From a8fe7817035764935cce1e2de46a4047f0cd33da Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Wed, 7 Oct 2009 19:31:39 +0000 Subject: [PATCH] fixes #499 2009-10-07 vadim * FindWhereUsedWidget.cpp (FindWhereUsedWidget::itemClicked): "find where used" panel selects object in the tree or in rules on single click in the list of the results. To open the object in the editor user needs to switch to the editor tab in the bottom docked panel. --- build_num | 2 +- doc/ChangeLog | 8 ++ src/gui/FWBMainWindow_q.ui | 17 ++++ src/gui/FWWindow.h | 2 + src/gui/FWWindow_editor.cpp | 24 ++++-- src/gui/FindWhereUsedWidget.cpp | 26 ++++++- src/gui/FindWhereUsedWidget.h | 3 +- src/gui/ObjectEditor.cpp | 34 ++++---- src/gui/findwhereusedwidget_q.ui | 129 ++++++++++++++++--------------- 9 files changed, 155 insertions(+), 90 deletions(-) diff --git a/build_num b/build_num index 59b60198d..38ccb13bb 100644 --- a/build_num +++ b/build_num @@ -1 +1 @@ -#define BUILD_NUM 1563 +#define BUILD_NUM 1564 diff --git a/doc/ChangeLog b/doc/ChangeLog index 4965482e9..3d7cd80b6 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,11 @@ +2009-10-07 vadim + + * FindWhereUsedWidget.cpp (FindWhereUsedWidget::itemClicked): + "find where used" panel selects object in the tree or in rules on + single click in the list of the results. To open the object in the + editor user needs to switch to the editor tab in the bottom docked + panel. + 2009-10-03 vadim * PolicyCompiler_ipt.cpp (PolicyCompiler_ipt::insertFailoverRule): diff --git a/src/gui/FWBMainWindow_q.ui b/src/gui/FWBMainWindow_q.ui index 769780d1b..b8baec4ad 100644 --- a/src/gui/FWBMainWindow_q.ui +++ b/src/gui/FWBMainWindow_q.ui @@ -2418,6 +2418,22 @@ + + editorPanelTabWidget + currentChanged(int) + FWBMainWindow_q + editorPanelTabChanged(int) + + + 511 + 708 + + + 540 + 422 + + + clearRecentFilesMenu() @@ -2426,5 +2442,6 @@ toggleViewRules() toggleViewEditor() toggleViewSearch() + editorPanelTabChanged(int) diff --git a/src/gui/FWWindow.h b/src/gui/FWWindow.h index 6741cd913..36afaf221 100644 --- a/src/gui/FWWindow.h +++ b/src/gui/FWWindow.h @@ -137,6 +137,8 @@ public slots: void selectActiveSubWindow (/*const QString & text*/); void subWindowActivated(QMdiSubWindow*); + void editorPanelTabChanged(int); + void minimize(); void maximize(); virtual void search(); diff --git a/src/gui/FWWindow_editor.cpp b/src/gui/FWWindow_editor.cpp index cb8d24e91..3952da9ed 100644 --- a/src/gui/FWWindow_editor.cpp +++ b/src/gui/FWWindow_editor.cpp @@ -48,17 +48,18 @@ using namespace libfwbuilder; /* - * when ProjectPanel is created, it send bunch of stateChange events - * which leads to calls to ProjectPanel::changeEvent() method. This - * method checks if editr is visible and contains modified data. Since - * we create defaulr ProjectPanel object in the constructor of + * when ProjectPanel is created, it sends bunch of stateChange events + * which lead to calls to ProjectPanel::changeEvent() method. This + * method checks if editor is visible and contains modified data. Since + * we create default ProjectPanel object in the constructor of * FWWindow, the first call to ProjectPanel::changeEvent() comes when * object editor has not been create yet. This is why we need to check * for oe != NULL here and below. */ bool FWWindow::isEditorVisible() { - return oe != NULL && m_mainWindow->editorDockWidget->isVisible(); // editor + return oe != NULL && m_mainWindow->editorDockWidget->isVisible() && + m_mainWindow->editorPanelTabWidget->currentIndex() == EDITOR_PANEL_EDITOR_TAB; } bool FWWindow::isEditorModified() @@ -66,6 +67,19 @@ bool FWWindow::isEditorModified() return oe != NULL && oe->isModified(); } +void FWWindow::editorPanelTabChanged(int idx) +{ + if (idx == EDITOR_PANEL_EDITOR_TAB) + { + ProjectPanel *pp = activeProject(); + if (pp) + { + oe->open(pp->getSelectedObject()); + m_mainWindow->objectEditorStack->setCurrentIndex(oe->getCurrentDialogIndex()); + } + } +} + void FWWindow::showEditor() { m_mainWindow->objectEditorStack->setCurrentIndex(oe->getCurrentDialogIndex()); diff --git a/src/gui/FindWhereUsedWidget.cpp b/src/gui/FindWhereUsedWidget.cpp index 38d48134c..befec9b86 100644 --- a/src/gui/FindWhereUsedWidget.cpp +++ b/src/gui/FindWhereUsedWidget.cpp @@ -112,7 +112,31 @@ void FindWhereUsedWidget::setShowObject(bool fl) flShowObject=fl; } -void FindWhereUsedWidget::itemActivated(QTreeWidgetItem* item) +/** + * This signal is emitted when the user activates an item by single- + * or double-clicking (depending on the platform, i.e. on the + * QStyle::SH_ItemView_ActivateItemOnSingleClick style hint) or + * pressing a special key (e.g., Enter). + */ +void FindWhereUsedWidget::itemActivated(QTreeWidgetItem* item, int) +{ + FWObject *container = (FWObject*)(qVariantValue(item->data(1, Qt::UserRole))); + + if (flShowObject && container!=NULL) + { + showObject(container); + } +} + +/** + * This signal is emitted when the user clicks inside the widget. + * + * The specified item is the item that was clicked, or 0 if no item + * was clicked. The column is the item's column that was clicked. If + * no item was clicked, no signal will be emitted. + * + */ +void FindWhereUsedWidget::itemClicked(QTreeWidgetItem* item, int) { FWObject *container = (FWObject*)(qVariantValue(item->data(1, Qt::UserRole))); diff --git a/src/gui/FindWhereUsedWidget.h b/src/gui/FindWhereUsedWidget.h index 0030cfeb7..9e2d4417b 100644 --- a/src/gui/FindWhereUsedWidget.h +++ b/src/gui/FindWhereUsedWidget.h @@ -85,7 +85,8 @@ public slots: virtual void find(); virtual void find(libfwbuilder::FWObject *obj); void init(); - void itemActivated(QTreeWidgetItem*); + void itemActivated(QTreeWidgetItem*, int); + void itemClicked(QTreeWidgetItem*, int); void findFromDrop(); signals: diff --git a/src/gui/ObjectEditor.cpp b/src/gui/ObjectEditor.cpp index bdfd07837..402998555 100644 --- a/src/gui/ObjectEditor.cpp +++ b/src/gui/ObjectEditor.cpp @@ -275,8 +275,14 @@ QString ObjectEditor::getOptDialogName(OptType t) return QString("OptionDialog_%1").arg(t); } -void ObjectEditor::openOpt(FWObject *obj,OptType t) +void ObjectEditor::openOpt(FWObject *obj, OptType t) { + if (fwbdebug) + qDebug() << "ObjectEditor::openOpt obj=" << obj + << QString((obj)?obj->getName().c_str():"") + << QString((obj)?obj->getTypeName().c_str():"") + << "t=" << t; + if (Rule::cast(obj)==NULL) return; disconnectSignals(); @@ -332,22 +338,16 @@ void ObjectEditor::open(FWObject *obj) openedOpt = optNone; if (stackIds.count(obj->getTypeName().c_str())!=0) { + if (fwbdebug) + qDebug() << "ObjectEditor::open obj=" << obj + << QString((obj)?obj->getName().c_str():"") + << QString((obj)?obj->getTypeName().c_str():""); + disconnectSignals(); current_dialog_name = obj->getTypeName().c_str(); current_dialog_idx = stackIds[current_dialog_name]; -// disconnect( SIGNAL(loadObject_sign(libfwbuilder::FWObject*)) ); -// disconnect( SIGNAL(validate_sign(bool*)) ); -// disconnect( SIGNAL(isChanged_sign(bool*)) ); -// disconnect( SIGNAL(applyChanges_sign()) ); -// disconnect( SIGNAL(discardChanges_sign()) ); -// disconnect( SIGNAL(close_sign(QCloseEvent*)) ); - - //hide(); - - - show(); connect(this, SIGNAL(loadObject_sign(libfwbuilder::FWObject*)), @@ -358,10 +358,6 @@ void ObjectEditor::open(FWObject *obj) dialogs[ current_dialog_idx ], SLOT(validate(bool*))); - //connect(this, SIGNAL(isChanged_sign(bool*)), - // dialogs[ current_dialog_idx ], - // SLOT(isChanged(bool*))); - connect(this, SIGNAL(applyChanges_sign()), dialogs[ current_dialog_idx ], SLOT(applyChanges())); @@ -388,10 +384,10 @@ void ObjectEditor::open(FWObject *obj) emit loadObject_sign(obj); findAndLoadHelp(); - } - opened = obj; - applyButton->setEnabled(false); + opened = obj; + applyButton->setEnabled(false); + } } void ObjectEditor::disconnectSignals() diff --git a/src/gui/findwhereusedwidget_q.ui b/src/gui/findwhereusedwidget_q.ui index 337bcc249..4cd0872f6 100644 --- a/src/gui/findwhereusedwidget_q.ui +++ b/src/gui/findwhereusedwidget_q.ui @@ -1,8 +1,7 @@ - - + findWhereUsedWidget_q - - + + 0 0 @@ -10,56 +9,56 @@ 164 - - + + 0 0 - + Form1 - - + + 6 - - - + + + Object: - - + + 6 - - - + + + 0 0 - + 100 80 - + - + Qt::Vertical - + QSizePolicy::Expanding - + 20 31 @@ -70,38 +69,38 @@ - - - - + + + + 0 0 - + Object is found in : - - + + 6 - - - + + + true - + Object - + Parent - + Details @@ -110,27 +109,27 @@ - - - + + + QFrame::NoFrame - + QFrame::Raised - - + + 0 - + - + Qt::Vertical - + QSizePolicy::Expanding - + 20 20 @@ -138,9 +137,9 @@ - - - + + + Find @@ -150,7 +149,7 @@ - + FWObjectDropArea @@ -166,36 +165,40 @@ - resListView - itemActivated(QTreeWidgetItem*, int) + pushButton2 + clicked() findWhereUsedWidget_q - itemActivated(QTreeWidgetItem*) + find() - + 20 20 - + 20 20 - pushButton2 - clicked() + resListView + itemClicked(QTreeWidgetItem*,int) findWhereUsedWidget_q - find() + itemClicked(QTreeWidgetItem*,int) - - 20 - 20 + + 457 + 88 - - 20 - 20 + + 433 + 81 + + itemActivated(QTreeWidgetItem*,int) + itemClicked(QTreeWidgetItem*,int) +