Added text label for empty panels
authorKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Mon, 6 Sep 2010 11:23:32 +0000 (14:23 +0300)
committerKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Mon, 6 Sep 2010 11:23:32 +0000 (14:23 +0300)
Reviewed by Sami Rämö

src/ui/friendlistpanel.cpp
src/ui/friendlistpanel.h
src/ui/locationsearchpanel.cpp
src/ui/locationsearchpanel.h
src/ui/routingpanel.cpp
src/ui/routingpanel.h

index 99a2585..316638e 100644 (file)
@@ -114,6 +114,15 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     friendListPanelLayout->setSpacing(0);
     setLayout(friendListPanelLayout);
 
+    m_noFriendsLabel = new QLabel();
+    m_noFriendsLabel->setText("No Friends");
+    m_noFriendsLabel->setAlignment(Qt::AlignCenter);
+
+    QPalette noFriendsPalette = palette();
+    noFriendsPalette.setColor(QPalette::Foreground, Qt::white);
+    m_noFriendsLabel->setPalette(noFriendsPalette);
+
+    friendListPanelLayout->addWidget(m_noFriendsLabel, Qt::AlignCenter);
     friendListPanelLayout->addWidget(m_headerWidget);
     friendListPanelLayout->addLayout(listViewLayout);
     friendListPanelLayout->addLayout(footerLayout);
@@ -142,6 +151,8 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     m_itemButtonsLayout->addWidget(m_routeButton);
     m_itemButtonsLayout->addWidget(m_showContactButton);
     m_genericButtonsLayout->addWidget(m_clearGroupFilteringButton);
+
+    showEmptyPanel(true);
 }
 
 void FriendListPanel::anyPanelClosed()
@@ -209,6 +220,9 @@ void FriendListPanel::friendInfoReceived(QList<User *> &friendList)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    if (!friendList.isEmpty())
+           showEmptyPanel(false);
+
     QStringList newUserIDs;
 
     foreach (User *user, friendList) {
@@ -231,6 +245,7 @@ void FriendListPanel::friendInfoReceived(QList<User *> &friendList)
     }
 
     m_friendListView->clearUnused(newUserIDs);
+    m_friendListView->show();
 }
 
 void FriendListPanel::hideEvent(QHideEvent *event)
@@ -297,6 +312,17 @@ void FriendListPanel::showEvent(QShowEvent *event)
     setFilteringLayoutVisibility(false);
 }
 
+void FriendListPanel::showEmptyPanel(bool show)
+{
+    if (show){
+        m_noFriendsLabel->show();
+        m_friendListView->hide();
+    }
+    else {
+        m_noFriendsLabel->hide();
+    }
+}
+
 void FriendListPanel::showFriendsInList(const QList<QString> &userIDs)
 {
     qDebug() << __PRETTY_FUNCTION__;
index 43362a1..0f16ea1 100644 (file)
@@ -174,6 +174,13 @@ private slots:
     void routeToSelectedFriend();
 
     /**
+     * @brief show / hide empty panel label
+     *
+     * @param show true if empty panel should be shown
+     */
+    void showEmptyPanel(bool show);
+
+    /**
      * @brief Slot to show friends in list.
      *
      * Shows only friends that are on userIDs list
@@ -223,6 +230,7 @@ private:
     bool m_somePanelIsOpen;                     ///< Is any panel tab open
 
     QLabel *m_headerLabel;                      ///< Show how many friends are selected
+    QLabel *m_noFriendsLabel;                   ///< Text label for empty panel
 
     QLineEdit *m_filterField;                   ///< Text field for the filter text
 
index 63449a0..25f5399 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()
@@ -233,6 +242,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__;
@@ -249,6 +269,7 @@ void LocationSearchPanel::showLocationListView(int locationItemsCount)
     setHeaderText(locationItemsCount);
     m_clearLocationListButton->setEnabled(true);
     m_locationListView->show();
+    showEmptyPanel(false);
 }
 
 void LocationSearchPanel::showSearchHistoryListView()
@@ -260,4 +281,5 @@ void LocationSearchPanel::showSearchHistoryListView()
     m_resultsLabel->setText(tr("Search history:"));
     m_clearLocationListButton->setDisabled(true);
     m_searchHistoryListView->show();
+    showEmptyPanel(false);
 }
index e939db7..4002090 100644 (file)
@@ -107,6 +107,13 @@ private slots:
     void clearListsSelections();
 
     /**
+     * @brief show / hide empty panel label
+     *
+     * @param show true if empty panel should be shown
+     */
+    void showEmptyPanel(bool show);
+
+    /**
     * @brief Shows location list view.
     *
     * @param locationItemsCount location items count
@@ -174,6 +181,7 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
+    QLabel *m_noSearchLabel;                        ///< Text label for empty panel
     QLabel *m_resultsLabel;                         ///< Location list label
 
     ImageButton *m_clearLocationListButton;         ///< Clear location list button
index 55b711f..6380de2 100644 (file)
@@ -50,7 +50,17 @@ RoutingPanel::RoutingPanel(QWidget *parent)
     panelLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
                                     PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
 
+    m_noRouteLabel = new QLabel();
+    m_noRouteLabel->setText("No Route");
+    m_noRouteLabel->setAlignment(Qt::AlignCenter);
+
+    QPalette noRoutePalette = palette();
+    noRoutePalette.setColor(QPalette::Foreground, Qt::white);
+    m_noRouteLabel->setPalette(noRoutePalette);
+
     panelLayout->addWidget(m_routeWaypointListView);
+    panelLayout->addWidget(m_noRouteLabel, Qt::AlignCenter);
+    m_routeWaypointListView->hide();
     setLayout(panelLayout);
 
     // --- CONTEXT BUTTONS ---
@@ -82,6 +92,8 @@ void RoutingPanel::clearRouteButtonClicked()
 
     m_clearRouteButton->setDisabled(true);
     m_routeWaypointListView->clearList();
+    m_routeWaypointListView->hide();
+    m_noRouteLabel->show();
     emit clearRoute();
 }
 
@@ -99,6 +111,7 @@ void RoutingPanel::setRoute(Route &route)
     qDebug() << __PRETTY_FUNCTION__;
 
     m_routeWaypointListView->clearList();
+    m_noRouteLabel->hide();
 
     QList<RouteSegment> segments = route.segments();
     QList<GeoCoordinate> geometryPoints = route.geometryPoints();
@@ -110,6 +123,7 @@ void RoutingPanel::setRoute(Route &route)
                                    geometryPoints.at(routeSegment.positionIndex()));
 
         m_routeWaypointListView->addListItem(QString::number(i), item);
+        m_routeWaypointListView->show();
     }
 
     m_routeWaypointListView->scrollToTop();
index 2418f4c..5d773d2 100644 (file)
@@ -119,6 +119,7 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
+    QLabel *m_noRouteLabel;                             ///< Text label for empty panel
     QLabel *m_resultsLabel;                             ///< Location list label
 
     ImageButton *m_clearRouteButton;                    ///< Search location button