Skip to content

Commit

Permalink
Fix navigation for Gate-Pin-Input wizard page
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Sep 8, 2024
1 parent 0def71a commit 0417b89
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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();

Expand All @@ -55,7 +70,7 @@ namespace hal

private:
PinModel* mPinModel;
QTreeView* mTreeView;
PinTreeView* mTreeView;

QGridLayout* mGridLayout;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ namespace hal
BoolWizardPage* boolPage;

PinModel* mPinModel;
GateLibraryTabPin* mPinTab;
GateType* mNewGateType;
};
}
3 changes: 3 additions & 0 deletions plugins/gui/include/gui/pin_model/pin_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ namespace hal
{
Q_OBJECT

Q_SIGNALS:
void editNewDone(QModelIndex index);

public:

explicit PinModel(QObject* parent = nullptr);
Expand Down
18 changes: 18 additions & 0 deletions plugins/gui/resources/stylesheet/dark.qss
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
9 changes: 2 additions & 7 deletions plugins/gui/src/file_status_manager/file_status_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ namespace hal
return !mModifiedFilesUuid.empty() || mNetlistModified;
}

void FileStatusManager::flushUnsavedChanges()
{
mModifiedFilesUuid.clear();
mModifiedFilesDescriptors.clear();
netlistSaved();
}

void FileStatusManager::netlistChanged()
{
bool before = modifiedFilesExisting();
Expand All @@ -65,6 +58,8 @@ namespace hal
void FileStatusManager::netlistClosed()
{
mNetlistModified = false;
mModifiedFilesUuid.clear();
mModifiedFilesDescriptors.clear();
Q_EMIT status_changed(false, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ namespace hal
mGateLibrary = gateLibrary;
mGateType = gateType;
mPinModel = new PinModel(this, true);
mPinTab = new GateLibraryTabPin(this, true);

if(mGateType == nullptr)
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/gui/src/main_window/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions plugins/gui/src/pin_model/pin_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ namespace hal
//add pin to group
//addPinToPinGroup(initialPin, pinItem);

Q_EMIT editNewDone(index);
break;
}
case PinItem::TreeItemType::PinCreator:{
Expand All @@ -235,6 +236,7 @@ namespace hal
//auto pinGroup = static_cast<PinItem*>(pinItem->getParent());
//addPinToPinGroup(pinItem, pinGroup);

Q_EMIT editNewDone(index);
break;
}
case PinItem::TreeItemType::InvalidPin:{
Expand All @@ -254,6 +256,7 @@ namespace hal
auto pinItem = static_cast<PinItem*>(index.internalPointer());
auto itemType = pinItem->getItemType();

PinDirection oldDirection = pinItem->getDirection();
PinDirection pinDirection = enum_from_string<PinDirection>(directionString.toStdString());

switch(itemType){
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0417b89

Please sign in to comment.