11 #include <QGridLayout>
12 #include <QVBoxLayout>
13 #include <QHBoxLayout>
14 #include <QGraphicsView>
20 #include <QFileDialog>
21 #include <QHeaderView>
23 #include <QPushButton>
24 #include <QTableWidget>
26 #include <QDialogButtonBox>
32 :
QFrame(parent), mFrameWidth(0), mLayout(new
QGridLayout()), mGateLibrary(nullptr)
54 mTabWidget->
addTab(mGeneralTab,
"Gate Type");
55 mTabWidget->
addTab(mPinTab,
"Pins");
56 mTabWidget->
addTab(mBooleanFunctionTab,
"Truth Table");
96 mContentWidget->mCreationMode = mCreationMode;
97 std::filesystem::path path;
98 QFile gldpath(
":/path/gate_library_definitions");
103 if(allNames.
contains(
"unnamed_gate_library.hgl"))
106 while(allNames.
contains(
QString(
"unnamed_gate_library(%1).hgl").arg(cnt)))
108 path += std::filesystem::path(
QString(
"/unnamed_gate_library(%1).hgl").arg(cnt).toStdString());
110 else path +=
"/unnamed_gate_library.hgl";
118 mGateLibrary =
new GateLibrary(path, path.string());
120 mCreationMode =
false;
144 QString title =
"Load gate library";
145 QString text =
"HAL Gate Library (*.hgl *.lib)";
147 QFile gldpath(
":/path/gate_library_definitions");
153 if (fileName ==
nullptr)
162 mGateLibrary = gateLibrary;
175 mReadOnly = readOnly;
176 mGateLibrary = gateLibrary;
181 mPath = mGateLibrary->
get_path().generic_string();
186 mTableModel->
loadFile(mGateLibrary);
187 mContentWidget->
activate(mReadOnly);
204 for (
int r=0; r<mTableModel->
rowCount(); r++) {
206 mContentWidget->mTableView->
selectRow(r);
220 for (
int r=0; r<mTableModel->
rowCount(); r++) {
222 mContentWidget->mTableView->
selectRow(r);
242 occupiedIds->
insert(gt.second->get_id());
244 while(occupiedIds->
contains(freeId))
264 Gate*
g = mDemoNetlist->get_gate_by_id(1);
265 if (
g) mDemoNetlist->delete_gate(
g);
266 g = mDemoNetlist.get()->create_gate(1,gateType,
"Instance of");
292 GateType* GateLibraryManager::getSelectedGate()
303 mGeneralTab->
update(gateType);
304 mBooleanFunctionTab->
update(gateType);
305 mPinTab->
update(gateType);
317 msgBox->
setInformativeText(
"The current gate library has been modified. Do you want to save your changes or discard them?");
320 int r = msgBox->
exec();
331 mDemoNetlist.reset();
340 mDemoNetlist.reset();
359 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 setGateLibraryPath(std::filesystem::path p)
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)
void setGateLibrary(GateLibrary *gl)
A model to display loaded gatelibraries.
void loadFile(const GateLibrary *g)
GateType * getGateTypeAtIndex(int index)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void loadFeature(FacExtensionInterface::Feature ft, const QString &extension=QString())
const GateLibrary * get_gate_library() const
A proxy model to filter the ContextTableModel by a given string.
GuiPluginTable * mGuiPluginTable
void remove(std::filesystem::path file_path)
GateLibrary * load(std::filesystem::path file_path, bool reload)
std::unique_ptr< Netlist > create_netlist(const GateLibrary *gate_library)
Create a new empty netlist using the specified gate library.
PluginRelay * gPluginRelay
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
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
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)