1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef OPENEDITORSMODEL_H
34 #define OPENEDITORSMODEL_H
36 #include "../core_global.h"
38 #include <QtCore/QAbstractItemModel>
39 #include <QtCore/QScopedPointer>
41 QT_FORWARD_DECLARE_CLASS(QIcon)
45 struct OpenEditorsModelPrivate;
49 class CORE_EXPORT OpenEditorsModel : public QAbstractItemModel
53 explicit OpenEditorsModel(QObject *parent);
54 virtual ~OpenEditorsModel();
56 QIcon lockedIcon() const;
57 QIcon unlockedIcon() const;
59 int columnCount(const QModelIndex &parent = QModelIndex()) const;
60 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
61 QModelIndex parent(const QModelIndex &/*index*/) const { return QModelIndex(); }
62 int rowCount(const QModelIndex &parent = QModelIndex()) const;
63 QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
65 void addEditor(IEditor *editor, bool isDuplicate = false);
66 void addRestoredEditor(const QString &fileName, const QString &displayName, const QString &id);
67 QModelIndex firstRestoredEditor() const;
69 struct CORE_EXPORT Entry {
72 QString fileName() const;
73 QString displayName() const;
76 QString m_displayName;
79 QList<Entry> entries() const;
81 IEditor *editorAt(int row) const;
83 void removeEditor(IEditor *editor);
84 void removeEditor(const QModelIndex &index);
86 void removeAllRestoredEditors();
87 void emitDataChanged(IEditor *editor);
89 QList<IEditor *> editors() const;
90 QList<Entry> restoredEditors() const;
91 bool isDuplicate(IEditor *editor) const;
92 QList<IEditor *> duplicatesFor(IEditor *editor) const;
93 IEditor *originalForDuplicate(IEditor *duplicate) const;
94 void makeOriginal(IEditor *duplicate);
95 QModelIndex indexOf(IEditor *editor) const;
97 QString displayNameForFile(IFile *file) const;
103 void addEntry(const Entry &entry);
104 int findEditor(IEditor *editor) const;
105 int findFileName(const QString &filename) const;
107 QScopedPointer<OpenEditorsModelPrivate> d;
112 #endif // OPENEDITORSMODEL_H