summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-05-21 13:38:25 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-05-21 13:38:25 -0400
commit41fc26b70f7f9ce68b075bca9c7bc6d181624fca (patch)
treebc0ac9e014498b90dd7f8f937aa94ba5b82c46f0
parent6d6ca27fbde34088fbfd8720a1306238f0336ad2 (diff)
downloadsigen-41fc26b70f7f9ce68b075bca9c7bc6d181624fca.tar.gz
sigen-41fc26b70f7f9ce68b075bca9c7bc6d181624fca.tar.xz
sigen-41fc26b70f7f9ce68b075bca9c7bc6d181624fca.zip
Handle selecting an index for the new model
-rw-r--r--sigmodr/SigmodrUI.cpp35
-rw-r--r--sigmodr/SigmodrUI.h1
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;
};