OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / coreplugin / editormanager / openeditorsmodel.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
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.
18 **
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.
22 **
23 ** Other Usage
24 **
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.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef OPENEDITORSMODEL_H
34 #define OPENEDITORSMODEL_H
35
36 #include "../core_global.h"
37
38 #include <QtCore/QAbstractItemModel>
39 #include <QtCore/QScopedPointer>
40
41 QT_FORWARD_DECLARE_CLASS(QIcon)
42
43 namespace Core {
44
45 struct OpenEditorsModelPrivate;
46 class IEditor;
47 class IFile;
48
49 class CORE_EXPORT OpenEditorsModel : public QAbstractItemModel
50 {
51     Q_OBJECT
52 public:
53     explicit OpenEditorsModel(QObject *parent);
54     virtual ~OpenEditorsModel();
55
56     QIcon lockedIcon() const;
57     QIcon unlockedIcon() const;
58
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;
64
65     void addEditor(IEditor *editor, bool isDuplicate = false);
66     void addRestoredEditor(const QString &fileName, const QString &displayName, const QString &id);
67     QModelIndex firstRestoredEditor() const;
68
69     struct CORE_EXPORT Entry {
70         Entry();
71         IEditor *editor;
72         QString fileName() const;
73         QString displayName() const;
74         QString id() const;
75         QString m_fileName;
76         QString m_displayName;
77         QString m_id;
78     };
79     QList<Entry> entries() const;
80
81     IEditor *editorAt(int row) const;
82
83     void removeEditor(IEditor *editor);
84     void removeEditor(const QModelIndex &index);
85
86     void removeAllRestoredEditors();
87     void emitDataChanged(IEditor *editor);
88
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;
96
97     QString displayNameForFile(IFile *file) const;
98
99 private slots:
100     void itemChanged();
101
102 private:
103     void addEntry(const Entry &entry);
104     int findEditor(IEditor *editor) const;
105     int findFileName(const QString &filename) const;
106
107     QScopedPointer<OpenEditorsModelPrivate> d;
108 };
109
110 } // namespace Core
111
112 #endif // OPENEDITORSMODEL_H