2
* Copyright 2013 Canonical Ltd.
4
* This file is part of webbrowser-app.
6
* webbrowser-app is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 3.
10
* webbrowser-app is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#ifndef __TABS_MODEL_H__
20
#define __TABS_MODEL_H__
23
#include <QtCore/QAbstractListModel>
24
#include <QtCore/QList>
28
class TabsModel : public QAbstractListModel
34
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
35
Q_PROPERTY(QQuickItem* currentWebview READ currentWebview NOTIFY currentWebviewChanged)
36
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
39
TabsModel(QObject* parent=0);
43
Url = Qt::UserRole + 1,
50
// reimplemented from QAbstractListModel
51
QHash<int, QByteArray> roleNames() const;
52
int rowCount(const QModelIndex& parent=QModelIndex()) const;
53
QVariant data(const QModelIndex& index, int role) const;
55
int currentIndex() const;
56
void setCurrentIndex(int index);
58
QQuickItem* currentWebview() const;
60
Q_INVOKABLE int add(QQuickItem* webview);
61
Q_INVOKABLE QQuickItem* remove(int index);
64
void currentIndexChanged() const;
65
void currentWebviewChanged() const;
66
void countChanged() const;
70
void onTitleChanged();
74
QList<QQuickItem*> m_webviews;
77
bool checkValidTabIndex(int index) const;
78
void onDataChanged(QQuickItem* webview, int role);
81
#endif // __TABS_MODEL_H__