Merge branch 'master' of https://vcs.maemo.org/git/situare
[situare] / src / ui / locationsearchpanel.cpp
index 533da07..a1c66e7 100644 (file)
@@ -92,8 +92,16 @@ LocationSearchPanel::LocationSearchPanel(QWidget *parent)
     const int MARGIN_LEFT = 0;
     panelLayout->setContentsMargins(MARGIN_LEFT, PANEL_MARGIN_TOP,
                                     PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
+    m_noSearchLabel = new QLabel();
+    m_noSearchLabel->setText("No Search Results");
+    m_noSearchLabel->setAlignment(Qt::AlignCenter);
+
+    QPalette m_noSearchPalette = palette();
+    m_noSearchPalette.setColor(QPalette::Foreground, Qt::white);
+    m_noSearchLabel->setPalette(m_noSearchPalette);
 
     panelLayout->addWidget(resultsHeaderWidget);
+    panelLayout->addWidget(m_noSearchLabel, Qt::AlignCenter);
     panelLayout->addLayout(resultsListViewLayout);
 
     // --- CONTEXT BUTTONS ---
@@ -121,6 +129,7 @@ LocationSearchPanel::LocationSearchPanel(QWidget *parent)
 
     readSettings();
     showSearchHistoryListView();
+    showEmptyPanel(true);
 }
 
 LocationSearchPanel::~LocationSearchPanel()
@@ -223,6 +232,17 @@ void LocationSearchPanel::routeToSelectedLocation()
         emit routeToLocation(item->coordinates());
 }
 
+void LocationSearchPanel::showEmptyPanel(bool show)
+{
+    if (show){
+        m_noSearchLabel->show();
+        m_searchHistoryListView->hide();
+    }
+    else {
+        m_noSearchLabel->hide();
+    }
+}
+
 void LocationSearchPanel::setHeaderText(int count)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -239,6 +259,7 @@ void LocationSearchPanel::showLocationListView(int locationItemsCount)
     setHeaderText(locationItemsCount);
     m_clearLocationListButton->setEnabled(true);
     m_locationListView->show();
+    showEmptyPanel(false);
 }
 
 void LocationSearchPanel::showSearchHistoryListView()
@@ -250,4 +271,5 @@ void LocationSearchPanel::showSearchHistoryListView()
     m_resultsLabel->setText(tr("Search history:"));
     m_clearLocationListButton->setDisabled(true);
     m_searchHistoryListView->show();
+    showEmptyPanel(false);
 }