KDStateMachineEditor  1.0.0
A framework for creating Qt State Machine metacode using a graphical user interface
abstractscene.h
1 /*
2  This file is part of the KDAB State Machine Editor Library.
3 
4  Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com.
5  All rights reserved.
6  Author: Kevin Funk <kevin.funk@kdab.com>
7 
8  Licensees holding valid commercial KDAB State Machine Editor Library
9  licenses may use this file in accordance with the KDAB State Machine Editor
10  Library License Agreement provided with the Software.
11 
12  This file may be distributed and/or modified under the terms of the
13  GNU Lesser General Public License version 2.1 as published by the
14  Free Software Foundation and appearing in the file LICENSE.LGPL.txt included.
15 
16  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
17  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 
19  Contact info@kdab.com if any conditions of this licensing are not
20  clear to you.
21 */
22 
23 #ifndef KDSME_VIEW_ABSTRACTSCENE_H
24 #define KDSME_VIEW_ABSTRACTSCENE_H
25 
26 #include "kdsme_view_export.h"
27 
28 #include <QQuickItem>
29 #include <QPointer>
30 
31 class QAbstractItemModel;
32 class QItemSelection;
33 class QItemSelectionModel;
34 class QModelIndex;
35 
36 namespace KDSME {
37 
38 class KDSME_VIEW_EXPORT AbstractScene : public QQuickItem
39 {
40  Q_OBJECT
41  Q_PROPERTY(QAbstractItemModel* model READ model WRITE setModel NOTIFY modelChanged)
42  Q_PROPERTY(QQuickItem* instantiator READ instantiator WRITE setInstantiator NOTIFY instantiatorChanged)
43  Q_PROPERTY(ViewState viewState READ viewState NOTIFY stateChanged FINAL)
44 
45 public:
46  enum EditTrigger {
47  NoEditTriggers,
48  SelectedClicked
49  };
50  Q_DECLARE_FLAGS(EditTriggers, EditTrigger)
51 
52  enum ViewState {
53  NoState,
54  RefreshState,
55  };
56  Q_ENUMS(ViewState)
57 
58  explicit AbstractScene(QQuickItem* parent = nullptr);
59  virtual ~AbstractScene();
60 
61  virtual void setModel(QAbstractItemModel *model);
62  QAbstractItemModel *model() const;
63 
64  virtual void setSelectionModel(QItemSelectionModel *selectionModel);
65  QItemSelectionModel *selectionModel() const;
66 
67  QQuickItem* instantiator() const;
68  void setInstantiator(QQuickItem* instantiator);
69 
70  void setEditTriggers(EditTriggers triggers);
71  EditTriggers editTriggers() const;
72 
73  QObject* itemForIndex(const QModelIndex& index) const;
74 
75  ViewState viewState() const;
76 
77  QModelIndex currentIndex() const;
78 
79 public Q_SLOTS:
80  void setCurrentIndex(const QModelIndex& index);
81 
82 protected Q_SLOTS:
83  virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
84  virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
85 
86  virtual void rowsInserted(const QModelIndex& parent, int start, int end);
87  virtual void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end);
88 
93  virtual void layoutChanged();
94 
95  void setViewState(ViewState state);
96 
97 Q_SIGNALS:
98  void modelChanged(QAbstractItemModel* model);
99  void stateChanged(ViewState state);
100  void instantiatorChanged(QObject* instantiator);
101 
102 private:
103  struct Private;
104  QScopedPointer<Private> d;
105 };
106 
107 }
108 
109 Q_DECLARE_METATYPE(KDSME::AbstractScene*)
110 Q_DECLARE_METATYPE(KDSME::AbstractScene::ViewState)
111 
112 #endif // ABSTRACTVIEW_H
Definition: abstractscene.h:38
Definition: abstractexporter.h:33

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
https://github.com/KDAB/KDStateMachineEditor