create PresenceManager that manage global presence state and message
[makneto-zunavac1.git] / src / ui-kde / sidebarwidget.cpp
blob0ac5a09cfb95742baad8d3f64d921ea0fa5d2264
1 /*
2 * sidebarwidget.cpp
4 * Copyright (C) 2007 Jaroslav Reznik <rezzabuh@gmail.com>
5 */
7 #include "sidebarwidget.h"
8 //#include "connectionview.h"
9 #include "kmultitabbar.h"
10 #include "kiconloader.h"
11 #include "klocale.h"
12 #include "kdebug.h"
14 #include <QtGui/QHBoxLayout>
15 #include <QtGui/QLabel>
16 #include <QtGui/QWidget>
17 #include <QtGui/QStackedWidget>
20 SidebarWidget::SidebarWidget(QWidget *) : m_currentIndex(-1)
22 m_layout = new QHBoxLayout(this);
23 m_layout->setMargin(0);
24 m_layout->setSpacing(0);
26 m_multitab = new KMultiTabBar(KMultiTabBar::Left, this);
27 m_widgets = new QStackedWidget();
29 m_layout->addWidget(m_multitab);
30 m_layout->addWidget(m_widgets);
32 m_multitab->setPosition(KMultiTabBar::Left);
34 setMinimumSize(0, 0);
36 setLayout(m_layout);
39 SidebarWidget::~SidebarWidget()
44 int SidebarWidget::appendTabWidget(QWidget *widget, const QPixmap &pic, int id, const QString &text)
46 // append tab and tab signal
47 m_multitab->appendTab(pic, id, text);
48 connect(m_multitab->tab(id), SIGNAL(clicked(int)), this, SLOT(tabClicked(int)));
50 // append widget to stack
51 m_widgets->insertWidget(id, widget);
53 return 0;
56 void SidebarWidget::setCurrentIndex(int index)
58 if (m_currentIndex != index)
60 // reset current tab
61 m_multitab->setTab(m_currentIndex, false);
63 m_currentIndex = index;
65 // set widget to index
66 m_multitab->setTab(m_currentIndex, true);
68 m_widgets->setCurrentIndex(index);
72 void SidebarWidget::tabClicked(int id)
74 if (m_currentIndex != id)
76 setCurrentIndex(id);
77 m_widgets->setVisible(true);
79 else
81 m_widgets->setVisible(!m_widgets->isVisible());
85 void SidebarWidget::hideAll()
87 m_widgets->setCurrentIndex(-1);
88 m_widgets->setVisible(false);
89 for (int i = 0; i < m_widgets->count(); i++)
90 m_multitab->setTab(i, false);
93 #include "sidebarwidget.moc"