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 RESOURCEVIEW_H
34 #define RESOURCEVIEW_H
36 #include "namespace_global.h"
38 #include "resourcefile_p.h"
40 #include <QtGui/QTreeView>
41 #include <QtCore/QPoint>
43 using namespace qdesigner_internal;
52 namespace SharedTools {
57 Holds the backup of a tree node including children.
62 ResourceModel *m_model;
66 EntryBackup(ResourceModel &model, int prefixIndex, const QString &name)
67 : m_model(&model), m_prefixIndex(prefixIndex), m_name(name) { }
70 virtual void restore() const = 0;
71 virtual ~EntryBackup() { }
75 class RelativeResourceModel;
78 class ResourceView : public QTreeView
89 explicit ResourceView(QUndoStack *history, QWidget *parent = 0);
92 bool load(const QString &fileName);
94 QString fileName() const;
95 void setFileName(const QString &fileName);
98 void setDirty(bool dirty);
100 void enableContextMenu(bool enable);
102 void addFiles(QStringList fileList, const QModelIndex &index);
104 void addFile(const QString &prefix, const QString &file);
105 // void removeFile(const QString &prefix, const QString &file);
107 bool isPrefix(const QModelIndex &index) const;
109 QString currentAlias() const;
110 QString currentPrefix() const;
111 QString currentLanguage() const;
113 void setResourceDragEnabled(bool e);
114 bool resourceDragEnabled() const;
116 void setDefaultAddFileEnabled(bool enable);
117 bool defaultAddFileEnabled() const;
119 void findSamePlacePostDeletionModelIndex(int &row, QModelIndex &parent) const;
120 EntryBackup *removeEntry(const QModelIndex &index);
121 void addFiles(int prefixIndex, const QStringList &fileNames, int cursorFile,
122 int &firstFile, int &lastFile);
123 void removeFiles(int prefixIndex, int firstFileIndex, int lastFileIndex);
124 QStringList fileNamesToAdd();
125 QModelIndex addPrefix();
129 void setCurrentAlias(const QString &before, const QString &after);
130 void setCurrentPrefix(const QString &before, const QString &after);
131 void setCurrentLanguage(const QString &before, const QString &after);
132 void advanceMergeId();
136 void changePrefix(const QModelIndex &index);
137 void changeLang(const QModelIndex &index);
138 void changeAlias(const QModelIndex &index);
139 void mouseReleaseEvent(QMouseEvent *e);
140 void keyPressEvent(QKeyEvent *e);
144 void dirtyChanged(bool b);
146 void addFilesTriggered(const QString &prefix);
147 void addPrefixTriggered();
153 void popupMenu(const QModelIndex &index);
156 QString getCurrentValue(NodeProperty property) const;
157 void changeValue(const QModelIndex &nodeIndex, NodeProperty property, const QString &value);
160 void addUndoCommand(const QModelIndex &nodeIndex, NodeProperty property,
161 const QString &before, const QString &after);
165 qdesigner_internal::ResourceFile m_qrcFile;
166 Internal::RelativeResourceModel *m_qrcModel;
169 QAction *m_editAlias;
170 QAction *m_removeItem;
171 QAction *m_addPrefix;
172 QAction *m_editPrefix;
175 bool m_defaultAddFile;
176 QUndoStack *m_history;
180 } // namespace SharedTools
182 #endif // RESOURCEVIEW_H