Rough implementation of the item related buttons
authorSami Rämö <sami.ramo@ixonos.com>
Thu, 2 Sep 2010 09:55:12 +0000 (12:55 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Thu, 2 Sep 2010 09:55:12 +0000 (12:55 +0300)
 - Widget for item related context buttons into PanelBase class

 - Moved old item related buttons into the new widget

 - Widget positioning, showing and hiding. Stacking order is not
   correct, so the buttons are covered by the list item and updating
   is not done properly.

src/ui/friendlistpanel.cpp
src/ui/locationsearchpanel.cpp
src/ui/panelbase.cpp
src/ui/panelbase.h
src/ui/routingpanel.cpp
src/ui/tabbedpanel.cpp
src/ui/userinfopanel.cpp

index 3dfd9e5..5e461e5 100644 (file)
@@ -85,6 +85,9 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     connect(m_friendListView, SIGNAL(listItemSelectionChanged()),
             this, SLOT(setRouteButtonDisabled()));
 
+    connect(m_friendListView, SIGNAL(listItemSelectionChanged()),
+            this, SLOT(onListItemSelectionChanged()));
+
     // --- FOOTER, TEXT BASED FILTERING ---
     QHBoxLayout *footerLayout = new QHBoxLayout();
 
@@ -133,8 +136,8 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     connect(m_clearGroupFilteringButton, SIGNAL(clicked()),
             this, SLOT(clearFiltering()));
 
-    m_contextButtonLayout->addWidget(m_routeButton);
-    m_contextButtonLayout->addWidget(m_clearGroupFilteringButton);
+    m_itemButtonsLayout->addWidget(m_routeButton);
+    m_genericButtonsLayout->addWidget(m_clearGroupFilteringButton);
 }
 
 void FriendListPanel::anyPanelClosed()
index d42353c..b765744 100644 (file)
@@ -62,6 +62,9 @@ LocationSearchPanel::LocationSearchPanel(QWidget *parent)
     connect(m_locationListView, SIGNAL(listItemSelectionChanged()),
             this, SLOT(setRouteButtonDisabled()));
 
+    connect(m_locationListView, SIGNAL(listItemSelectionChanged()),
+            this, SLOT(onListItemSelectionChanged()));
+
     QVBoxLayout *resultsListViewLayout = new QVBoxLayout;
     resultsListViewLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
                                        PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
@@ -90,8 +93,8 @@ LocationSearchPanel::LocationSearchPanel(QWidget *parent)
     connect(searchLocationButton, SIGNAL(clicked()),
             this, SIGNAL(requestSearchLocation()));
 
-    m_contextButtonLayout->addWidget(m_routeButton);
-    m_contextButtonLayout->addWidget(searchLocationButton);
+    m_itemButtonsLayout->addWidget(m_routeButton);
+    m_genericButtonsLayout->addWidget(searchLocationButton);
 }
 
 void LocationSearchPanel::clearListsSelections()
index a0ebc33..08cfa51 100644 (file)
@@ -3,6 +3,7 @@
     Copyright (C) 2010  Ixonos Plc. Authors:
 
         Pekka Nissinen - pekka.nissinen@ixonos.com
+        Sami Rämö - sami.ramo@ixonos.com
 
     Situare is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
@@ -20,6 +21,8 @@
 */
 
 #include <QDebug>
+#include <QListWidget>
+#include <QResizeEvent>
 #include <QVBoxLayout>
 
 #include "panelbase.h"
@@ -35,21 +38,49 @@ PanelBase::PanelBase(QWidget *parent)
     const int CONTEXT_BUTTON_MARGIN_BOTTOM = 0;
     const int CONTEXT_BUTTON_SPACING = 0;
 
-    m_contextButtons = new QWidget;
+    // --- GENERIC BUTTONS ---
+    m_genericButtons = new QWidget;
 
-    m_contextButtonLayout = new QVBoxLayout;
-    m_contextButtonLayout->setContentsMargins(CONTEXT_BUTTON_MARGIN_LEFT,
+    m_genericButtonsLayout = new QVBoxLayout;
+    m_genericButtonsLayout->setContentsMargins(CONTEXT_BUTTON_MARGIN_LEFT,
                                               CONTEXT_BUTTON_MARGIN_TOP,
                                               CONTEXT_BUTTON_MARGIN_RIGHT,
                                               CONTEXT_BUTTON_MARGIN_BOTTOM);
-    m_contextButtonLayout->setSpacing(CONTEXT_BUTTON_SPACING);
+    m_genericButtonsLayout->setSpacing(CONTEXT_BUTTON_SPACING);
 
-    m_contextButtons->setLayout(m_contextButtonLayout);
+    m_genericButtons->setLayout(m_genericButtonsLayout);
+
+    // --- ITEM RELATED BUTTONS ---
+    m_itemButtons = new QWidget(this);
+    m_itemButtonsLayout = new QHBoxLayout;
+    /// @todo set margins
+    m_itemButtons->setLayout(m_itemButtonsLayout);
+    m_itemButtons->hide();
+}
+
+QWidget* PanelBase::genericPanelButtons() const
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_genericButtons;
+}
+
+void PanelBase::onListItemSelectionChanged()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    QListWidget *listWidget = dynamic_cast<QListWidget *>(sender());
+    if (listWidget && (listWidget->selectedItems().count() > 0))
+        m_itemButtons->show();
+    else
+        m_itemButtons->hide();
 }
 
