From fb4a8a977fbd366a419813f3b1cebae01a9a2a09 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sami=20R=C3=A4m=C3=B6?= Date: Thu, 2 Sep 2010 14:38:42 +0300 Subject: [PATCH] Re-factoring - Created ListItemContextButtonBar class - Moved handling of the list item context buttons into TabbedPanel class, same way as the generic panel context buttons are handled. - Positioning, sizing and updating of the buttons widget are broken --- src/src.pro | 6 +++-- src/ui/listitemcontextbuttonbar.cpp | 49 ++++++++++++++++++++++++++++++++++ src/ui/listitemcontextbuttonbar.h | 50 +++++++++++++++++++++++++++++++++++ src/ui/panelbase.cpp | 13 ++++++--- src/ui/panelbase.h | 2 ++ src/ui/panelcommon.h | 2 +- src/ui/tabbedpanel.cpp | 18 +++++++++++-- src/ui/tabbedpanel.h | 2 ++ 8 files changed, 134 insertions(+), 8 deletions(-) create mode 100644 src/ui/listitemcontextbuttonbar.cpp create mode 100644 src/ui/listitemcontextbuttonbar.h diff --git a/src/src.pro b/src/src.pro index 1cf0da4..e47c648 100644 --- a/src/src.pro +++ b/src/src.pro @@ -82,7 +82,8 @@ SOURCES += main.cpp \ ui/routewaypointlistview.cpp \ user/user.cpp \ ui/locationsearchpanel.cpp \ - ui/textmodifier.cpp + ui/textmodifier.cpp \ + ui/listitemcontextbuttonbar.cpp HEADERS += application.h \ common.h \ coordinates/geocoordinate.h \ @@ -166,7 +167,8 @@ HEADERS += application.h \ ui/routewaypointlistview.h \ user/user.h \ ui/locationsearchpanel.h \ - ui/textmodifier.h + ui/textmodifier.h \ + ui/listitemcontextbuttonbar.h QT += network \ webkit DEFINES += QT_NO_DEBUG_OUTPUT diff --git a/src/ui/listitemcontextbuttonbar.cpp b/src/ui/listitemcontextbuttonbar.cpp new file mode 100644 index 0000000..b4e4038 --- /dev/null +++ b/src/ui/listitemcontextbuttonbar.cpp @@ -0,0 +1,49 @@ +/* + Situare - A location system for Facebook + Copyright (C) 2010 Ixonos Plc. Authors: + + 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 + version 2 as published by the Free Software Foundation. + + Situare is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Situare; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. +*/ + +#include + +#include "listitemcontextbuttonbar.h" + +ListItemContextButtonBar::ListItemContextButtonBar(QWidget *parent) : + QWidget(parent), + m_contextButtons(0) +{ + qDebug() << __PRETTY_FUNCTION__; +} + +void ListItemContextButtonBar::setContextButtons(QWidget *contextButtons) +{ + qDebug() << __PRETTY_FUNCTION__; + + // Hide previous buttons (if any) + if (m_contextButtons) + m_contextButtons->setParent(0); + + m_contextButtons = contextButtons; + + m_contextButtons->setParent(this); +// m_contextButtons->setVisible(true); + +// setFixedHeight(m_contextButtons->height()); + +// emit positionChangeRequested(); +} diff --git a/src/ui/listitemcontextbuttonbar.h b/src/ui/listitemcontextbuttonbar.h new file mode 100644 index 0000000..910729f --- /dev/null +++ b/src/ui/listitemcontextbuttonbar.h @@ -0,0 +1,50 @@ +/* + Situare - A location system for Facebook + Copyright (C) 2010 Ixonos Plc. Authors: + + 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 + version 2 as published by the Free Software Foundation. + + Situare is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Situare; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. +*/ + + +#ifndef LISTITEMCONTEXTBUTTONBAR_H +#define LISTITEMCONTEXTBUTTONBAR_H + +#include + +class ListItemContextButtonBar : public QWidget +{ + Q_OBJECT +public: + explicit ListItemContextButtonBar(QWidget *parent = 0); + + /** + * @brief Sets the context buttons to the context button bar + * + * @param contextButtons Pointer to context buttons + */ + void setContextButtons(QWidget *contextButtons); + +signals: + +public slots: + +private: + QWidget *m_contextButtons; ///< Widget for context buttons + +}; + +#endif // LISTITEMCONTEXTBUTTONBAR_H diff --git a/src/ui/panelbase.cpp b/src/ui/panelbase.cpp index 08cfa51..f825aa7 100644 --- a/src/ui/panelbase.cpp +++ b/src/ui/panelbase.cpp @@ -65,6 +65,13 @@ QWidget* PanelBase::genericPanelButtons() const return m_genericButtons; } +QWidget* PanelBase::itemButtons() const +{ + qDebug() << __PRETTY_FUNCTION__; + + return m_itemButtons; +} + void PanelBase::onListItemSelectionChanged() { qDebug() << __PRETTY_FUNCTION__; @@ -80,7 +87,7 @@ void PanelBase::resizeEvent(QResizeEvent *event) { qDebug() << __PRETTY_FUNCTION__; - int x = event->size().width() / 2 - m_itemButtons->width() / 2; - const int Y = 0; - m_itemButtons->move(x, Y); +// 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 3da0f62..a1a1bd6 100644 --- a/src/ui/panelbase.h +++ b/src/ui/panelbase.h @@ -63,6 +63,8 @@ public: */ QWidget* genericPanelButtons() const; + QWidget* itemButtons() const; + protected slots: void onListItemSelectionChanged(); diff --git a/src/ui/panelcommon.h b/src/ui/panelcommon.h index d721628..c3fcd64 100644 --- a/src/ui/panelcommon.h +++ b/src/ui/panelcommon.h @@ -41,7 +41,7 @@ const int PANEL_BOTTOM_PADDING = 0; ///< Amount of padding in bottom of panels const int PANEL_BAR_WIDTH = 5; ///< Width of the slider bar const int PANEL_TAB_BAR_WIDTH = 74; ///< Panel tab bar total width const int PANEL_BAR_TABBED_WIDTH = PANEL_BAR_WIDTH + PANEL_TAB_BAR_WIDTH; ///< Width of the tabbed bar -const int PANEL_WIDTH = 384; ///< Width of the panel +const int PANEL_WIDTH = 384; ///< Width of the panel contents area const int PANEL_HEIGHT = DEFAULT_SCREEN_HEIGHT - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING; ///< Height of the panel diff --git a/src/ui/tabbedpanel.cpp b/src/ui/tabbedpanel.cpp index 13d1c08..52155d0 100644 --- a/src/ui/tabbedpanel.cpp +++ b/src/ui/tabbedpanel.cpp @@ -29,6 +29,7 @@ #include #include +#include "listitemcontextbuttonbar.h" #include "panelbar.h" #include "panelbase.h" #include "panelcontentstack.h" @@ -73,7 +74,7 @@ TabbedPanel::TabbedPanel(QWidget *parent) m_panelBar = new PanelBar(this); m_panelBar->move(PANEL_TAB_BAR_WIDTH, PANEL_TOP_Y); - // --- CONTEXT BUTTON BAR --- + // --- GENERIC PANEL CONTEXT BUTTON BAR --- m_panelContextButtonBar = new PanelContextButtonBar(this); m_panelContextButtonBar->move(PANEL_CONTEXT_BUTTON_BAR_LEFT_X, PANEL_HEIGHT); @@ -83,9 +84,13 @@ TabbedPanel::TabbedPanel(QWidget *parent) connect(m_panelContextButtonBar, SIGNAL(positionChangeRequested()), this, SLOT(repositionContextButtonBar())); + // --- LIST ITEM RELATED CONTEXT BUTTONS BAR --- + m_itemContextButtonBar = new ListItemContextButtonBar(this); + // --- PANEL CONTENT --- m_panelContentStack = new PanelContentStack(this); m_panelContentStack->move(PANEL_TAB_BAR_WIDTH + PANEL_BAR_WIDTH, PANEL_TOP_Y); + m_panelContentStack->stackUnder(m_itemContextButtonBar); // --- PANEL ANIMATION --- QStateMachine *panelStateMachine = new QStateMachine(this); @@ -209,7 +214,7 @@ void TabbedPanel::repositionContextButtonBar() qDebug() << __PRETTY_FUNCTION__; m_panelContextButtonBar->move(PANEL_CONTEXT_BUTTON_BAR_LEFT_X, height()); - + calculateMask(); } @@ -254,6 +259,15 @@ void TabbedPanel::setCurrentIndex(int index) m_panelContextButtonBar->setContextButtons( static_cast(m_panelContentStack->widget(index))->genericPanelButtons()); + QWidget *itemContextButtons = static_cast(m_panelContentStack->widget(index))->itemButtons(); + m_itemContextButtonBar->setContextButtons(itemContextButtons); + + const int FROM_PANEL_CONTENTS_LEFT = PANEL_WIDTH / 2 - itemContextButtons->width() / 2; + const int Y = 0; + + m_itemContextButtonBar->move(PANEL_TAB_BAR_WIDTH + PANEL_BAR_WIDTH + + FROM_PANEL_CONTENTS_LEFT, Y); + emit currentChanged(index); } } diff --git a/src/ui/tabbedpanel.h b/src/ui/tabbedpanel.h index 12fefa9..95c46ff 100644 --- a/src/ui/tabbedpanel.h +++ b/src/ui/tabbedpanel.h @@ -32,6 +32,7 @@ class QSignalTransition; class QState; class QStateMachine; +class ListItemContextButtonBar; class PanelBar; class PanelContentStack; class PanelContextButtonBar; @@ -196,6 +197,7 @@ private: QState *m_stateClosed; ///< State of the closed panel QState *m_stateOpened; ///< State of the opened panel + ListItemContextButtonBar *m_itemContextButtonBar; PanelBar *m_panelBar; ///< Widget for panel bar PanelContentStack *m_panelContentStack; ///< Stack for panel widgets PanelContextButtonBar * m_panelContextButtonBar; ///< Widget for panel context button bar -- 1.7.9.5