Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/util/qundoview.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** 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 or version 3 as published by the Free | - | ||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
25 | ** | - | ||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
29 | ** | - | ||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||
31 | ** | - | ||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||
33 | - | |||||||||||||
34 | #include "qundostack.h" | - | ||||||||||||
35 | #include "qundoview.h" | - | ||||||||||||
36 | - | |||||||||||||
37 | #ifndef QT_NO_UNDOVIEW | - | ||||||||||||
38 | - | |||||||||||||
39 | #include "qundogroup.h" | - | ||||||||||||
40 | #include <QtCore/qabstractitemmodel.h> | - | ||||||||||||
41 | #include <QtCore/qpointer.h> | - | ||||||||||||
42 | #include <QtGui/qicon.h> | - | ||||||||||||
43 | #include <private/qlistview_p.h> | - | ||||||||||||
44 | - | |||||||||||||
45 | QT_BEGIN_NAMESPACE | - | ||||||||||||
46 | - | |||||||||||||
47 | class QUndoModel : public QAbstractItemModel | - | ||||||||||||
48 | { | - | ||||||||||||
49 | Q_OBJECT | - | ||||||||||||
50 | public: | - | ||||||||||||
51 | QUndoModel(QObject *parent = 0); | - | ||||||||||||
52 | - | |||||||||||||
53 | QUndoStack *stack() const; | - | ||||||||||||
54 | - | |||||||||||||
55 | virtual QModelIndex index(int row, int column, | - | ||||||||||||
56 | const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | - | ||||||||||||
57 | virtual QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE; | - | ||||||||||||
58 | virtual int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | - | ||||||||||||
59 | virtual int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | - | ||||||||||||
60 | virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; | - | ||||||||||||
61 | - | |||||||||||||
62 | QModelIndex selectedIndex() const; | - | ||||||||||||
63 | QItemSelectionModel *selectionModel() const; | - | ||||||||||||
64 | - | |||||||||||||
65 | QString emptyLabel() const; | - | ||||||||||||
66 | void setEmptyLabel(const QString &label); | - | ||||||||||||
67 | - | |||||||||||||
68 | void setCleanIcon(const QIcon &icon); | - | ||||||||||||
69 | QIcon cleanIcon() const; | - | ||||||||||||
70 | - | |||||||||||||
71 | public slots: | - | ||||||||||||
72 | void setStack(QUndoStack *stack); | - | ||||||||||||
73 | - | |||||||||||||
74 | private slots: | - | ||||||||||||
75 | void stackChanged(); | - | ||||||||||||
76 | void stackDestroyed(QObject *obj); | - | ||||||||||||
77 | void setStackCurrentIndex(const QModelIndex &index); | - | ||||||||||||
78 | - | |||||||||||||
79 | private: | - | ||||||||||||
80 | QUndoStack *m_stack; | - | ||||||||||||
81 | QItemSelectionModel *m_sel_model; | - | ||||||||||||
82 | QString m_emty_label; | - | ||||||||||||
83 | QIcon m_clean_icon; | - | ||||||||||||
84 | }; | - | ||||||||||||
85 | - | |||||||||||||
86 | QUndoModel::QUndoModel(QObject *parent) | - | ||||||||||||
87 | : QAbstractItemModel(parent) | - | ||||||||||||
88 | { | - | ||||||||||||
89 | m_stack = 0; | - | ||||||||||||
90 | m_sel_model = new QItemSelectionModel(this, this); | - | ||||||||||||
91 | connect(m_sel_model, SIGNAL(currentChanged(QModelIndex,QModelIndex)), | - | ||||||||||||
92 | this, SLOT(setStackCurrentIndex(QModelIndex))); | - | ||||||||||||
93 | m_emty_label = tr("<empty>"); | - | ||||||||||||
94 | } never executed: end of block | 0 | ||||||||||||
95 | - | |||||||||||||
96 | QItemSelectionModel *QUndoModel::selectionModel() const | - | ||||||||||||
97 | { | - | ||||||||||||
98 | return m_sel_model; never executed: return m_sel_model; | 0 | ||||||||||||
99 | } | - | ||||||||||||
100 | - | |||||||||||||
101 | QUndoStack *QUndoModel::stack() const | - | ||||||||||||
102 | { | - | ||||||||||||
103 | return m_stack; never executed: return m_stack; | 0 | ||||||||||||
104 | } | - | ||||||||||||
105 | - | |||||||||||||
106 | void QUndoModel::setStack(QUndoStack *stack) | - | ||||||||||||
107 | { | - | ||||||||||||
108 | if (m_stack == stack)
| 0 | ||||||||||||
109 | return; never executed: return; | 0 | ||||||||||||
110 | - | |||||||||||||
111 | if (m_stack != 0) {
| 0 | ||||||||||||
112 | disconnect(m_stack, SIGNAL(cleanChanged(bool)), this, SLOT(stackChanged())); | - | ||||||||||||
113 | disconnect(m_stack, SIGNAL(indexChanged(int)), this, SLOT(stackChanged())); | - | ||||||||||||
114 | disconnect(m_stack, SIGNAL(destroyed(QObject*)), this, SLOT(stackDestroyed(QObject*))); | - | ||||||||||||
115 | } never executed: end of block | 0 | ||||||||||||
116 | m_stack = stack; | - | ||||||||||||
117 | if (m_stack != 0) {
| 0 | ||||||||||||
118 | connect(m_stack, SIGNAL(cleanChanged(bool)), this, SLOT(stackChanged())); | - | ||||||||||||
119 | connect(m_stack, SIGNAL(indexChanged(int)), this, SLOT(stackChanged())); | - | ||||||||||||
120 | connect(m_stack, SIGNAL(destroyed(QObject*)), this, SLOT(stackDestroyed(QObject*))); | - | ||||||||||||
121 | } never executed: end of block | 0 | ||||||||||||
122 | - | |||||||||||||
123 | stackChanged(); | - | ||||||||||||
124 | } never executed: end of block | 0 | ||||||||||||
125 | - | |||||||||||||
126 | void QUndoModel::stackDestroyed(QObject *obj) | - | ||||||||||||
127 | { | - | ||||||||||||
128 | if (obj != m_stack)
| 0 | ||||||||||||
129 | return; never executed: return; | 0 | ||||||||||||
130 | m_stack = 0; | - | ||||||||||||
131 | - | |||||||||||||
132 | stackChanged(); | - | ||||||||||||
133 | } never executed: end of block | 0 | ||||||||||||
134 | - | |||||||||||||
135 | void QUndoModel::stackChanged() | - | ||||||||||||
136 | { | - | ||||||||||||
137 | beginResetModel(); | - | ||||||||||||
138 | endResetModel(); | - | ||||||||||||
139 | m_sel_model->setCurrentIndex(selectedIndex(), QItemSelectionModel::ClearAndSelect); | - | ||||||||||||
140 | } never executed: end of block | 0 | ||||||||||||
141 | - | |||||||||||||
142 | void QUndoModel::setStackCurrentIndex(const QModelIndex &index) | - | ||||||||||||
143 | { | - | ||||||||||||
144 | if (m_stack == 0)
| 0 | ||||||||||||
145 | return; never executed: return; | 0 | ||||||||||||
146 | - | |||||||||||||
147 | if (index == selectedIndex())
| 0 | ||||||||||||
148 | return; never executed: return; | 0 | ||||||||||||
149 | - | |||||||||||||
150 | if (index.column() != 0)
| 0 | ||||||||||||
151 | return; never executed: return; | 0 | ||||||||||||
152 | - | |||||||||||||
153 | m_stack->setIndex(index.row()); | - | ||||||||||||
154 | } never executed: end of block | 0 | ||||||||||||
155 | - | |||||||||||||
156 | QModelIndex QUndoModel::selectedIndex() const | - | ||||||||||||
157 | { | - | ||||||||||||
158 | return m_stack == 0 ? QModelIndex() : createIndex(m_stack->index(), 0); never executed: return m_stack == 0 ? QModelIndex() : createIndex(m_stack->index(), 0);
| 0 | ||||||||||||
159 | } | - | ||||||||||||
160 | - | |||||||||||||
161 | QModelIndex QUndoModel::index(int row, int column, const QModelIndex &parent) const | - | ||||||||||||
162 | { | - | ||||||||||||
163 | if (m_stack == 0)
| 0 | ||||||||||||
164 | return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||
165 | - | |||||||||||||
166 | if (parent.isValid())
| 0 | ||||||||||||
167 | return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||
168 | - | |||||||||||||
169 | if (column != 0)
| 0 | ||||||||||||
170 | return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||
171 | - | |||||||||||||
172 | if (row < 0 || row > m_stack->count())
| 0 | ||||||||||||
173 | return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||
174 | - | |||||||||||||
175 | return createIndex(row, column); never executed: return createIndex(row, column); | 0 | ||||||||||||
176 | } | - | ||||||||||||
177 | - | |||||||||||||
178 | QModelIndex QUndoModel::parent(const QModelIndex&) const | - | ||||||||||||
179 | { | - | ||||||||||||
180 | return QModelIndex(); never executed: return QModelIndex(); | 0 | ||||||||||||
181 | } | - | ||||||||||||
182 | - | |||||||||||||
183 | int QUndoModel::rowCount(const QModelIndex &parent) const | - | ||||||||||||
184 | { | - | ||||||||||||
185 | if (m_stack == 0)
| 0 | ||||||||||||
186 | return 0; never executed: return 0; | 0 | ||||||||||||
187 | - | |||||||||||||
188 | if (parent.isValid())
| 0 | ||||||||||||
189 | return 0; never executed: return 0; | 0 | ||||||||||||
190 | - | |||||||||||||
191 | return m_stack->count() + 1; never executed: return m_stack->count() + 1; | 0 | ||||||||||||
192 | } | - | ||||||||||||
193 | - | |||||||||||||
194 | int QUndoModel::columnCount(const QModelIndex&) const | - | ||||||||||||
195 | { | - | ||||||||||||
196 | return 1; never executed: return 1; | 0 | ||||||||||||
197 | } | - | ||||||||||||
198 | - | |||||||||||||
199 | QVariant QUndoModel::data(const QModelIndex &index, int role) const | - | ||||||||||||
200 | { | - | ||||||||||||
201 | if (m_stack == 0)
| 0 | ||||||||||||
202 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||
203 | - | |||||||||||||
204 | if (index.column() != 0)
| 0 | ||||||||||||
205 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||
206 | - | |||||||||||||
207 | if (index.row() < 0 || index.row() > m_stack->count())
| 0 | ||||||||||||
208 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||
209 | - | |||||||||||||
210 | if (role == Qt::DisplayRole) {
| 0 | ||||||||||||
211 | if (index.row() == 0)
| 0 | ||||||||||||
212 | return m_emty_label; never executed: return m_emty_label; | 0 | ||||||||||||
213 | return m_stack->text(index.row() - 1); never executed: return m_stack->text(index.row() - 1); | 0 | ||||||||||||
214 | } else if (role == Qt::DecorationRole) {
| 0 | ||||||||||||
215 | if (index.row() == m_stack->cleanIndex() && !m_clean_icon.isNull())
| 0 | ||||||||||||
216 | return m_clean_icon; never executed: return m_clean_icon; | 0 | ||||||||||||
217 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||
218 | } | - | ||||||||||||
219 | - | |||||||||||||
220 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||
221 | } | - | ||||||||||||
222 | - | |||||||||||||
223 | QString QUndoModel::emptyLabel() const | - | ||||||||||||
224 | { | - | ||||||||||||
225 | return m_emty_label; never executed: return m_emty_label; | 0 | ||||||||||||
226 | } | - | ||||||||||||
227 | - | |||||||||||||
228 | void QUndoModel::setEmptyLabel(const QString &label) | - | ||||||||||||
229 | { | - | ||||||||||||
230 | m_emty_label = label; | - | ||||||||||||
231 | stackChanged(); | - | ||||||||||||
232 | } never executed: end of block | 0 | ||||||||||||
233 | - | |||||||||||||
234 | void QUndoModel::setCleanIcon(const QIcon &icon) | - | ||||||||||||
235 | { | - | ||||||||||||
236 | m_clean_icon = icon; | - | ||||||||||||
237 | stackChanged(); | - | ||||||||||||
238 | } never executed: end of block | 0 | ||||||||||||
239 | - | |||||||||||||
240 | QIcon QUndoModel::cleanIcon() const | - | ||||||||||||
241 | { | - | ||||||||||||
242 | return m_clean_icon; never executed: return m_clean_icon; | 0 | ||||||||||||
243 | } | - | ||||||||||||
244 | - | |||||||||||||
245 | /*! | - | ||||||||||||
246 | \class QUndoView | - | ||||||||||||
247 | \brief The QUndoView class displays the contents of a QUndoStack. | - | ||||||||||||
248 | \since 4.2 | - | ||||||||||||
249 | - | |||||||||||||
250 | \ingroup advanced | - | ||||||||||||
251 | \inmodule QtWidgets | - | ||||||||||||
252 | - | |||||||||||||
253 | QUndoView is a QListView which displays the list of commands pushed on an undo stack. | - | ||||||||||||
254 | The most recently executed command is always selected. Selecting a different command | - | ||||||||||||
255 | results in a call to QUndoStack::setIndex(), rolling the state of the document | - | ||||||||||||
256 | backwards or forward to the new command. | - | ||||||||||||
257 | - | |||||||||||||
258 | The stack can be set explicitly with setStack(). Alternatively, a QUndoGroup object can | - | ||||||||||||
259 | be set with setGroup(). The view will then update itself automatically whenever the | - | ||||||||||||
260 | active stack of the group changes. | - | ||||||||||||
261 | - | |||||||||||||
262 | \image qundoview.png | - | ||||||||||||
263 | */ | - | ||||||||||||
264 | - | |||||||||||||
265 | class QUndoViewPrivate : public QListViewPrivate | - | ||||||||||||
266 | { | - | ||||||||||||
267 | Q_DECLARE_PUBLIC(QUndoView) | - | ||||||||||||
268 | public: | - | ||||||||||||
269 | QUndoViewPrivate() : | - | ||||||||||||
270 | #ifndef QT_NO_UNDOGROUP | - | ||||||||||||
271 | group(0), | - | ||||||||||||
272 | #endif | - | ||||||||||||
273 | model(0) {} never executed: end of block | 0 | ||||||||||||
274 | - | |||||||||||||
275 | #ifndef QT_NO_UNDOGROUP | - | ||||||||||||
276 | QPointer<QUndoGroup> group; | - | ||||||||||||
277 | #endif | - | ||||||||||||
278 | QUndoModel *model; | - | ||||||||||||
279 | - | |||||||||||||
280 | void init(); | - | ||||||||||||
281 | }; | - | ||||||||||||
282 | - | |||||||||||||
283 | void QUndoViewPrivate::init() | - | ||||||||||||
284 | { | - | ||||||||||||
285 | Q_Q(QUndoView); | - | ||||||||||||
286 | - | |||||||||||||
287 | model = new QUndoModel(q); | - | ||||||||||||
288 | q->setModel(model); | - | ||||||||||||
289 | q->setSelectionModel(model->selectionModel()); | - | ||||||||||||
290 | } never executed: end of block | 0 | ||||||||||||
291 | - | |||||||||||||
292 | /*! | - | ||||||||||||
293 | Constructs a new view with parent \a parent. | - | ||||||||||||
294 | */ | - | ||||||||||||
295 | - | |||||||||||||
296 | QUndoView::QUndoView(QWidget *parent) | - | ||||||||||||
297 | : QListView(*new QUndoViewPrivate(), parent) | - | ||||||||||||
298 | { | - | ||||||||||||
299 | Q_D(QUndoView); | - | ||||||||||||
300 | d->init(); | - | ||||||||||||
301 | } never executed: end of block | 0 | ||||||||||||
302 | - | |||||||||||||
303 | /*! | - | ||||||||||||
304 | Constructs a new view with parent \a parent and sets the observed stack to \a stack. | - | ||||||||||||
305 | */ | - | ||||||||||||
306 | - | |||||||||||||
307 | QUndoView::QUndoView(QUndoStack *stack, QWidget *parent) | - | ||||||||||||
308 | : QListView(*new QUndoViewPrivate(), parent) | - | ||||||||||||
309 | { | - | ||||||||||||
310 | Q_D(QUndoView); | - | ||||||||||||
311 | d->init(); | - | ||||||||||||
312 | setStack(stack); | - | ||||||||||||
313 | } never executed: end of block | 0 | ||||||||||||
314 | - | |||||||||||||
315 | #ifndef QT_NO_UNDOGROUP | - | ||||||||||||
316 | - | |||||||||||||
317 | /*! | - | ||||||||||||
318 | Constructs a new view with parent \a parent and sets the observed group to \a group. | - | ||||||||||||
319 | - | |||||||||||||
320 | The view will update itself autmiatically whenever the active stack of the group changes. | - | ||||||||||||
321 | */ | - | ||||||||||||
322 | - | |||||||||||||
323 | QUndoView::QUndoView(QUndoGroup *group, QWidget *parent) | - | ||||||||||||
324 | : QListView(*new QUndoViewPrivate(), parent) | - | ||||||||||||
325 | { | - | ||||||||||||
326 | Q_D(QUndoView); | - | ||||||||||||
327 | d->init(); | - | ||||||||||||
328 | setGroup(group); | - | ||||||||||||
329 | } never executed: end of block | 0 | ||||||||||||
330 | - | |||||||||||||
331 | #endif // QT_NO_UNDOGROUP | - | ||||||||||||
332 | - | |||||||||||||
333 | /*! | - | ||||||||||||
334 | Destroys this view. | - | ||||||||||||
335 | */ | - | ||||||||||||
336 | - | |||||||||||||
337 | QUndoView::~QUndoView() | - | ||||||||||||
338 | { | - | ||||||||||||
339 | } | - | ||||||||||||
340 | - | |||||||||||||
341 | /*! | - | ||||||||||||
342 | Returns the stack currently displayed by this view. If the view is looking at a | - | ||||||||||||
343 | QUndoGroup, this the group's active stack. | - | ||||||||||||
344 | - | |||||||||||||
345 | \sa setStack(), setGroup() | - | ||||||||||||
346 | */ | - | ||||||||||||
347 | - | |||||||||||||
348 | QUndoStack *QUndoView::stack() const | - | ||||||||||||
349 | { | - | ||||||||||||
350 | Q_D(const QUndoView); | - | ||||||||||||
351 | return d->model->stack(); never executed: return d->model->stack(); | 0 | ||||||||||||
352 | } | - | ||||||||||||
353 | - | |||||||||||||
354 | /*! | - | ||||||||||||
355 | Sets the stack displayed by this view to \a stack. If \a stack is 0, the view | - | ||||||||||||
356 | will be empty. | - | ||||||||||||
357 | - | |||||||||||||
358 | If the view was previously looking at a QUndoGroup, the group is set to 0. | - | ||||||||||||
359 | - | |||||||||||||
360 | \sa stack(), setGroup() | - | ||||||||||||
361 | */ | - | ||||||||||||
362 | - | |||||||||||||
363 | void QUndoView::setStack(QUndoStack *stack) | - | ||||||||||||
364 | { | - | ||||||||||||
365 | Q_D(QUndoView); | - | ||||||||||||
366 | #ifndef QT_NO_UNDOGROUP | - | ||||||||||||
367 | setGroup(0); | - | ||||||||||||
368 | #endif | - | ||||||||||||
369 | d->model->setStack(stack); | - | ||||||||||||
370 | } never executed: end of block | 0 | ||||||||||||
371 | - | |||||||||||||
372 | #ifndef QT_NO_UNDOGROUP | - | ||||||||||||
373 | - | |||||||||||||
374 | /*! | - | ||||||||||||
375 | Sets the group displayed by this view to \a group. If \a group is 0, the view will | - | ||||||||||||
376 | be empty. | - | ||||||||||||
377 | - | |||||||||||||
378 | The view will update itself autmiatically whenever the active stack of the group changes. | - | ||||||||||||
379 | - | |||||||||||||
380 | \sa group(), setStack() | - | ||||||||||||
381 | */ | - | ||||||||||||
382 | - | |||||||||||||
383 | void QUndoView::setGroup(QUndoGroup *group) | - | ||||||||||||
384 | { | - | ||||||||||||
385 | Q_D(QUndoView); | - | ||||||||||||
386 | - | |||||||||||||
387 | if (d->group == group)
| 0 | ||||||||||||
388 | return; never executed: return; | 0 | ||||||||||||
389 | - | |||||||||||||
390 | if (d->group != 0) {
| 0 | ||||||||||||
391 | disconnect(d->group, SIGNAL(activeStackChanged(QUndoStack*)), | - | ||||||||||||
392 | d->model, SLOT(setStack(QUndoStack*))); | - | ||||||||||||
393 | } never executed: end of block | 0 | ||||||||||||
394 | - | |||||||||||||
395 | d->group = group; | - | ||||||||||||
396 | - | |||||||||||||
397 | if (d->group != 0) {
| 0 | ||||||||||||
398 | connect(d->group, SIGNAL(activeStackChanged(QUndoStack*)), | - | ||||||||||||
399 | d->model, SLOT(setStack(QUndoStack*))); | - | ||||||||||||
400 | d->model->setStack(d->group->activeStack()); | - | ||||||||||||
401 | } else { never executed: end of block | 0 | ||||||||||||
402 | d->model->setStack(0); | - | ||||||||||||
403 | } never executed: end of block | 0 | ||||||||||||
404 | } | - | ||||||||||||
405 | - | |||||||||||||
406 | /*! | - | ||||||||||||
407 | Returns the group displayed by this view. | - | ||||||||||||
408 | - | |||||||||||||
409 | If the view is not looking at group, this function returns 0. | - | ||||||||||||
410 | - | |||||||||||||
411 | \sa setGroup(), setStack() | - | ||||||||||||
412 | */ | - | ||||||||||||
413 | - | |||||||||||||
414 | QUndoGroup *QUndoView::group() const | - | ||||||||||||
415 | { | - | ||||||||||||
416 | Q_D(const QUndoView); | - | ||||||||||||
417 | return d->group; never executed: return d->group; | 0 | ||||||||||||
418 | } | - | ||||||||||||
419 | - | |||||||||||||
420 | #endif // QT_NO_UNDOGROUP | - | ||||||||||||
421 | - | |||||||||||||
422 | /*! | - | ||||||||||||
423 | \property QUndoView::emptyLabel | - | ||||||||||||
424 | \brief the label used for the empty state. | - | ||||||||||||
425 | - | |||||||||||||
426 | The empty label is the topmost element in the list of commands, which represents | - | ||||||||||||
427 | the state of the document before any commands were pushed on the stack. The default | - | ||||||||||||
428 | is the string "<empty>". | - | ||||||||||||
429 | */ | - | ||||||||||||
430 | - | |||||||||||||
431 | void QUndoView::setEmptyLabel(const QString &label) | - | ||||||||||||
432 | { | - | ||||||||||||
433 | Q_D(QUndoView); | - | ||||||||||||
434 | d->model->setEmptyLabel(label); | - | ||||||||||||
435 | } never executed: end of block | 0 | ||||||||||||
436 | - | |||||||||||||
437 | QString QUndoView::emptyLabel() const | - | ||||||||||||
438 | { | - | ||||||||||||
439 | Q_D(const QUndoView); | - | ||||||||||||
440 | return d->model->emptyLabel(); never executed: return d->model->emptyLabel(); | 0 | ||||||||||||
441 | } | - | ||||||||||||
442 | - | |||||||||||||
443 | /*! | - | ||||||||||||
444 | \property QUndoView::cleanIcon | - | ||||||||||||
445 | \brief the icon used to represent the clean state. | - | ||||||||||||
446 | - | |||||||||||||
447 | A stack may have a clean state set with QUndoStack::setClean(). This is usually | - | ||||||||||||
448 | the state of the document at the point it was saved. QUndoView can display an | - | ||||||||||||
449 | icon in the list of commands to show the clean state. If this property is | - | ||||||||||||
450 | a null icon, no icon is shown. The default value is the null icon. | - | ||||||||||||
451 | */ | - | ||||||||||||
452 | - | |||||||||||||
453 | void QUndoView::setCleanIcon(const QIcon &icon) | - | ||||||||||||
454 | { | - | ||||||||||||
455 | Q_D(const QUndoView); | - | ||||||||||||
456 | d->model->setCleanIcon(icon); | - | ||||||||||||
457 | - | |||||||||||||
458 | } never executed: end of block | 0 | ||||||||||||
459 | - | |||||||||||||
460 | QIcon QUndoView::cleanIcon() const | - | ||||||||||||
461 | { | - | ||||||||||||
462 | Q_D(const QUndoView); | - | ||||||||||||
463 | return d->model->cleanIcon(); never executed: return d->model->cleanIcon(); | 0 | ||||||||||||
464 | } | - | ||||||||||||
465 | - | |||||||||||||
466 | QT_END_NAMESPACE | - | ||||||||||||
467 | - | |||||||||||||
468 | #include "qundoview.moc" | - | ||||||||||||
469 | #include "moc_qundoview.cpp" | - | ||||||||||||
470 | - | |||||||||||||
471 | #endif // QT_NO_UNDOVIEW | - | ||||||||||||
Source code | Switch to Preprocessed file |