-QWidget* PanelBase::contextButtons() const
+void PanelBase::resizeEvent(QResizeEvent *event)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    return m_contextButtons;
+    int x =  event->size().width() / 2 - m_itemButtons->width() / 2;
+    const int Y = 0;
+    m_itemButtons->move(x, Y);
 }
index 6f4dd0a..3da0f62 100644 (file)
@@ -3,6 +3,7 @@
     Copyright (C) 2010  Ixonos Plc. Authors:
 
         Pekka Nissinen - pekka.nissinen@ixonos.com
+        Sami Rämö - sami.ramo@ixonos.com
 
     Situare is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
@@ -24,6 +25,8 @@
 
 #include <QWidget>
 
+class QHBoxLayout;
+class QListWidgetItem;
 class QVBoxLayout;
 
 class ImageButton;
@@ -32,6 +35,7 @@ class ImageButton;
  * @brief Base class for panels
  *
  * @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
+ * @author Sami Rämö - sami.ramo (at) ixonos.com
  */
 class PanelBase : public QWidget
 {
@@ -45,16 +49,22 @@ public:
      */
     PanelBase(QWidget *parent = 0);
 
+protected:
+    void resizeEvent(QResizeEvent *event);
+
 /*******************************************************************************
  * MEMBER FUNCTIONS AND SLOTS
  ******************************************************************************/
 public:
     /**
-     * @brief Getter for the context buttons
+     * @brief Getter for the generic panel related context buttons
      *
      * @returns Pointer to context buttons widget
      */
-    QWidget* contextButtons() const;
+    QWidget* genericPanelButtons() const;
+
+protected slots:
+    void onListItemSelectionChanged();
 
 /*******************************************************************************
  * SIGNALS
@@ -71,9 +81,11 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 protected:
-    QVBoxLayout *m_contextButtonLayout; ///< Layout for context buttons
+    QVBoxLayout *m_genericButtonsLayout;    ///< Layout for generic context buttons
+    QHBoxLayout *m_itemButtonsLayout;       ///< Layout for item related context buttons
 
 private:
-    QWidget *m_contextButtons;          ///< Widget for context buttons
+    QWidget *m_genericButtons;              ///< Widget for generic context buttons
+    QWidget *m_itemButtons;                 ///< Widget for item related context buttons
 };
 #endif // PANELBASE_H
index 45998f4..55b711f 100644 (file)
@@ -43,6 +43,9 @@ RoutingPanel::RoutingPanel(QWidget *parent)
     connect(m_routeWaypointListView, SIGNAL(routeWaypointItemClicked(GeoCoordinate)),
             this, SIGNAL(routeWaypointItemClicked(GeoCoordinate)));
 
+    connect(m_routeWaypointListView, SIGNAL(listItemSelectionChanged()),
+            this, SLOT(onListItemSelectionChanged()));
+
     QVBoxLayout *panelLayout = new QVBoxLayout;
     panelLayout->setContentsMargins(PANEL_MARGIN_LEFT, PANEL_MARGIN_TOP,
                                     PANEL_MARGIN_RIGHT, PANEL_MARGIN_BOTTOM);
@@ -62,8 +65,8 @@ RoutingPanel::RoutingPanel(QWidget *parent)
             this, SLOT(clearRouteButtonClicked()));
     m_clearRouteButton->setDisabled(true);
 
-    m_contextButtonLayout->addWidget(routeToCursorButton);
-    m_contextButtonLayout->addWidget(m_clearRouteButton);
+    m_genericButtonsLayout->addWidget(routeToCursorButton);
+    m_genericButtonsLayout->addWidget(m_clearRouteButton);
 }
 
 void RoutingPanel::clearListsSelections()
index af58c61..13d1c08 100644 (file)
@@ -252,7 +252,7 @@ void TabbedPanel::setCurrentIndex(int index)
             openPanel();
 
         m_panelContextButtonBar->setContextButtons(
-                static_cast<PanelBase *>(m_panelContentStack->widget(index))->contextButtons());
+                static_cast<PanelBase *>(m_panelContentStack->widget(index))->genericPanelButtons());
 
         emit currentChanged(index);
     }
index 2c48092..c71defc 100644 (file)
@@ -89,8 +89,8 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
                                                              ":/res/images/send_position_s.png",
                                                              "", this);
 
-    m_contextButtonLayout->addWidget(updateFriendsButton);
-    m_contextButtonLayout->addWidget(updateStatusMessageButton);
+    m_genericButtonsLayout->addWidget(updateFriendsButton);
+    m_genericButtonsLayout->addWidget(updateStatusMessageButton);
 
     connect(updateFriendsButton, SIGNAL(clicked()),
             this, SIGNAL(refreshUserData()));