From 5ec42868508a0f2dc2f82fea19ae478fa274924b Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Fri, 13 May 2011 15:17:05 +0200 Subject: [PATCH] Added search bar (can be activated by Ctrl+F/CMD+F) @TODO change search icon? @TODO remove title for search bar --- qt/mainwindow.cpp | 135 ++++++++++++++++++++++++++----------------- qt/mainwindow.hpp | 19 +++--- qt/res/resources.qrc | 1 + qt/res/search.png | Bin 0 -> 7039 bytes 4 files changed, 94 insertions(+), 61 deletions(-) create mode 100644 qt/res/search.png diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 2d81af06f3..77d904cfbb 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #define IDM_ABOUT_DIALOG 1001 #define IDM_PREFERENCES_DIALOG 1002 @@ -42,6 +43,8 @@ MainWindow::MainWindow() CreateNavigationBar(); + CreateSearchBar(); + #ifdef DEBUG // code removed for desktop releases CreateClassifPanel(); CreateGuidePanel(); @@ -200,9 +203,9 @@ namespace void MainWindow::CreateNavigationBar() { - QToolBar * pBar = new QToolBar(tr("Navigation Bar"), this); - pBar->setOrientation(Qt::Vertical); - pBar->setIconSize(QSize(32, 32)); + QToolBar * pToolBar = new QToolBar(tr("Navigation Bar"), this); + pToolBar->setOrientation(Qt::Vertical); + pToolBar->setIconSize(QSize(32, 32)); { // add navigation hot keys @@ -228,25 +231,31 @@ void MainWindow::CreateNavigationBar() } { + // add search button with "checked" behavior + m_pSearchAction = pToolBar->addAction(QIcon(":/navig64/search.png"), + tr("Search"), + this, + SLOT(OnSearchButtonClicked())); + m_pSearchAction->setCheckable(true); + m_pSearchAction->setToolTip(tr("Offline Search")); + + pToolBar->addSeparator(); + // add my position button with "checked" behavior - m_pMyPosition = pBar->addAction(QIcon(":/navig64/location.png"), + m_pMyPositionAction = pToolBar->addAction(QIcon(":/navig64/location.png"), tr("My Position"), this, SLOT(OnMyPosition())); - m_pMyPosition->setCheckable(true); - m_pMyPosition->setToolTip(tr("My Position")); + m_pMyPositionAction->setCheckable(true); + m_pMyPositionAction->setToolTip(tr("My Position")); // add view actions 1 button_t arr[] = { -// { tr("Left"), ":/navig64/left.png", SLOT(MoveLeft()) }, -// { tr("Right"), ":/navig64/right.png", SLOT(MoveRight()) }, -// { tr("Up"), ":/navig64/up.png", SLOT(MoveUp()) }, -// { tr("Down"), ":/navig64/down.png", SLOT(MoveDown()) }, { QString(), 0, 0 }, { tr("Show all"), ":/navig64/world.png", SLOT(ShowAll()) }, { tr("Scale +"), ":/navig64/plus.png", SLOT(ScalePlus()) } }; - add_buttons(pBar, arr, ARRAY_SIZE(arr), m_pDrawWidget); + add_buttons(pToolBar, arr, ARRAY_SIZE(arr), m_pDrawWidget); } // add scale slider @@ -254,7 +263,7 @@ void MainWindow::CreateNavigationBar() pScale->setRange(3, scales::GetUpperScale()); pScale->setTickPosition(QSlider::TicksRight); - pBar->addWidget(pScale); + pToolBar->addWidget(pScale); m_pDrawWidget->SetScaleControl(pScale); { @@ -262,7 +271,7 @@ void MainWindow::CreateNavigationBar() button_t arr[] = { { tr("Scale -"), ":/navig64/minus.png", SLOT(ScaleMinus()) } }; - add_buttons(pBar, arr, ARRAY_SIZE(arr), m_pDrawWidget); + add_buttons(pToolBar, arr, ARRAY_SIZE(arr), m_pDrawWidget); } #ifdef DEBUG // code removed for desktop releases { @@ -271,37 +280,12 @@ void MainWindow::CreateNavigationBar() { QString(), 0, 0 }, { tr("Download Maps"), ":/navig64/download.png", SLOT(ShowUpdateDialog()) } }; - add_buttons(pBar, arr, ARRAY_SIZE(arr), this); + add_buttons(pToolBar, arr, ARRAY_SIZE(arr), this); } #endif // DEBUG - addToolBar(Qt::RightToolBarArea, pBar); + addToolBar(Qt::RightToolBarArea, pToolBar); } -//void MainWindow::CreateFindTable(QLayout * pLayout) -//{ -// // find widget -// FindEditorWnd * pEditor = new FindEditorWnd(0); -// pLayout->addWidget(pEditor); -// -// // find table result -// m_pFindTable = new FindTableWnd(0, pEditor, m_pDrawWidget->GetModel()); -// pLayout->addWidget(m_pFindTable); -// connect(m_pFindTable, SIGNAL(cellClicked(int, int)), this, SLOT(OnFeatureClicked(int, int))); -// connect(m_pFindTable, SIGNAL(cellEntered(int, int)), this, SLOT(OnFeatureEntered(int, int))); -//} -// -//void MainWindow::OnFeatureEntered(int /*row*/, int /*col*/) -//{ -// //Feature const & p = m_pFindTable->GetFeature(row); -// -// /// @todo highlight the feature -//} -// -//void MainWindow::OnFeatureClicked(int row, int /*col*/) -//{ -// Feature const & p = m_pFindTable->GetFeature(row); -// m_pDrawWidget->ShowFeature(p); -//} void MainWindow::OnAbout() { AboutDialog dlg(this); @@ -310,26 +294,59 @@ void MainWindow::OnAbout() void MainWindow::OnLocationFound() { - m_pMyPosition->setIcon(QIcon(":/navig64/location.png")); - m_pMyPosition->setToolTip(tr("My Position")); + m_pMyPositionAction->setIcon(QIcon(":/navig64/location.png")); + m_pMyPositionAction->setToolTip(tr("My Position")); } void MainWindow::OnMyPosition() { - if (m_pMyPosition->isChecked()) + if (m_pMyPositionAction->isChecked()) { - m_pMyPosition->setIcon(QIcon(":/navig64/location-search.png")); - m_pMyPosition->setToolTip(tr("Looking for position...")); + m_pMyPositionAction->setIcon(QIcon(":/navig64/location-search.png")); + m_pMyPositionAction->setToolTip(tr("Looking for position...")); m_pDrawWidget->OnEnableMyPosition(boost::bind(&MainWindow::OnLocationFound, this)); } else { - m_pMyPosition->setIcon(QIcon(":/navig64/location.png")); - m_pMyPosition->setToolTip(tr("My Position")); + m_pMyPositionAction->setIcon(QIcon(":/navig64/location.png")); + m_pMyPositionAction->setToolTip(tr("My Position")); m_pDrawWidget->OnDisableMyPosition(); } } +void MainWindow::OnSearchButtonClicked() +{ + if (m_pSearchAction->isChecked()) + { + m_Docks[2]->show(); + m_Docks[2]->widget()->setFocus(); + } + else + { + m_Docks[2]->hide(); + } +} + +void MainWindow::OnSearchShortcutPressed() +{ + if (m_Docks[2]->isVisible()) + { + m_pSearchAction->setChecked(false); + m_Docks[2]->hide(); + } + else + { + m_pSearchAction->setChecked(true); + m_Docks[2]->show(); + m_Docks[2]->widget()->setFocus(); + } +} + +void MainWindow::OnSearchTextChanged(QString const & str) +{ + +} + void MainWindow::OnPreferences() { bool autoUpdatesEnabled = DEFAULT_AUTO_UPDATES_ENABLED; @@ -361,7 +378,7 @@ void MainWindow::ShowGuidePanel() void MainWindow::CreateClassifPanel() { - CreatePanelImpl(0, tr("Classificator Bar"), + CreatePanelImpl(0, Qt::LeftDockWidgetArea, tr("Classificator Bar"), QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), SLOT(ShowClassifPanel())); ClassifTreeHolder * pCTree = new ClassifTreeHolder(m_Docks[0], m_pDrawWidget, SLOT(Repaint())); @@ -372,20 +389,34 @@ void MainWindow::CreateClassifPanel() void MainWindow::CreateGuidePanel() { - CreatePanelImpl(1, tr("Guide Bar"), + CreatePanelImpl(1, Qt::LeftDockWidgetArea, tr("Guide Bar"), QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G), SLOT(ShowGuidePanel())); qt::GuidePageHolder * pGPage = new qt::GuidePageHolder(m_Docks[1]); m_Docks[1]->setWidget(pGPage); } +#endif // DEBUG -void MainWindow::CreatePanelImpl(size_t i, QString const & name, +void MainWindow::CreateSearchBar() +{ + CreatePanelImpl(2, Qt::TopDockWidgetArea, tr("Search Bar"), + QKeySequence(Qt::CTRL + Qt::Key_F), SLOT(OnSearchShortcutPressed())); + + QLineEdit * editor = new QLineEdit(m_Docks[2]); + connect(editor, SIGNAL(textChanged(QString const &)), this, SLOT(OnSearchTextChanged(QString const &))); + + m_Docks[2]->setFeatures(QDockWidget::NoDockWidgetFeatures); + // @TODO remove search bar title + m_Docks[2]->setWidget(editor); +} + +void MainWindow::CreatePanelImpl(size_t i, Qt::DockWidgetArea area, QString const & name, QKeySequence const & hotkey, char const * slot) { m_Docks[i] = new QDockWidget(name, this); - addDockWidget(Qt::LeftDockWidgetArea, m_Docks[i]); + addDockWidget(area, m_Docks[i]); // hide by default m_Docks[i]->hide(); @@ -396,5 +427,5 @@ void MainWindow::CreatePanelImpl(size_t i, QString const & name, connect(pAct, SIGNAL(triggered()), this, slot); addAction(pAct); } -#endif // DEBUG + } diff --git a/qt/mainwindow.hpp b/qt/mainwindow.hpp index f4afd9e2f4..f9b7aa43f3 100644 --- a/qt/mainwindow.hpp +++ b/qt/mainwindow.hpp @@ -8,18 +8,18 @@ class QDockWidget; namespace qt { - class FindTableWnd; class DrawWidget; class UpdateDialog; class MainWindow : public QMainWindow { - QAction * m_pMyPosition; + QAction * m_pMyPositionAction; + QAction * m_pSearchAction; DrawWidget * m_pDrawWidget; + QDockWidget * m_Docks[3]; + #ifdef DEBUG // code removed for desktop releases - QDockWidget * m_Docks[2]; - //FindTableWnd * m_pFindTable; UpdateDialog * m_updateDialog; #endif // DEBUG @@ -41,14 +41,14 @@ namespace qt protected: #ifdef DEBUG // code removed for desktop releases - void CreatePanelImpl(size_t i, QString const & name, QKeySequence const & hotkey, - char const * slot); + void CreatePanelImpl(size_t i, Qt::DockWidgetArea area, QString const & name, + QKeySequence const & hotkey, char const * slot); void CreateClassifPanel(); void CreateGuidePanel(); #endif // DEBUG void CreateNavigationBar(); - //void CreateFindTable(QLayout * pLayout); + void CreateSearchBar(); #if defined(Q_WS_WIN) /// to handle menu messages @@ -56,8 +56,7 @@ namespace qt #endif protected Q_SLOTS: - //void OnFeatureEntered(int row, int col); - //void OnFeatureClicked(int row, int col); + void OnSearchTextChanged(QString const &); #ifdef DEBUG // code removed for desktop releases void ShowUpdateDialog(); void ShowClassifPanel(); @@ -66,5 +65,7 @@ namespace qt void OnPreferences(); void OnAbout(); void OnMyPosition(); + void OnSearchButtonClicked(); + void OnSearchShortcutPressed(); }; } diff --git a/qt/res/resources.qrc b/qt/res/resources.qrc index e2a2bc8797..0d31f65562 100644 --- a/qt/res/resources.qrc +++ b/qt/res/resources.qrc @@ -6,6 +6,7 @@ clear.png + search.png up.png down.png left.png diff --git a/qt/res/search.png b/qt/res/search.png new file mode 100644 index 0000000000000000000000000000000000000000..008823301d8f30ff9c3a23bf6588256c91e4cfc9 GIT binary patch literal 7039 zcmV-_8-V1AP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#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