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 <QButtonGroup>
27 #include "paneltabbar.h"
29 PanelTabBar::PanelTabBar(QWidget *parent)
31 m_activeTab(-1) ///< @todo magic
33 qDebug() << __PRETTY_FUNCTION__;
35 m_tabButtonGroup = new QButtonGroup(this);
37 connect(m_tabButtonGroup, SIGNAL(buttonPressed(int)),
38 this, SLOT(setCurrentIndex(int)));
41 int PanelTabBar::addTab(const QIcon& icon)
43 qDebug() << __PRETTY_FUNCTION__;
45 const int APPEND_INDEX = -1;
47 return insertTab(APPEND_INDEX, icon);
50 void PanelTabBar::deselectTabs()
52 qDebug() << __PRETTY_FUNCTION__;
54 m_tabButtonGroup->setExclusive(false);
55 m_tabButtonGroup->button(m_tabButtonGroup->checkedId())->setChecked(false);
56 m_tabButtonGroup->setExclusive(true);
59 int PanelTabBar::insertTab(int index, const QIcon& icon)
61 qDebug() << __PRETTY_FUNCTION__;
63 const int TAB_BAR_TOP_SPACING = 8;
65 int verticalStartPoint = TAB_BAR_TOP_SPACING;
67 m_tabButtonGroup->addButton(new PanelTab(this), index);
68 m_tabButtonGroup->button(index)->setIcon(icon);
70 ///< @todo [BEGIN]: Purkkaa (to be removed ASAP!!!)
72 verticalStartPoint += 65 * index;
74 m_tabButtonGroup->button(index)->move(0, verticalStartPoint);
80 void PanelTabBar::removeTab(int index)
82 qDebug() << __PRETTY_FUNCTION__;
84 if (QAbstractButton *tab = m_tabButtonGroup->button(index)) {
85 m_tabButtonGroup->removeButton(tab);
90 void PanelTabBar::selectTab(int index)
92 qDebug() << __PRETTY_FUNCTION__;
94 if (!m_tabButtonGroup->button(index)->isChecked())
95 m_tabButtonGroup->button(index)->click();
98 void PanelTabBar::setCurrentIndex(int index)
100 qDebug() << __PRETTY_FUNCTION__;
102 if (m_activeTab == index) {
105 emit tabCloseRequested(index);
108 emit currentChanged(index);