It is now using a specialised QWidget that contains the buttons in a grid layout. Also made the required changes to
the RoutingPanel and UserInfoPanel classes.
connect(this, SIGNAL(locationDataParsed(const QList<Location>&)),
m_routingPanel, SLOT(populateLocationListView(const QList<Location>&)));
- connect(m_routingPanel,
- SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
- this,
- SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
+ connect(m_routingPanel, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)),
+ this, SIGNAL(locationItemClicked(const GeoCoordinate&, const GeoCoordinate&)));
connect(m_routingPanel, SIGNAL(routeToLocation(const GeoCoordinate&)),
this, SIGNAL(routeTo(const GeoCoordinate&)));
: QWidget(parent)
{
qDebug() << __PRETTY_FUNCTION__;
+
+ const int CONTEXT_BUTTON_MARGIN_LEFT = 2;
+ const int CONTEXT_BUTTON_MARGIN_TOP = 10;
+ const int CONTEXT_BUTTON_MARGIN_RIGHT = 0;
+ const int CONTEXT_BUTTON_MARGIN_BOTTOM = 0;
+ const int CONTEXT_BUTTON_SPACING = 0;
+
+ m_contextButtons = new QWidget;
+
+ m_contextButtonLayout = new QGridLayout;
+ m_contextButtonLayout->setContentsMargins(CONTEXT_BUTTON_MARGIN_LEFT,
+ CONTEXT_BUTTON_MARGIN_TOP,
+ CONTEXT_BUTTON_MARGIN_RIGHT,
+ CONTEXT_BUTTON_MARGIN_BOTTOM);
+ m_contextButtonLayout->setSpacing(CONTEXT_BUTTON_SPACING);
+
+ m_contextButtons->setLayout(m_contextButtonLayout);
}
-const QList<ImageButton *>& PanelBase::contextButtons() const
+QWidget* PanelBase::contextButtons() const
{
qDebug() << __PRETTY_FUNCTION__;
- return m_contextButtonList;
+ return m_contextButtons;
}
#ifndef PANELBASE_H
#define PANELBASE_H
+#include <QGridLayout>
#include <QWidget>
class ImageButton;
******************************************************************************/
public:
/**
- * @brief Get list of context buttons
+ * @brief Getter for the context buttons
*
- * @returns Reference to list of context buttons
+ * @returns Pointer to context buttons widget
*/
- const QList<ImageButton *>& contextButtons() const;
+ QWidget* contextButtons() const;
/*******************************************************************************
* SIGNALS
* DATA MEMBERS
******************************************************************************/
protected:
- QList<ImageButton *> m_contextButtonList; ///< List of context buttons
+ QGridLayout *m_contextButtonLayout; ///< Layout for context buttons
+
+private:
+ QWidget *m_contextButtons; ///< Widget for context buttons
};
#endif // PANELBASE_H
#include <QDebug>
#include <QPainter>
-#include "imagebutton.h"
-
#include "panelcontextbuttonbar.h"
const int CONTEXT_BUTTON_BAR_WIDTH = 78;
PanelContextButtonBar::PanelContextButtonBar(QWidget *parent)
- : QWidget(parent)
+ : QWidget(parent),
+ m_contextButtons(0)
{
qDebug() << __PRETTY_FUNCTION__;
}
-void PanelContextButtonBar::setContextButtons(const QList<ImageButton *> &contextButtonList)
+void PanelContextButtonBar::setContextButtons(QWidget *contextButtons)
{
qDebug() << __PRETTY_FUNCTION__;
- const int CONTEXT_BUTTON_HEIGHT = 74;
- const int CONTEXT_BUTTON_MARGIN_LEFT = 2;
- const int CONTEXT_BUTTON_MARGIN_TOP = 10;
-
// Hide previous buttons (if any)
- for (int i = 0; i < m_contextButtonList.size(); i ++) {
- m_contextButtonList.at(i)->setParent(0);
- }
+ if (m_contextButtons)
+ m_contextButtons->setParent(0);
- m_contextButtonList = contextButtonList;
+ m_contextButtons = contextButtons;
- for (int i = 0; i < m_contextButtonList.size(); i ++) {
- m_contextButtonList.at(i)->setParent(this);
- m_contextButtonList.at(i)->setVisible(true);
- m_contextButtonList.at(i)->move(CONTEXT_BUTTON_MARGIN_LEFT,
- CONTEXT_BUTTON_MARGIN_TOP + (CONTEXT_BUTTON_HEIGHT * i));
- }
+ m_contextButtons->setParent(this);
+ m_contextButtons->setVisible(true);
- setFixedHeight(CONTEXT_BUTTON_MARGIN_TOP + (CONTEXT_BUTTON_HEIGHT * contextButtonList.size()));
+ setFixedHeight(m_contextButtons->height());
emit positionChangeRequested();
}
#include <QWidget>
-class ImageButton;
-
class PanelContextButtonBar : public QWidget
{
Q_OBJECT
/**
* @brief Sets the context buttons to the context button bar
*
- * @param contextButtonList List of context buttons
+ * @param contextButtons Pointer to context buttons
*/
- void setContextButtons(const QList<ImageButton *> &contextButtonList);
+ void setContextButtons(QWidget *contextButtons);
/*******************************************************************************
* SIGNALS
* DATA MEMBERS
******************************************************************************/
private:
- QList<ImageButton *> m_contextButtonList;
+ QPixmap m_barTile; ///< Pixmap for button bar
+ QPixmap m_barTop; ///< Pixmap for button bar top
- QPixmap m_barTile; ///< Pixmap for button bar
- QPixmap m_barTop; ///< Pixmap for button bar top
+ QRect m_barRect; ///< Rect for the button bar
- QRect m_barRect; ///< Rect for the button bar
+ QWidget *m_contextButtons; ///< Widget for context buttons
};
#endif // PANELCONTEXTBUTTONBAR_H
":/res/images/search_s.png",
"", this);
- m_contextButtonList.append(searchLocationButton);
+ m_contextButtonLayout->addWidget(searchLocationButton, 0, 0);
m_routeButton = new QPushButton(tr("Route to location"));
m_routeButton->setDisabled(true);
":/res/images/send_position_s.png",
"", this);
- m_contextButtonList.append(updateFriendsButton);
- m_contextButtonList.append(updateStatusMessageButton);
+ m_contextButtonLayout->addWidget(updateFriendsButton, 0, 0);
+ m_contextButtonLayout->addWidget(updateStatusMessageButton, 1, 0);
connect(updateFriendsButton, SIGNAL(clicked()),
this, SIGNAL(refreshUserData()));