Kactus2
Kactus2 reference guide
Loading...
Searching...
No Matches
LibraryModel.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 LIBRARYMODEL_H
13#define LIBRARYMODEL_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 LibraryModel : public QAbstractItemModel
33{
34 Q_OBJECT
35
36public:
37
44 LibraryModel(LibraryInterface* handler, QObject* parent = 0);
45
47 virtual ~LibraryModel();
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, QString const& viewName);
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, QString const& viewName);
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
234protected:
235
238
239private:
240
242 LibraryModel(const LibraryModel& other);
243
245 LibraryModel& operator=(const LibraryModel& other);
246
251 void removeLibraryItem(LibraryItem* toRemove);
252
260 bool validate(LibraryItem* item);
261
262 //-----------------------------------------------------------------------------
263 // Data.
264 //-----------------------------------------------------------------------------
265
270 LibraryItem* rootItem_;
271
272};
273
274#endif // LIBRARYMODEL_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 onShowErrors(QModelIndex const &index)
Shows errors about the item at the given index.
LibraryModel(LibraryInterface *handler, QObject *parent=0)
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
void onRemoveVLNV(VLNV const &vlnv)
Remove the specified vlnv branch from the tree.
void onCreateAbsDef(QModelIndex const &index)
Create a new abstraction definition for given bus definition.
void invalidateFilter()
Refresh the item filtering because changes have been made.
void onOpenDesign(QModelIndex const &index, QString const &viewName)
Open the selected hierarchical design.
void onExportItem(QModelIndex const &index)
When export is selected in search view.
void createSystemDesign(VLNV const &vlnv)
Create new system design with given vlnv.
virtual ~LibraryModel()
The destructor.
void onOpenSWDesign(QModelIndex const &index)
Open the selected hierarchical SW design.
void onDeleteItem(QModelIndex const &index)
When delete is selected in search view.
void onAddVLNV(VLNV const &vlnv)
Add the specified vlnv branch to the tree.
void noticeMessage(const QString &message)
Emit a notice message to be printed to user.
void exportItems(const QList< VLNV > list)
Export a list of vlnv items to a new location.
void openMemoryDesign(VLNV const &vlnv, QString const &viewName)
Open the memory design of a HW design.
void openSWDesign(VLNV const &vlnv)
Open the SW design of a component.
void editItem(VLNV const &vlnv)
Open the component in a component editor.
void onCreateNewSWDesign(QModelIndex const &index)
Create new SW design.
void openSystemDesign(VLNV const &vlnv, QString const &viewName)
Open the system design of a component.
virtual int columnCount(QModelIndex const &parent=QModelIndex()) const
void onOpenMemoryDesign(QModelIndex const &index, QString const &viewName)
Open the selected memory design.
void removeVLNV(QList< VLNV > vlnvs)
Remove the specified VLNV from the library.
virtual bool hasChildren(QModelIndex const &parent=QModelIndex()) const
void openDesign(VLNV const &vlnv, QString const &viewName)
Open the design of a component.
LibraryInterface * handler_
The instance that manages the library.
void onOpenSystemDesign(QModelIndex const &index, QString const &viewName)
Open the selected hierarchical system design.
virtual QModelIndex parent(QModelIndex const &child) const
void onDocumentUpdated(VLNV const &vlnv)
void createDesign(VLNV const &vlnv)
Create new design with given vlnv.
void errorMessage(const QString &message)
Emit an error message to be printed to user.
void onOpenDocument(QModelIndex const &index)
Open the selected document e.g. component or bus definition.
void onResetModel()
Reset the model.
virtual QModelIndex index(int row, int column, QModelIndex const &parent=QModelIndex()) const
virtual QVariant data(QModelIndex const &index, int role=Qt::DisplayRole) const
LibraryItem * getRoot() const
void createSWDesign(VLNV const &vlnv)
Create new SW design with given vlnv.
QModelIndex index(LibraryItem *item)
void showErrors(VLNV const &vlnv)
Shows errors about the item at the given index.
void createAbsDef(VLNV const &vlnv)
Create a new abstraction definition for given bus definition.
void onCreateNewDesign(QModelIndex const &index)
Create new design.
virtual int rowCount(QModelIndex const &parent=QModelIndex()) const
Qt::ItemFlags flags(QModelIndex const &index) const
void onCreateNewSystemDesign(QModelIndex const &index)
Create new system design.