Version 0.3
[aspt.git] / stafftab.cc
1 /*******************************************************************
2 Jan Cermak | johniez | aspt.johniez.com
3 Creative Commons 2.5 Attribution-NonCommercial-NoDerivs 2.5 license
4 http://creativecommons.org/licenses/by-nc-nd/2.5/legalcode
5 *******************************************************************/
6
7 #include "stafftab.h"
8
9 /**
10  * \brief Staff Tab constructor.
11  */
12 StaffTab::StaffTab(QWidget *parent) : QWidget(parent) {
13         initTabs();
14 }
15
16 /**
17  * \brief Staff Tab destructor.
18  */
19 StaffTab::~StaffTab() {
20         delete tabWidget;
21         delete mainLayout;
22 }
23
24 /**
25  * \brief Add tabs for each staff members.
26  */
27 void StaffTab::initTabs() {
28         tabWidget = new QTabWidget;
29         tabWidget->setTabPosition(QTabWidget::West);
30         for(int i=0; i<staffCnt; ++i) {
31                 tabWidget->addTab(new StaffMember(i, this), staff[i].name);
32         }
33         
34         mainLayout = new QVBoxLayout;
35         mainLayout->addWidget(tabWidget);
36         setLayout(mainLayout);
37 }
38
39 /**
40  * \brief Slot assigned to data change action.
41  */
42 void StaffTab::dataChanged() {
43         rebuildUI();
44 }
45
46 /**
47  * \brief Delete widget and draw it again.
48  */
49 void StaffTab::rebuildUI() {
50         delete tabWidget;
51         delete mainLayout;
52         
53         initTabs();
54 }