Re-factoring
authorSami Rämö <sami.ramo@ixonos.com>
Thu, 2 Sep 2010 11:38:42 +0000 (14:38 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Thu, 2 Sep 2010 11:38:42 +0000 (14:38 +0300)
 - 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
src/ui/listitemcontextbuttonbar.cpp [new file with mode: 0644]
src/ui/listitemcontextbuttonbar.h [new file with mode: 0644]
src/ui/panelbase.cpp
src/ui/panelbase.h
src/ui/panelcommon.h
src/ui/tabbedpanel.cpp
src/ui/tabbedpanel.h

index 1cf0da4..e47c648 100644 (file)
@@ -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 (file)
index 0000000..b4e4038
--- /dev/null
@@ -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 <QDebug>
+
+#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 (file)
index 0000000..910729f
--- /dev/null
@@ -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 <QWidget>
+
+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
index 08cfa51..f825aa7 100644 (file)
@@ -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);
 }
index 3da0f62..a1a1bd6 100644 (file)
@@ -63,6 +63,8 @@ public:
      */
     QWidget* genericPanelButtons() const;
 
+    QWidget* itemButtons() const;
+
 protected slots:
     void onListItemSelectionChanged();
 
index d721628..c3fcd64 100644 (file)
@@ -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
 
index 13d1c08..52155d0 100644 (file)
@@ -29,6 +29,7 @@
 #include <QStackedWidget>
 #include <QStateMachine>
 
+#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<PanelBase *>(m_panelContentStack->widget(index))->genericPanelButtons());
 
+        QWidget *itemContextButtons = static_cast<PanelBase *>(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);
     }
 }
index 12fefa9..95c46ff 100644 (file)
@@ -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