1/****************************************************************************
2**
3** Copyright (C) 2009 Tony Murray <murraytony @ gmail.com>
4**
5** This file is part of KDE.
6**
7** This program is free software; you can redistribute it and/or modify
8** it under the terms of the GNU General Public License as published by
9** the Free Software Foundation; either version 2 of the License, or
10** (at your option) any later version.
11**
12** This program is distributed in the hope that it will be useful,
13** but WITHOUT ANY WARRANTY; without even the implied warranty of
14** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15** GNU General Public License for more details.
16**
17** You should have received a copy of the GNU General Public License
18** along with this program; see the file COPYING. If not, write to
19** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20** Boston, MA 02110-1301, USA.
21**
22****************************************************************************/
23
24#ifndef TABBEDVIEWWIDGET_H
25#define TABBEDVIEWWIDGET_H
26
27#include <QAbstractItemModel>
28#include <KTabWidget>
29
30class TabbedViewWidgetModel : public QAbstractItemModel
31{
32 friend class TabbedViewWidget;
33 Q_OBJECT
34public:
35 explicit TabbedViewWidgetModel(KTabWidget *modelTarget);
36 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
37 QModelIndex parent(const QModelIndex &index) const;
38 int rowCount(const QModelIndex &parent = QModelIndex()) const;
39 int columnCount(const QModelIndex &parent = QModelIndex()) const;
40 Qt::ItemFlags flags(const QModelIndex &index) const;
41 bool setData(const QModelIndex &index, const QVariant &value, int role);
42 QVariant data(const QModelIndex &index, int role) const;
43protected:
44 void emitLayoutAboutToBeChanged();
45 void emitLayoutChanged();
46 void emitDataChanged(int index);
47private:
48 KTabWidget *m_tabWidget;
49};
50
51class TabbedViewWidget : public KTabWidget
52{
53 Q_OBJECT
54public:
55 explicit TabbedViewWidget(QWidget *parent = 0, Qt::WFlags flags = 0);
56 virtual ~TabbedViewWidget();
57 TabbedViewWidgetModel* getModel();
58 int addTab(QWidget *page, const QString &label);
59 int addTab(QWidget *page, const QIcon &icon, const QString &label);
60 int insertTab(int index, QWidget *page, const QString &label);
61 int insertTab(int index, QWidget *page, const QIcon &icon, const QString &label);
62 void removeTab(int index);
63 void removePage(QWidget *page);
64 void moveTab(int from, int to);
65 void setTabText(int index, const QString &label);
66private:
67 TabbedViewWidgetModel *m_model;
68};
69
70#endif // FULLSCREENWINDOW_H
71
72