From 41fc26b70f7f9ce68b075bca9c7bc6d181624fca Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 21 May 2009 13:38:25 -0400 Subject: Handle selecting an index for the new model --- sigmodr/SigmodrUI.cpp | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'sigmodr/SigmodrUI.cpp') 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; } } -- cgit