diff options
-rw-r--r-- | sigmodr/SigmodrUI.cpp | 35 | ||||
-rw-r--r-- | sigmodr/SigmodrUI.h | 1 |
2 files changed, 27 insertions, 9 deletions
diff --git a/sigmodr/SigmodrUI.cpp b/sigmodr/SigmodrUI.cpp index 7d051fea..c9bc0163 100644 --- a/sigmodr/SigmodrUI.cpp +++ b/sigmodr/SigmodrUI.cpp @@ -473,16 +473,33 @@ void SigmodrUI::on_treeSigmod_clicked(const QModelIndex& index) { if (!(treeSigmod->model()->flags(index) & Qt::ItemIsEnabled)) return; - ObjectUI* widget = treeSigmod->editorWidget(index); - if (widget && closeWidget()) + switch (index.column()) { - connect(widget, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); - connect(widget, SIGNAL(saved()), this, SLOT(setDirty())); - connect(buttonApply, SIGNAL(clicked()), widget, SLOT(apply())); - connect(buttonReset, SIGNAL(clicked()), widget, SLOT(discard())); - setChangedTitle(treeSigmod->dirty(treeSigmod->currentGame())); - formPanel->setWidget(widget); - formPanel->show(); + case 1: + { + ObjectUI* editor = treeSigmod->editorWidget(index); + if (editor && closeWidget()) + { + connect(editor, SIGNAL(changed(bool)), boxButtons, SLOT(setEnabled(bool))); + connect(editor, SIGNAL(saved()), this, SLOT(setDirty())); + connect(buttonApply, SIGNAL(clicked()), editor, SLOT(apply())); + connect(buttonReset, SIGNAL(clicked()), editor, SLOT(discard())); + setChangedTitle(treeSigmod->dirty(treeSigmod->currentGame())); + formPanel->setWidget(editor); + formPanel->show(); + m_editedIndex = index; + } + break; + } + case 2: + if ((m_editedIndex.internalId() != index.internalId()) || closeWidget()) + treeSigmod->model()->removeRow(index.row(), index.parent()); + break; + case 3: + treeSigmod->model()->insertRow(treeSigmod->model()->rowCount(index), index); + break; + default: + break; } } diff --git a/sigmodr/SigmodrUI.h b/sigmodr/SigmodrUI.h index 561ba3a4..b9ffab26 100644 --- a/sigmodr/SigmodrUI.h +++ b/sigmodr/SigmodrUI.h @@ -89,6 +89,7 @@ class SigmodrUI : public KXmlGuiWindow, private Ui::formSigmodr private: void setupActions(); + QModelIndex m_editedIndex; QSplitter* ui_splitter; QDomDocument m_clipboard; }; |