Re-factored FriendListPanel constructor and data member names
authorSami Rämö <sami.ramo@ixonos.com>
Wed, 25 Aug 2010 12:21:47 +0000 (15:21 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Wed, 25 Aug 2010 12:41:11 +0000 (15:41 +0300)
 - Reviewed by Pekka Nissinen

src/ui/friendlistpanel.cpp
src/ui/friendlistpanel.h

index 92d656f..4b62e3f 100644 (file)
@@ -50,38 +50,27 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     const int FRIENDPANEL_FILTER_MARGIN_RIGHT = PANEL_MARGIN_RIGHT + MAEMO5_SCROLLBAR_WIDTH + 4;
     const int FRIENDPANEL_FILTER_MARGIN_BOTTOM = 0;
 
-    QVBoxLayout *friendListPanelLayout = new QVBoxLayout();
-    friendListPanelLayout->setMargin(0);
-    friendListPanelLayout->setSpacing(0);
-    setLayout(friendListPanelLayout);
-
-    QHBoxLayout *filterLayout = new QHBoxLayout();
-    filterLayout->setContentsMargins(FRIENDPANEL_FILTER_MARGIN_LEFT, FRIENDPANEL_FILTER_MARGIN_TOP,
-                                     FRIENDPANEL_FILTER_MARGIN_RIGHT, FRIENDPANEL_FILTER_MARGIN_BOTTOM);
+    // --- HEADER, HOW MANY FRIENDS ARE SELECTED ---
+    m_headerWidget = new QWidget();
 
-    m_friendListHeaderWidget = new QWidget();
-    m_friendListHeaderWidget->setLayout(filterLayout);
-    m_friendListHeaderWidget->setAutoFillBackground(true);
+    m_headerWidget->hide();
+    m_headerWidget->setAutoFillBackground(true);
 
-    m_routeButton = new ImageButton(":res/images/route_to_friend.png",
-                                    ":res/images/route_to_friend_s.png", "", this);
-    m_routeButton->setDisabled(true);
-
-    QPalette labelPalette = m_friendListHeaderWidget->palette();
-    labelPalette.setColor(QPalette::Background, Qt::black);
-
-    m_friendListHeaderWidget->setPalette(labelPalette);
-    m_friendListHeaderWidget->hide();
-    m_friendListLabel = new QLabel(this);
-    m_clearGroupFilteringButton = new ImageButton(":res/images/filtered.png",
-                                                  ":res/images/filtered_s.png", "", this);
+    QPalette headerPalette = m_headerWidget->palette();
+    headerPalette.setColor(QPalette::Background, Qt::black);
+    m_headerWidget->setPalette(headerPalette);
 
-    m_clearGroupFilteringButton->setCheckable(true);
-    m_clearGroupFilteringButton->setDisabled(true);
+    QHBoxLayout *headerLayout = new QHBoxLayout();
+    m_headerWidget->setLayout(headerLayout);
+    headerLayout->setContentsMargins(FRIENDPANEL_FILTER_MARGIN_LEFT,
+                                     FRIENDPANEL_FILTER_MARGIN_TOP,
+                                     FRIENDPANEL_FILTER_MARGIN_RIGHT,
+                                     FRIENDPANEL_FILTER_MARGIN_BOTTOM);
 
-    filterLayout->addWidget(m_friendListLabel);
-    filterLayout->addWidget(m_clearGroupFilteringButton);
+    m_headerLabel = new QLabel(this);
+    headerLayout->addWidget(m_headerLabel, 0, Qt::AlignCenter);
 
+    // --- FRIEND LIST ---
     m_friendListView = new FriendListView(this);
     m_friendListView->setItemDelegate(new FriendListItemDelegate(this));
 
@@ -90,35 +79,17 @@ FriendListPanel::FriendListPanel(QWidget *parent)
                                        PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
     listViewLayout->addWidget(m_friendListView);
 
-    friendListPanelLayout->addWidget(m_routeButton);
-    friendListPanelLayout->addWidget(m_friendListHeaderWidget);
-    friendListPanelLayout->addLayout(listViewLayout);
-
     connect(m_friendListView, SIGNAL(friendItemClicked(GeoCoordinate)),
             this, SIGNAL(findFriend(GeoCoordinate)));
 
-    connect(m_clearGroupFilteringButton, SIGNAL(clicked()),
-            this, SLOT(clearFiltering()));
-
-    connect(m_routeButton, SIGNAL(clicked()),
-            this, SLOT(routeToSelectedFriend()));
-
     connect(m_friendListView, SIGNAL(listItemSelectionChanged()),
             this, SLOT(setRouteButtonDisabled()));
 
-    /// @todo remove old filterLayout when new panel are merged
+    // --- FOOTER, TEXT BASED FILTERING ---
+    QHBoxLayout *footerLayout = new QHBoxLayout();
 
-    //////////////////////////////////////////////////////////////////////////
-    // NOTE! Do not mix the new filtering layout below with the old one above
-    //////////////////////////////////////////////////////////////////////////
-
-    // filtering layout
-    QHBoxLayout *filteringLayout = new QHBoxLayout();
-    friendListPanelLayout->addLayout(filteringLayout);
-
-    // line edit for filtering
     m_filterField = new QLineEdit;
-    filteringLayout->addWidget(m_filterField);
+    footerLayout->addWidget(m_filterField);
 
     connect(m_filterField, SIGNAL(returnPressed()),
             this, SLOT(clearTextFiltering()));
@@ -126,9 +97,8 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     connect(m_filterField, SIGNAL(textChanged(QString)),
             this, SLOT(filterTextChanged(QString)));
 
-    // button for clearing the filtering
     m_clearTextFilteringButton = new QPushButton();
-    filteringLayout->addWidget(m_clearTextFilteringButton);
+    footerLayout->addWidget(m_clearTextFilteringButton);
     m_clearTextFilteringButton->setIcon(QIcon::fromTheme(QLatin1String("general_close")));
 
     connect(m_clearTextFilteringButton, SIGNAL(clicked()),
@@ -137,7 +107,30 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     connect(qApp, SIGNAL(topmostWindowChanged(bool)),
             this, SLOT(topmostWindowChanged(bool)));
 
-    // CONTEXT BUTTONS
+    // --- MAIN LAYOUT ---
+    QVBoxLayout *friendListPanelLayout = new QVBoxLayout();
+    friendListPanelLayout->setMargin(0);
+    friendListPanelLayout->setSpacing(0);
+    setLayout(friendListPanelLayout);
+
+    friendListPanelLayout->addWidget(m_headerWidget);
+    friendListPanelLayout->addLayout(listViewLayout);
+    friendListPanelLayout->addLayout(footerLayout);
+
+    // --- CONTEXT BUTTONS ---
+    m_routeButton = new ImageButton(":res/images/route_to_friend.png",
+                                    ":res/images/route_to_friend_s.png", "", this);
+    m_routeButton->setDisabled(true);
+    connect(m_routeButton, SIGNAL(clicked()),
+            this, SLOT(routeToSelectedFriend()));
+
+    m_clearGroupFilteringButton = new ImageButton(":res/images/filtered.png",
+                                                  ":res/images/filtered_s.png", "", this);
+    m_clearGroupFilteringButton->setCheckable(true);
+    m_clearGroupFilteringButton->setDisabled(true);
+    connect(m_clearGroupFilteringButton, SIGNAL(clicked()),
+            this, SLOT(clearFiltering()));
+
     m_contextButtonLayout->addWidget(m_routeButton);
     m_contextButtonLayout->addWidget(m_clearGroupFilteringButton);
 }
@@ -167,7 +160,7 @@ void FriendListPanel::clearFiltering()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_friendListHeaderWidget->hide();
+    m_headerWidget->hide();
     m_clearGroupFilteringButton->setChecked(false);
     m_clearGroupFilteringButton->setDisabled(true);
     m_friendListView->clearFilter();
@@ -295,9 +288,9 @@ void FriendListPanel::showFriendsInList(const QList<QString> &userIDs)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_friendListLabel->setText(tr("Selected: %1").arg(userIDs.count()));
+    m_headerLabel->setText(tr("Selected: %1").arg(userIDs.count()));
 
-    m_friendListHeaderWidget->show();
+    m_headerWidget->show();
     m_clearGroupFilteringButton->setDisabled(false);
     m_clearGroupFilteringButton->setChecked(true);
     m_friendListView->filter(userIDs);
index ae1b26a..a781517 100644 (file)
@@ -217,17 +217,17 @@ private:
     bool m_mainWindowIsTopmost;                 ///< Is the MainWindow the topmost one
     bool m_somePanelIsOpen;                     ///< Is any panel tab open
 
-    QLabel *m_friendListLabel;                  ///< Friend list label
+    QLabel *m_headerLabel;                      ///< Show how many friends are selected
 
     QLineEdit *m_filterField;                   ///< Text field for the filter text
 
-    QPushButton *m_clearTextFilteringButton;    ///< Button for clearing the filtering
+    QPushButton *m_clearTextFilteringButton;    ///< Button for clearing the text filtering
 
-    QWidget *m_friendListHeaderWidget;          ///< Friend list header widget
+    QWidget *m_headerWidget;                    ///< Friend list header widget
 
     FriendListView *m_friendListView;           ///< Friend list view
     ImageButton *m_clearGroupFilteringButton;   ///< Button for clearing friend group filtering
-    ImageButton *m_routeButton;                 ///< Button to route to friend
+    ImageButton *m_routeButton;                 ///< Button for routing to selected friend
 };
 
 #endif // FRIENDLISTPANEL_H