#include "panelcommon.h"
-///< @todo requires clean-up, there is some commented code
-
PanelBar::PanelBar(QWidget *parent)
: QWidget(parent)
{
m_barTile.load(":/res/images/sliding_bar_tile.png");
m_menuDropShadowTile.load(":/res/images/menu_bar_drop_shadow.png");
-
+ ///< @todo magic
m_barRect.setRect(0, 0, PANEL_BAR_WIDTH, PANEL_HEIGHT);
this->resize(PANEL_BAR_WIDTH, PANEL_HEIGHT);
}
-void PanelBar::paintEvent(QPaintEvent *)
+void PanelBar::paintEvent(QPaintEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
+ Q_UNUSED(event);
+
QPainter painter(this);
painter.drawTiledPixmap(m_barRect, m_barTile);
#include <QWidget>
-///< @todo Comment does not tell what this class is actually for (=draws the vertical line between panel contents and tab buttons)
/**
- * @brief Generic class for panel bars
+ * @brief Class for for drawing a vertical line between panel content and tab bar
*
* @author Kaj Wallin - kaj.wallin (at) ixonos.com
* @author Pekka Nissinen - pekka.nissinen@ixonos.com
* BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
******************************************************************************/
protected:
- ///< @todo parameter name missing (also in .cpp)
/**
* @brief Draws the bar
*
- * @param * QPaintEvent unused
+ * @param event Paint event
*/
- void paintEvent(QPaintEvent *);
+ void paintEvent(QPaintEvent *event);
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
setAutoFillBackground(true);
}
-void PanelBase::paintEvent(QPaintEvent *)
+void PanelBase::paintEvent(QPaintEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
+ Q_UNUSED(event);
+
QPainter painter(this);
QRect shadowRect = QRect(0, 0, this->rect().width(), m_menuDropShadowTile.height());
* BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
******************************************************************************/
protected:
- ///< @todo parameter name (also in .cpp)
/**
* @brief Draws the panel content base
*
- * @param * QPaintEvent unused
+ * @param event Paint event
*/
- void paintEvent(QPaintEvent *);
+ void paintEvent(QPaintEvent *event);
/*******************************************************************************
* DATA MEMBERS
{
qDebug() << __PRETTY_FUNCTION__;
- this->resize(PANEL_WIDTH, PANEL_HEIGHT);
+ resize(PANEL_WIDTH, PANEL_HEIGHT);
m_panelVBox = new QVBoxLayout(this);
m_panelVBox->setMargin(0);
{
qDebug() << __PRETTY_FUNCTION__;
- this->resize(PANEL_WIDTH, size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
+ resize(PANEL_WIDTH, size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
m_panelBase->resize(this->size());
}
#include "paneltab.h"
-///< @todo TAB_WIDTH not global? move into paintEvent()
-const int TAB_WIDTH = 66;
const int TAB_WIDTH_ACTIVE = 74;
const int TAB_HEIGHT = 66;
{
qDebug() << __PRETTY_FUNCTION__;
- ///< @todo magic, use enum, check also .h todo comment, fix everywhere
- m_tabPixmaps[0].load(":/res/images/tab_inactive.png");
- m_tabPixmaps[1].load(":/res/images/tab_inactive2.png");
- m_tabPixmaps[2].load(":/res/images/tab_active.png");
+ m_tabActiveImage.load(":/res/images/tab_active.png");
+ m_tabInactiveImage.load(":/res/images/tab_inactive.png");
+ m_tabInactiveImage2.load(":/res/images/tab_inactive2.png");
setCheckable(true);
{
qDebug() << __PRETTY_FUNCTION__;
- ///< @todo mouse button is not checked, add check here or remove from mousePressEvent
+ if (event->button() == Qt::LeftButton) {
+ if(this->rect().contains(event->pos())) {
+ click();
- if(this->rect().contains(event->pos())) {
- click();
+ if(isChecked())
+ setChecked(false);
+ else
+ setChecked(true);
+ }
- if(isChecked())
- setChecked(false);
- else
- setChecked(true);
+ setDown(false);
+ m_tabSelected = false;
}
-
- setDown(false);
- m_tabSelected = false;
}
-void PanelTab::paintEvent(QPaintEvent *)
+void PanelTab::paintEvent(QPaintEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
+ Q_UNUSED(event);
+
+ const int TAB_WIDTH = 66;
+
QPainter painter(this);
if(isChecked()) {
m_tabRect.setRect(0, 0, TAB_WIDTH_ACTIVE, TAB_HEIGHT);
- painter.drawPixmap(m_tabRect, m_tabPixmaps[2]);
+ painter.drawPixmap(m_tabRect, m_tabActiveImage);
} else {
m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, 0, TAB_WIDTH, TAB_HEIGHT);
- painter.drawPixmap(m_tabRect, m_tabPixmaps[0]);
+ painter.drawPixmap(m_tabRect, m_tabInactiveImage);
}
if(isDown())
else
icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Disabled);
}
-
-///< @todo setActive() method is not used
-void PanelTab::setActive(bool state)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- if(state)
- setChecked(true);
- else
- setChecked(false);
-}
*/
void mouseReleaseEvent(QMouseEvent *event);
-///< @todo parameter name missing (also in .cpp)
/**
* @brief Draws the tab button
*
- * @param * QPaintEvent unused
+ * @param event Paint event
*/
- void paintEvent(QPaintEvent *);
-
-/*******************************************************************************
- * MEMBER FUNCTIONS AND SLOTS
- ******************************************************************************/
-public:
- /**
- * @brief This slot is used to change tab button state
- */
- void setActive(bool state);
+ void paintEvent(QPaintEvent *event);
/*******************************************************************************
* DATA MEMBERS
bool m_tabActive; ///< Boolean used to track whether the tab button is active or not
bool m_tabSelected; ///< Boolean used to track whether the tab button is selected or not
- ///< @todo magic, replace with enum?
- QPixmap m_tabPixmaps[3]; ///< Pixmap table for tab button images
+ QPixmap m_tabActiveImage; ///< Pixmap for active tab button
+ QPixmap m_tabInactiveImage; ///< Pixmap for inactive tab button
+ QPixmap m_tabInactiveImage2; ///< Pixmap for inactive tab button below active tab button
- QRect m_tabRect; ///< Rect for the tab button
+ QRect m_tabRect; ///< Rect for the tab button
};
#endif // PANELTAB_H
{
qDebug() << __PRETTY_FUNCTION__;
- return insertTab(-1, icon);
+ const int APPEND_INDEX = -1;
+
+ return insertTab(APPEND_INDEX, icon);
}
void PanelTabBar::deselectTabs()
{
qDebug() << __PRETTY_FUNCTION__;
- ///< @todo Do not use this, REMOVE ALL OCCURENCES IN ALL FILES!
- this->resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH, PANEL_HEIGHT);
- this->move(PANEL_CLOSED_X, PANEL_TOP_PADDING);
+ resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH, PANEL_HEIGHT);
+ move(PANEL_CLOSED_X, PANEL_TOP_PADDING);
// --- TABS ---
m_panelWidgetStack = new QStackedWidget(this);
{
qDebug() << __PRETTY_FUNCTION__;
- ///< @todo magic
- return insertTab(-1, widget, icon);
+ const int APPEND_INDEX = -1;
+
+ return insertTab(APPEND_INDEX, widget, icon);
}
-int TabbedPanel::insertTab(int index, QWidget *widget, const QIcon& icon)
+void TabbedPanel::closePanel()
{
qDebug() << __PRETTY_FUNCTION__;
- ///< @todo callers responsibility to call with right parameters
- if(!widget)
- return -1;
+ if(m_isOpen)
+ emit toggleState();
+}
+
+int TabbedPanel::insertTab(int index, QWidget *widget, const QIcon& icon)
+{
+ qDebug() << __PRETTY_FUNCTION__;
index = m_panelWidgetStack->insertWidget(index, widget);
m_panelTabBar->insertTab(index, icon);
}
}
-///< @todo sort alphabetically (other methods too)
-void TabbedPanel::closePanel()
+void TabbedPanel::resizePanel(const QSize &size)
{
qDebug() << __PRETTY_FUNCTION__;
- if(m_isOpen)
- emit toggleState();
+ this->resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH,
+ size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
+
+ if (!m_isOpen) {
+ move(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH, PANEL_TOP_PADDING);
+ } else {
+ move(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH - PANEL_WIDTH,
+ PANEL_TOP_PADDING);
+ }
+
+ m_panelBar->resizeBar(size);
+
+ m_panelContent->resizePanelContent(size);
+
+ m_panelStateClosed->assignProperty(this, "pos",
+ QPoint(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH,
+ PANEL_TOP_PADDING));
+ m_panelStateOpened->assignProperty(this, "pos",
+ QPoint(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH - PANEL_WIDTH,
+ PANEL_TOP_PADDING));
}
void TabbedPanel::showPanel(QWidget *widget)
{
qDebug() << __PRETTY_FUNCTION__;
-///< @todo if ((first) && (second)) {
- if (index < m_panelWidgetStack->count() && index >= 0) {
+ if ((index < m_panelWidgetStack->count()) && (index >= 0)) {
m_panelWidgetStack->setCurrentIndex(index);
if(!m_isOpen)
}
}
-void TabbedPanel::resizePanel(const QSize &size)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- this->resize(PANEL_BAR_TABBED_WIDTH + PANEL_WIDTH,
- size.height() - PANEL_TOP_PADDING - PANEL_BOTTOM_PADDING);
-
- if (!m_isOpen) {
- this->move(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH, PANEL_TOP_PADDING);
- } else {
- this->move(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH - PANEL_WIDTH,
- PANEL_TOP_PADDING);
- }
-
- m_panelBar->resizeBar(size);
-
- m_panelContent->resizePanelContent(size);
-
- ///< @todo alignment
- m_panelStateClosed->assignProperty(this, "pos",
- QPoint(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH, PANEL_TOP_PADDING));
- m_panelStateOpened->assignProperty(this, "pos",
- QPoint(size.width() - PANEL_TAB_WIDTH - PANEL_BAR_WIDTH - PANEL_WIDTH,
- PANEL_TOP_PADDING));
-}
-
void TabbedPanel::stateChanged()
{
qDebug() << __PRETTY_FUNCTION__;
*/
int addTab(QWidget *widget, const QIcon& icon);
- ///< @todo define "out of range"
/**
* @brief Inserts a tab to the panel
*