diff --git a/plugins/gui/include/gui/file_status_manager/file_status_manager.h b/plugins/gui/include/gui/file_status_manager/file_status_manager.h index 857ff0a703c..4d535fc1fda 100644 --- a/plugins/gui/include/gui/file_status_manager/file_status_manager.h +++ b/plugins/gui/include/gui/file_status_manager/file_status_manager.h @@ -115,12 +115,6 @@ namespace hal */ bool isGatelibModified() const; - /** - * Removes all registered files and unsets every modified-flag, effectively resetting - * the state of the manager. - */ - void flushUnsavedChanges(); - /** * Get a list of the descriptions of all modified files that are registered to this manager. * Appends "Netlist modifications" to the list if the netlist-modified flag is set. diff --git a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_pin.h b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_pin.h index 04f37e319f5..6c82f08361f 100644 --- a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_pin.h +++ b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_pin.h @@ -37,6 +37,22 @@ namespace hal { + class PinTreeView : public QTreeView + { + Q_OBJECT + + /* controll tree navigation using arrow keys + protected: + QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override; + */ + + public Q_SLOTS: + void handleEditNewDone(const QModelIndex& index); + + public: + PinTreeView(QWidget* parent = nullptr); + }; + /** * Widget which shows information of the boolean functions of a gate */ @@ -45,8 +61,7 @@ namespace hal Q_OBJECT public: - GateLibraryTabPin(QWidget* parent = nullptr); - GateLibraryTabPin(QWidget* parent, bool editable); + GateLibraryTabPin(bool editable = false, QWidget* parent = nullptr); QTreeView* getTreeView(); PinModel* getPinModel(); @@ -55,7 +70,7 @@ namespace hal private: PinModel* mPinModel; - QTreeView* mTreeView; + PinTreeView* mTreeView; QGridLayout* mGridLayout; diff --git a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h index f07481e4db2..9ae42ca588a 100644 --- a/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h +++ b/plugins/gui/include/gui/gatelibrary_management/gatelibrary_wizard.h @@ -91,7 +91,6 @@ namespace hal BoolWizardPage* boolPage; PinModel* mPinModel; - GateLibraryTabPin* mPinTab; GateType* mNewGateType; }; } diff --git a/plugins/gui/include/gui/pin_model/pin_model.h b/plugins/gui/include/gui/pin_model/pin_model.h index 4cb83518b8f..e12d856d460 100644 --- a/plugins/gui/include/gui/pin_model/pin_model.h +++ b/plugins/gui/include/gui/pin_model/pin_model.h @@ -50,6 +50,9 @@ namespace hal { Q_OBJECT + Q_SIGNALS: + void editNewDone(QModelIndex index); + public: explicit PinModel(QObject* parent = nullptr); diff --git a/plugins/gui/resources/stylesheet/dark.qss b/plugins/gui/resources/stylesheet/dark.qss index 8e05b6fdac7..8a1ac27ee38 100755 --- a/plugins/gui/resources/stylesheet/dark.qss +++ b/plugins/gui/resources/stylesheet/dark.qss @@ -960,6 +960,24 @@ hal--GeneralInfoWizardPage #arrowButton max-width : 12px; } +hal--PinTreeView::item:focus +{ + background : rgba(10,20,80,0.6); + selection-background-color : rgba(10,20,80,0.6); +} + +/* +hal--PinTreeView +{ + background : gray; +} + +hal--PinTreeView::item:selected +{ + background : red; +} +*/ + hal--ImportNetlistDialog { qproperty-saveIconStyle: "all->#3192C5"; diff --git a/plugins/gui/src/file_status_manager/file_status_manager.cpp b/plugins/gui/src/file_status_manager/file_status_manager.cpp index a173b3204c5..e65a8ae4eb4 100644 --- a/plugins/gui/src/file_status_manager/file_status_manager.cpp +++ b/plugins/gui/src/file_status_manager/file_status_manager.cpp @@ -39,13 +39,6 @@ namespace hal return !mModifiedFilesUuid.empty() || mNetlistModified; } - void FileStatusManager::flushUnsavedChanges() - { - mModifiedFilesUuid.clear(); - mModifiedFilesDescriptors.clear(); - netlistSaved(); - } - void FileStatusManager::netlistChanged() { bool before = modifiedFilesExisting(); @@ -65,6 +58,8 @@ namespace hal void FileStatusManager::netlistClosed() { mNetlistModified = false; + mModifiedFilesUuid.clear(); + mModifiedFilesDescriptors.clear(); Q_EMIT status_changed(false, false); } diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_manager.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_manager.cpp index 7463e6a6f53..c7c10d7b5b6 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_manager.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_manager.cpp @@ -43,7 +43,7 @@ namespace hal //pages for the tab widget mGeneralTab = new GateLibraryTabGeneral(this); - mPinTab = new GateLibraryTabPin(this); + mPinTab = new GateLibraryTabPin(false,this); mBooleanFunctionTab = new GateLibraryTabTruthTable(this); @@ -267,6 +267,7 @@ namespace hal break; case QMessageBox::Discard: gate_library_manager::remove(std::filesystem::path(mEditableGatelibrary->get_path())); + gFileStatusManager->gatelibSaved(); window()->setWindowTitle("HAL"); Q_EMIT close(); break; diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/pins_wizardpage.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/pins_wizardpage.cpp index d24751a5565..58f414fb234 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_pages/pins_wizardpage.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_pages/pins_wizardpage.cpp @@ -11,7 +11,7 @@ namespace hal setSubTitle("Edit pins and pingroups"); QGridLayout* layout = new QGridLayout(this); - mPinTab = new GateLibraryTabPin(this, true); + mPinTab = new GateLibraryTabPin(true, this); mDelBtn = new QPushButton("Delete", this); mPinModel = mPinTab->getPinModel(); diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_pin.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_pin.cpp index acbae9c29c3..68d89305774 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_pin.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_pin.cpp @@ -10,28 +10,66 @@ namespace hal { - GateLibraryTabPin::GateLibraryTabPin(QWidget* parent) : GateLibraryTabInterface(parent) + PinTreeView::PinTreeView(QWidget* parent) + : QTreeView(parent) { - mGridLayout = new QGridLayout(this); + QStyle* s = style(); - mTreeView = new QTreeView(this); - mPinModel = new PinModel(this); + s->unpolish(this); + s->polish(this); + setSelectionBehavior(QAbstractItemView::SelectItems); + } - mTreeView->setModel(mPinModel); + /* + QModelIndex PinTreeView::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers) + { + QModelIndex inx = currentIndex(); + QModelIndex par = inx.parent(); + int pcount = 0; + while (par.isValid()) + { + ++pcount; + par = par.parent(); + } + std::cerr << "moveCursor " << cursorAction << " current: " << model()->data(inx).toString().toStdString() << std::endl; + + return QTreeView::moveCursor(cursorAction, modifiers); + } + */ - mGridLayout->addWidget(mTreeView); + void PinTreeView::handleEditNewDone(const QModelIndex& index) + { + QModelIndex nextIndex; - setLayout(mGridLayout); + if (index.column() || index.parent().isValid()) + nextIndex = model()->index(index.row()+1,0,index.parent()); + else + nextIndex = model()->index(index.row(),1,index.parent()); + + setCurrentIndex(nextIndex); + edit(nextIndex); } - GateLibraryTabPin::GateLibraryTabPin(QWidget* parent, bool editable) + + GateLibraryTabPin::GateLibraryTabPin(bool editable, QWidget* parent) + : GateLibraryTabInterface(parent) { mGridLayout = new QGridLayout(this); - mTreeView = new QTreeView(this); - mPinModel = new PinModel(this, editable); - auto pinDelegate = new PinDelegate(this); - mTreeView->setItemDelegate(pinDelegate); + mTreeView = new PinTreeView(this); + + if (editable) + { + mPinModel = new PinModel(this, editable); + auto pinDelegate = new PinDelegate(this); + mTreeView->setItemDelegate(pinDelegate); + connect(mPinModel, &PinModel::editNewDone, mTreeView, &PinTreeView::handleEditNewDone, Qt::QueuedConnection); + } + else + { + mPinModel = new PinModel(this); + } + mTreeView->setModel(mPinModel); mGridLayout->addWidget(mTreeView); diff --git a/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp b/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp index fd58d6b866a..cccfd154330 100644 --- a/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp +++ b/plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp @@ -45,7 +45,6 @@ namespace hal mGateLibrary = gateLibrary; mGateType = gateType; mPinModel = new PinModel(this, true); - mPinTab = new GateLibraryTabPin(this, true); if(mGateType == nullptr) { diff --git a/plugins/gui/src/main_window/main_window.cpp b/plugins/gui/src/main_window/main_window.cpp index bb5e7a23943..0deafdf34f1 100644 --- a/plugins/gui/src/main_window/main_window.cpp +++ b/plugins/gui/src/main_window/main_window.cpp @@ -966,7 +966,7 @@ namespace hal void MainWindow::closeEvent(QCloseEvent* event) { - if (FileManager::get_instance()->fileOpen()) + if (gFileStatusManager->isGatelibModified() || FileManager::get_instance()->fileOpen()) { if (tryToCloseFile()) event->accept(); diff --git a/plugins/gui/src/pin_model/pin_model.cpp b/plugins/gui/src/pin_model/pin_model.cpp index f99ccbba59f..f7b825a59dd 100644 --- a/plugins/gui/src/pin_model/pin_model.cpp +++ b/plugins/gui/src/pin_model/pin_model.cpp @@ -209,6 +209,7 @@ namespace hal //add pin to group //addPinToPinGroup(initialPin, pinItem); + Q_EMIT editNewDone(index); break; } case PinItem::TreeItemType::PinCreator:{ @@ -235,6 +236,7 @@ namespace hal //auto pinGroup = static_cast(pinItem->getParent()); //addPinToPinGroup(pinItem, pinGroup); + Q_EMIT editNewDone(index); break; } case PinItem::TreeItemType::InvalidPin:{ @@ -254,6 +256,7 @@ namespace hal auto pinItem = static_cast(index.internalPointer()); auto itemType = pinItem->getItemType(); + PinDirection oldDirection = pinItem->getDirection(); PinDirection pinDirection = enum_from_string(directionString.toStdString()); switch(itemType){ @@ -298,6 +301,8 @@ namespace hal } } Q_EMIT dataChanged(index, index); + if (oldDirection == PinDirection::none) + Q_EMIT editNewDone(index); } void PinModel::handleEditType(QModelIndex index, const QString& typeString)