diff options
author | ck <qt-info@nokia.com> | 2009-11-12 17:01:07 (GMT) |
---|---|---|
committer | ck <qt-info@nokia.com> | 2009-11-12 17:01:07 (GMT) |
commit | fc0403dd7c6d282882909fae32f729f5c855d55b (patch) | |
tree | c8fd498793608313e2b19000947fd9e287aba69e | |
parent | 45a5c5e2ba0ddc841629d99ee9929f5213293728 (diff) | |
download | Qt-fc0403dd7c6d282882909fae32f729f5c855d55b.zip Qt-fc0403dd7c6d282882909fae32f729f5c855d55b.tar.gz Qt-fc0403dd7c6d282882909fae32f729f5c855d55b.tar.bz2 |
Assistant: Refactoring of remote show/hide handling.
Got rid of some ugly code redundancy.
Reviewed-by: kh1
-rw-r--r-- | tools/assistant/tools/assistant/mainwindow.cpp | 73 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/mainwindow.h | 20 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/remotecontrol.cpp | 26 | ||||
-rw-r--r-- | tools/assistant/tools/assistant/remotecontrol.h | 3 |
4 files changed, 73 insertions, 49 deletions
diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 4b75387..08feb4e 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -875,41 +875,84 @@ void MainWindow::showAboutDialog() aboutDia.exec(); } +void MainWindow::setContentsVisible(bool visible) +{ + if (visible) + showContents(); + else + hideContents(); +} + void MainWindow::showContents() { activateDockWidget(m_contentWindow); } +void MainWindow::hideContents() +{ + m_contentWindow->parentWidget()->hide(); +} + +void MainWindow::setIndexVisible(bool visible) +{ + if (visible) + showIndex(); + else + hideIndex(); +} + void MainWindow::showIndex() { activateDockWidget(m_indexWindow); } +void MainWindow::hideIndex() +{ + m_indexWindow->parentWidget()->hide(); +} + +void MainWindow::setBookmarksVisible(bool visible) +{ + if (visible) + showBookmarks(); + else + hideBookmarks(); +} + + void MainWindow::showBookmarks() { activateDockWidget(m_bookmarkWidget); } -void MainWindow::activateDockWidget(QWidget *w) +void MainWindow::hideBookmarks() { - w->parentWidget()->show(); - w->parentWidget()->raise(); - w->setFocus(); + m_bookmarkWidget->parentWidget()->hide(); } -void MainWindow::hideContents() +void MainWindow::setSearchVisible(bool visible) { - m_contentWindow->parentWidget()->hide(); + if (visible) + showSearch(); + else + hideSearch(); } -void MainWindow::hideIndex() +void MainWindow::showSearch() { - m_indexWindow->parentWidget()->hide(); + m_centralWidget->activateSearchWidget(); } -void MainWindow::hideBookmarks() +void MainWindow::hideSearch() { - m_bookmarkWidget->parentWidget()->hide(); + m_centralWidget->removeSearchWidget(); +} + +void MainWindow::activateDockWidget(QWidget *w) +{ + w->parentWidget()->show(); + w->parentWidget()->raise(); + w->setFocus(); } void MainWindow::setIndexString(const QString &str) @@ -930,21 +973,11 @@ void MainWindow::activateCurrentCentralWidgetTab() m_centralWidget->activateTab(); } -void MainWindow::showSearch() -{ - m_centralWidget->activateSearchWidget(); -} - void MainWindow::showSearchWidget() { m_centralWidget->activateSearchWidget(true); } -void MainWindow::hideSearch() -{ - m_centralWidget->removeSearchWidget(); -} - void MainWindow::updateApplicationFont() { QFont font = qApp->font(); diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 3ab9403..96daf99 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -76,10 +76,6 @@ public: static QString defaultHelpCollectionFileName(); public: - void hideContents(); - void hideIndex(); - void hideBookmarks(); - void hideSearch(); void setIndexString(const QString &str); void expandTOC(int depth); bool usesDefaultCollection() const; @@ -88,16 +84,20 @@ signals: void initDone(); public slots: - void showContents(); - void showIndex(); - void showBookmarks(); - void showSearch(); + void setContentsVisible(bool visible); + void setIndexVisible(bool visible); + void setBookmarksVisible(bool visible); + void setSearchVisible(bool visible); void showSearchWidget(); void syncContents(); void activateCurrentCentralWidgetTab(); void currentFilterChanged(const QString &filter); private slots: + void showContents(); + void showIndex(); + void showBookmarks(); + void showSearch(); void insertLastPages(); void addBookmark(); void gotoAddress(); @@ -136,6 +136,10 @@ private: void setupAddressToolbar(); QMenu *toolBarMenu(); QWidget *setupBookmarkWidget(); + void hideContents(); + void hideIndex(); + void hideBookmarks(); + void hideSearch(); QHelpEngine *m_helpEngine; CentralWidget *m_centralWidget; diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index ee37b5e..55780e1 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -159,9 +159,9 @@ void RemoteControl::handleCommandString(const QString &cmdString) if (cmd == QLatin1String("debug")) handleDebugCommand(arg); else if (cmd == QLatin1String("show")) - handleShowCommand(arg); + handleShowOrHideCommand(arg, true); else if (cmd == QLatin1String("hide")) - handleHideCommand(arg); + handleShowOrHideCommand(arg, false); else if (cmd == QLatin1String("setsource")) handleSetSourceCommand(arg); else if (cmd == QLatin1String("synccontents")) @@ -202,28 +202,16 @@ void RemoteControl::handleDebugCommand(const QString &arg) m_debug = arg == QLatin1String("on"); } -void RemoteControl::handleShowCommand(const QString &arg) +void RemoteControl::handleShowOrHideCommand(const QString &arg, bool show) { if (arg.toLower() == QLatin1String("contents")) - m_mainWindow->showContents(); + m_mainWindow->setContentsVisible(show); else if (arg.toLower() == QLatin1String("index")) - m_mainWindow->showIndex(); + m_mainWindow->setIndexVisible(show); else if (arg.toLower() == QLatin1String("bookmarks")) - m_mainWindow->showBookmarks(); + m_mainWindow->setBookmarksVisible(show); else if (arg.toLower() == QLatin1String("search")) - m_mainWindow->showSearch(); -} - -void RemoteControl::handleHideCommand(const QString &arg) -{ - if (arg.toLower() == QLatin1String("contents")) - m_mainWindow->hideContents(); - else if (arg.toLower() == QLatin1String("index")) - m_mainWindow->hideIndex(); - else if (arg.toLower() == QLatin1String("bookmarks")) - m_mainWindow->hideBookmarks(); - else if (arg.toLower() == QLatin1String("search")) - m_mainWindow->hideSearch(); + m_mainWindow->setSearchVisible(show); } void RemoteControl::handleSetSourceCommand(const QString &arg) diff --git a/tools/assistant/tools/assistant/remotecontrol.h b/tools/assistant/tools/assistant/remotecontrol.h index 07d0479..c1c3105 100644 --- a/tools/assistant/tools/assistant/remotecontrol.h +++ b/tools/assistant/tools/assistant/remotecontrol.h @@ -67,8 +67,7 @@ private: void clearCache(); void splitInputString(const QString &input, QString &cmd, QString &arg); void handleDebugCommand(const QString &arg); - void handleShowCommand(const QString &arg); - void handleHideCommand(const QString &arg); + void handleShowOrHideCommand(const QString &arg, bool show); void handleSetSourceCommand(const QString &arg); void handleSyncContentsCommand(); void handleActivateKeywordCommand(const QString &arg); |