Kactus2
Kactus2 reference guide
Loading...
Searching...
No Matches
LibraryTreeModel.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// File: librarytreemodel.h
3//-----------------------------------------------------------------------------
4// Project: Kactus2
5// Author: Antti Kamppi
6// Date: 20.12.2010
7//
8// Description:
9// The model that contains the LibraryItems to display library hierarchically.
10//-----------------------------------------------------------------------------
11
12#ifndef LIBRARYTREEMODEL_H
13#define LIBRARYTREEMODEL_H
14
15#include "LibraryItem.h"
16
17#include <IPXACTmodels/common/VLNV.h>
18
19#include <KactusAPI/KactusAPIGlobal.h>
20
21#include <QAbstractItemModel>
22#include <QModelIndex>
23#include <QVariant>
24#include <QSharedPointer>
25#include <QList>
26
28
29//-----------------------------------------------------------------------------
31//-----------------------------------------------------------------------------
32class KACTUS2_API LibraryTreeModel : public QAbstractItemModel
33{
34 Q_OBJECT
35
36public:
37
44 LibraryTreeModel(LibraryInterface* handler, QObject* parent = 0);
45
48
57 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
58
65 virtual int columnCount(QModelIndex const& parent = QModelIndex()) const;
66
73 virtual int rowCount(QModelIndex const& parent = QModelIndex()) const;
74
83 virtual QModelIndex index(int row, int column, QModelIndex const& parent = QModelIndex()) const;
84
91 virtual QModelIndex parent(QModelIndex const& child) const;
92
100 virtual QVariant data(QModelIndex const& index, int role = Qt::DisplayRole) const;
101
108 virtual bool hasChildren(QModelIndex const& parent = QModelIndex()) const;
109
116 Qt::ItemFlags flags(QModelIndex const& index) const;
117
123
130 QModelIndex index(LibraryItem* item);
131
132signals:
133
135 void errorMessage(const QString& message);
136
138 void noticeMessage(const QString& message);
139
141 void openDesign(VLNV const& vlnv, QString const& viewName);
142
144 void openSWDesign(VLNV const& vlnv);
145
147 void openSystemDesign(VLNV const& vlnv);
148
150 void openMemoryDesign(VLNV const& vlnv, QString const& viewName);
151
153 void editItem(VLNV const& vlnv);
154
156 void createAbsDef(VLNV const& vlnv);
157
159 void createDesign(VLNV const& vlnv);
160
162 void createSWDesign(VLNV const& vlnv);
163
165 void createSystemDesign(VLNV const& vlnv);
166
168 void removeVLNV(QList<VLNV> vlnvs);
169
171 void exportItems(const QList<VLNV> list);
172
174 void showErrors(VLNV const& vlnv);
175
178
179public slots:
180
182 void onOpenDesign(QModelIndex const& index, QString const& viewName);
183
185 void onOpenMemoryDesign(QModelIndex const& index, QString const& viewName);
186
188 void onOpenSWDesign(QModelIndex const& index);
189
191 void onOpenSystemDesign(QModelIndex const& index);
192
194 void onOpenDocument(QModelIndex const& index);
195
197 void onCreateNewDesign(QModelIndex const& index);
198
200 void onCreateNewSWDesign(QModelIndex const& index);
201
203 void onCreateNewSystemDesign(QModelIndex const& index);
204
206 void onDeleteItem(QModelIndex const& index);
207
209 void onExportItem(QModelIndex const& index);
210
212 void onShowErrors(QModelIndex const& index);
213
215 void onCreateAbsDef(QModelIndex const& index);
216
218 void onRemoveVLNV(VLNV const& vlnv);
219
221 void onAddVLNV(VLNV const& vlnv);
222
225
232 void onDocumentUpdated(VLNV const& vlnv);
233
234private:
235
238
240 LibraryTreeModel& operator=(const LibraryTreeModel& other);
241
246 void removeLibraryItem(LibraryItem* toRemove);
247
255 bool validate(LibraryItem* item);
256
257 //-----------------------------------------------------------------------------
258 // Data.
259 //-----------------------------------------------------------------------------
260
265 LibraryItem* rootItem_;
266
268 LibraryInterface* handler_;
269};
270
271#endif // LIBRARYTREEMODEL_H
LibraryInterface defines an interface to operate the IP-XACT-library.
LibraryItem class is used to create the hierarchical structure of IP library.
Definition LibraryItem.h:27
void errorMessage(const QString &message)
Emit an error message to be printed to user.
void onCreateNewSWDesign(QModelIndex const &index)
Create new SW design.
void onCreateNewSystemDesign(QModelIndex const &index)
Create new system design.
void onCreateAbsDef(QModelIndex const &index)
Create a new abstraction definition for given bus definition.
void createDesign(VLNV const &vlnv)
Create new design with given vlnv.
virtual QModelIndex parent(QModelIndex const &child) const
LibraryTreeModel(LibraryInterface *handler, QObject *parent=0)
void onCreateNewDesign(QModelIndex const &index)
Create new design.
void onDocumentUpdated(VLNV const &vlnv)
void showErrors(VLNV const &vlnv)
Shows errors about the item at the given index.
virtual ~LibraryTreeModel()
The destructor.
void onOpenSystemDesign(QModelIndex const &index)
Open the selected hierarchical system design.
void exportItems(const QList< VLNV > list)
Export a list of vlnv items to a new location.
QModelIndex index(LibraryItem *item)
virtual bool hasChildren(QModelIndex const &parent=QModelIndex()) const
void openSWDesign(VLNV const &vlnv)
Open the SW design of a component.
void createSWDesign(VLNV const &vlnv)
Create new SW design with given vlnv.
void noticeMessage(const QString &message)
Emit a notice message to be printed to user.
void onResetModel()
Reset the model.
virtual int columnCount(QModelIndex const &parent=QModelIndex()) const
virtual QModelIndex index(int row, int column, QModelIndex const &parent=QModelIndex()) const
void openSystemDesign(VLNV const &vlnv)
Open the system design of a component.
void editItem(VLNV const &vlnv)
Open the component in a component editor.
void onExportItem(QModelIndex const &index)
When export is selected in search view.
void onAddVLNV(VLNV const &vlnv)
Add the specified vlnv branch to the tree.
void createAbsDef(VLNV const &vlnv)
Create a new abstraction definition for given bus definition.
void onOpenSWDesign(QModelIndex const &index)
Open the selected hierarchical SW design.
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
void onOpenDocument(QModelIndex const &index)
Open the selected document e.g. component or bus definition.
void onRemoveVLNV(VLNV const &vlnv)
Remove the specified vlnv branch from the tree.
virtual QVariant data(QModelIndex const &index, int role=Qt::DisplayRole) const
void onDeleteItem(QModelIndex const &index)
When delete is selected in search view.
void removeVLNV(QList< VLNV > vlnvs)
Remove the specified VLNV from the library.
void onOpenDesign(QModelIndex const &index, QString const &viewName)
Open the selected hierarchical design.
void openDesign(VLNV const &vlnv, QString const &viewName)
Open the design of a component.
Qt::ItemFlags flags(QModelIndex const &index) const
void openMemoryDesign(VLNV const &vlnv, QString const &viewName)
Open the memory design of a HW design.
LibraryItem * getRoot() const
virtual int rowCount(QModelIndex const &parent=QModelIndex()) const
void createSystemDesign(VLNV const &vlnv)
Create new system design with given vlnv.
void onOpenMemoryDesign(QModelIndex const &index, QString const &viewName)
Open the selected memory design.
void invalidateFilter()
Refresh the item filtering because changes have been made.
void onShowErrors(QModelIndex const &index)
Shows errors about the item at the given index.