2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Pekka Nissinen - pekka.nissinen@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 #include <QMouseEvent>
29 ///< @todo TAB_WIDTH not global? move into paintEvent()
30 const int TAB_WIDTH = 66;
31 const int TAB_WIDTH_ACTIVE = 74;
32 const int TAB_HEIGHT = 66;
34 PanelTab::PanelTab(QWidget *parent)
35 : QToolButton(parent),
39 qDebug() << __PRETTY_FUNCTION__;
41 ///< @todo magic, use enum, check also .h todo comment, fix everywhere
42 m_tabPixmaps[0].load(":/res/images/tab_inactive.png");
43 m_tabPixmaps[1].load(":/res/images/tab_inactive2.png");
44 m_tabPixmaps[2].load(":/res/images/tab_active.png");
48 setFixedSize(TAB_WIDTH_ACTIVE, TAB_HEIGHT);
51 void PanelTab::mouseMoveEvent(QMouseEvent *event)
53 qDebug() << __PRETTY_FUNCTION__;
56 if(!rect().contains(event->pos()))
63 void PanelTab::mousePressEvent(QMouseEvent *event)
65 qDebug() << __PRETTY_FUNCTION__;
67 if(event->button() == Qt::LeftButton) {
73 void PanelTab::mouseReleaseEvent(QMouseEvent *event)
75 qDebug() << __PRETTY_FUNCTION__;
77 ///< @todo mouse button is not checked, add check here or remove from mousePressEvent
79 if(this->rect().contains(event->pos())) {
89 m_tabSelected = false;
92 void PanelTab::paintEvent(QPaintEvent *)
94 qDebug() << __PRETTY_FUNCTION__;
96 QPainter painter(this);
99 m_tabRect.setRect(0, 0, TAB_WIDTH_ACTIVE, TAB_HEIGHT);
100 painter.drawPixmap(m_tabRect, m_tabPixmaps[2]);
102 m_tabRect.setRect(TAB_WIDTH_ACTIVE - TAB_WIDTH, 0, TAB_WIDTH, TAB_HEIGHT);
103 painter.drawPixmap(m_tabRect, m_tabPixmaps[0]);
107 icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Selected);
109 icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Normal);
111 icon().paint(&painter, m_tabRect, Qt::AlignCenter, QIcon::Disabled);
114 ///< @todo setActive() method is not used
115 void PanelTab::setActive(bool state)
117 qDebug() << __PRETTY_FUNCTION__;