diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2009-05-21 13:38:25 -0400 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2009-05-21 13:38:25 -0400 |
commit | 41fc26b70f7f9ce68b075bca9c7bc6d181624fca (patch) | |
tree | bc0ac9e014498b90dd7f8f937aa94ba5b82c46f0 /sigmodr/SigmodrUI.cpp | |
parent | 6d6ca27fbde34088fbfd8720a1306238f0336ad2 (diff) | |
download | sigen-41fc26b70f7f9ce68b075bca9c7bc6d181624fca.tar.gz sigen-41fc26b70f7f9ce68b075bca9c7bc6d181624fca.tar.xz sigen-41fc26b70f7f9ce68b075bca9c7bc6d181624fca.zip |
Handle selecting an index for the new model
Diffstat (limited to 'sigmodr/SigmodrUI.cpp')
-rw-r--r-- | sigmodr/SigmodrUI.cpp | 35 |
1 files changed, 26 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; } } |