4 * Copyright (C) 2007 Jaroslav Reznik <rezzabuh@gmail.com>
7 #include "sidebarwidget.h"
8 //#include "connectionview.h"
9 #include "kmultitabbar.h"
10 #include "kiconloader.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
);
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
);
56 void SidebarWidget::setCurrentIndex(int index
)
58 if (m_currentIndex
!= index
)
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
)
77 m_widgets
->setVisible(true);
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"