1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #ifndef RESOURCEVIEW_H
35 #define RESOURCEVIEW_H
37 #include "namespace_global.h"
39 #include "resourcefile_p.h"
41 #include <QtGui/QTreeView>
42 #include <QtCore/QPoint>
44 using namespace qdesigner_internal;
53 namespace SharedTools {
58 Holds the backup of a tree node including children.
63 ResourceModel *m_model;
67 EntryBackup(ResourceModel &model, int prefixIndex, const QString &name)
68 : m_model(&model), m_prefixIndex(prefixIndex), m_name(name) { }
71 virtual void restore() const = 0;
72 virtual ~EntryBackup() { }
76 class RelativeResourceModel;
79 class ResourceView : public QTreeView
90 explicit ResourceView(QUndoStack *history, QWidget *parent = 0);
93 bool load(const QString &fileName);
95 QString fileName() const;
96 void setFileName(const QString &fileName);
99 void setDirty(bool dirty);
101 void enableContextMenu(bool enable);
103 void addFiles(QStringList fileList, const QModelIndex &index);
105 void addFile(const QString &prefix, const QString &file);
106 // void removeFile(const QString &prefix, const QString &file);
108 bool isPrefix(const QModelIndex &index) const;
110 QString currentAlias() const;
111 QString currentPrefix() const;
112 QString currentLanguage() const;
114 void setResourceDragEnabled(bool e);
115 bool resourceDragEnabled() const;
117 void setDefaultAddFileEnabled(bool enable);
118 bool defaultAddFileEnabled() const;
120 void findSamePlacePostDeletionModelIndex(int &row, QModelIndex &parent) const;
121 EntryBackup *removeEntry(const QModelIndex &index);
122 void addFiles(int prefixIndex, const QStringList &fileNames, int cursorFile,
123 int &firstFile, int &lastFile);
124 void removeFiles(int prefixIndex, int firstFileIndex, int lastFileIndex);
125 QStringList fileNamesToAdd();
126 QModelIndex addPrefix();
130 void setCurrentAlias(const QString &before, const QString &after);
131 void setCurrentPrefix(const QString &before, const QString &after);
132 void setCurrentLanguage(const QString &before, const QString &after);
133 void advanceMergeId();
137 void changePrefix(const QModelIndex &index);
138 void changeLang(const QModelIndex &index);
139 void changeAlias(const QModelIndex &index);
140 void mouseReleaseEvent(QMouseEvent *e);
141 void keyPressEvent(QKeyEvent *e);
145 void dirtyChanged(bool b);
147 void addFilesTriggered(const QString &prefix);
148 void addPrefixTriggered();
154 void popupMenu(const QModelIndex &index);
157 QString getCurrentValue(NodeProperty property) const;
158 void changeValue(const QModelIndex &nodeIndex, NodeProperty property, const QString &value);
161 void addUndoCommand(const QModelIndex &nodeIndex, NodeProperty property,
162 const QString &before, const QString &after);
166 qdesigner_internal::ResourceFile m_qrcFile;
167 Internal::RelativeResourceModel *m_qrcModel;
170 QAction *m_editAlias;
171 QAction *m_removeItem;
172 QAction *m_addPrefix;
173 QAction *m_editPrefix;
176 bool m_defaultAddFile;
177 QUndoStack *m_history;
181 } // namespace SharedTools
183 #endif // RESOURCEVIEW_H