10 #include <QGridLayout>
11 #include <QVBoxLayout>
12 #include <QHBoxLayout>
13 #include <QGraphicsView>
19 #include <QFileDialog>
20 #include <QHeaderView>
22 #include <QPushButton>
23 #include <QTableWidget>
25 #include <QDialogButtonBox>
53 mTabWidget->
addTab(mGeneralTab,
"Gate Type");
54 mTabWidget->
addTab(mPinTab,
"Pins");
55 mTabWidget->
addTab(mBooleanFunctionTab,
"Truth Table");
95 mContentWidget->mCreationMode = mCreationMode;
96 std::filesystem::path path;
97 QFile gldpath(
":/path/gate_library_definitions");
102 if(allNames.
contains(
"unnamed_gate_library.hgl"))
105 while(allNames.
contains(
QString(
"unnamed_gate_library(%1).hgl").arg(cnt)))
107 path += std::filesystem::path(
QString(
"/unnamed_gate_library(%1).hgl").arg(cnt).toStdString());
109 else path +=
"/unnamed_gate_library.hgl";
117 mContentWidget->mGateLibrary =
new GateLibrary(path, path.string());
119 mCreationMode =
false;
134 if (!mContentWidget->initialize(gateLibrary,readOnly))
142 mTableModel->
loadFile(mContentWidget->mGateLibrary);
143 mContentWidget->
activate(mContentWidget->mReadOnly);
152 if(mContentWidget->mReadOnly)
161 for (
int r=0; r<mTableModel->
rowCount(); r++) {
163 mContentWidget->mTableView->
selectRow(r);
175 for (
int r=0; r<mTableModel->
rowCount(); r++) {
177 mContentWidget->mTableView->
selectRow(r);
195 occupiedIds->
insert(gt.second->get_id());
197 while(occupiedIds->
contains(freeId))
217 Gate*
g = mDemoNetlist->get_gate_by_id(1);
218 if (
g) mDemoNetlist->delete_gate(
g);
219 g = mDemoNetlist.get()->create_gate(1,gateType,
"Instance of");
224 void GateLibraryManager::emitClose()
252 GateType* GateLibraryManager::getSelectedGate()
263 mGeneralTab->
update(gateType);
264 mBooleanFunctionTab->
update(gateType);
265 mPinTab->
update(gateType);
270 return mContentWidget->mReadOnly;
277 msgBox->
setInformativeText(
"The current gate library has been modified. Do you want to save your changes or discard them?");
280 int r = msgBox->
exec();
291 mDemoNetlist.reset();
300 mDemoNetlist.reset();
319 splitSizes << mFrameWidth * 27 / 100 << mFrameWidth * 73 / 100;
bool isGatelibModified() const
std::filesystem::path get_path() const
void remove_gate_type(const std::string &name)
std::unordered_map< std::string, GateType * > get_gate_types(const std::function< bool(const GateType *)> &filter=nullptr) const
bool initialize(GateLibrary *gateLibrary=nullptr, bool readOnly=false)
void updateTabs(GateType *gateType)
bool callUnsavedChangesWindow()
void handleCancelClicked()
void handleCreateAction()
void handleSaveAsAction()
void handleEditWizard(const QModelIndex &index)
void handleDeleteType(QModelIndex index)
void handleSelectionChanged(const QModelIndex &index, const QModelIndex &prevIndex)
GateLibraryManager(MainWindow *parent)
void resizeEvent(QResizeEvent *evt) override
void update(GateType *gt) override
void update(GateType *gate) override
void update(GateType *gt) override
void triggerUnsavedChanges()
GateType * getRecentCreatedGate()
const std::string & get_name() const
void triggerEditType(QModelIndex index)
void triggerCurrentSelectionChanged(QModelIndex index, QModelIndex prevIndex)
void handleSaveAsAction()
void triggerDoubleClicked(QModelIndex index)
void triggerDeleteType(QModelIndex index)
void activate(bool readOnly=false)
void toggleSelection(bool selected)
A model to display loaded gatelibraries.
void loadFile(const GateLibrary *g)
GateType * getGateTypeAtIndex(int index)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
A proxy model to filter the ContextTableModel by a given string.
void remove(std::filesystem::path file_path)
std::unique_ptr< Netlist > create_netlist(const GateLibrary *gate_library)
Create a new empty netlist using the specified gate library.
FileStatusManager * gFileStatusManager
This file contains various functions to create and load netlists.
QModelIndex currentIndex() const const
void triggered(bool checked)
QStringList entryList(QDir::Filters filters, QDir::SortFlags sort) const const
virtual bool open(QIODevice::OpenMode mode) override
void setSceneRect(const QRectF &rect)
void setScene(QGraphicsScene *scene)
virtual int exec() override
void setInformativeText(const QString &text)
void setWindowTitle(const QString &title)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
const QSize & size() const const
bool contains(const T &value) const const
QSet::iterator insert(const T &value)
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const const override
void setSizes(const QList< int > &list)
QString fromStdString(const std::string &str)
QString fromUtf8(const char *str, int size)
std::string toStdString() const const
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
virtual void polish(QWidget *widget)
virtual void unpolish(QWidget *widget)