From 45cde4dd3136f1490a7ffba61c226fb3e13f92d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sami=20R=C3=A4m=C3=B6?= Date: Thu, 2 Sep 2010 12:55:12 +0300 Subject: [PATCH] Rough implementation of the item related buttons - 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 | 7 +++++-- src/ui/locationsearchpanel.cpp | 7 +++++-- src/ui/panelbase.cpp | 45 +++++++++++++++++++++++++++++++++------- src/ui/panelbase.h | 20 ++++++++++++++---- src/ui/routingpanel.cpp | 7 +++++-- src/ui/tabbedpanel.cpp | 2 +- src/ui/userinfopanel.cpp | 4 ++-- 7 files changed, 72 insertions(+), 20 deletions(-) diff --git a/src/ui/friendlistpanel.cpp b/src/ui/friendlistpanel.cpp index 3dfd9e5..5e461e5 100644 --- a/src/ui/friendlistpanel.cpp +++ b/src/ui/friendlistpanel.cpp @@ -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() diff --git a/src/ui/locationsearchpanel.cpp b/src/ui/locationsearchpanel.cpp index d42353c..b765744 100644 --- a/src/ui/locationsearchpanel.cpp +++ b/src/ui/locationsearchpanel.cpp @@ -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() diff --git a/src/ui/panelbase.cpp b/src/ui/panelbase.cpp index a0ebc33..08cfa51 100644 --- a/src/ui/panelbase.cpp +++ b/src/ui/panelbase.cpp @@ -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 +#include +#include #include #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(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); } diff --git a/src/ui/panelbase.h b/src/ui/panelbase.h index 6f4dd0a..3da0f62 100644 --- a/src/ui/panelbase.h +++ b/src/ui/panelbase.h @@ -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 +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 diff --git a/src/ui/routingpanel.cpp b/src/ui/routingpanel.cpp index 45998f4..55b711f 100644 --- a/src/ui/routingpanel.cpp +++ b/src/ui/routingpanel.cpp @@ -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() diff --git a/src/ui/tabbedpanel.cpp b/src/ui/tabbedpanel.cpp index af58c61..13d1c08 100644 --- a/src/ui/tabbedpanel.cpp +++ b/src/ui/tabbedpanel.cpp @@ -252,7 +252,7 @@ void TabbedPanel::setCurrentIndex(int index) openPanel(); m_panelContextButtonBar->setContextButtons( - static_cast(m_panelContentStack->widget(index))->contextButtons()); + static_cast(m_panelContentStack->widget(index))->genericPanelButtons()); emit currentChanged(index); } diff --git a/src/ui/userinfopanel.cpp b/src/ui/userinfopanel.cpp index 2c48092..c71defc 100644 --- a/src/ui/userinfopanel.cpp +++ b/src/ui/userinfopanel.cpp @@ -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())); -- 1.7.9.5