1 #ifndef WORKSPACEQTMODEL_H_INCLUDED
2 #define WORKSPACEQTMODEL_H_INCLUDED
26 #include <QAbstractItemModel>
27 #include <boost/property_tree/ptree.hpp>
39 using namespace Ws::Event;
54 static std::shared_ptr<WorkspaceQtModel>
55 Create(
const std::shared_ptr<IWorkspace>&,
62 virtual int columnCount(QModelIndex
const& parent = QModelIndex())
const;
63 virtual QVariant data(QModelIndex
const& index,
int role = Qt::DisplayRole)
const;
64 virtual Qt::ItemFlags flags(QModelIndex
const& index)
const;
65 virtual QVariant headerData(
int section, Qt::Orientation,
int role)
const;
66 virtual QModelIndex index(
int row,
int column, QModelIndex
const& parent = QModelIndex())
const;
67 virtual bool insertRow(
int row, QModelIndex
const& parent = QModelIndex());
68 virtual bool insertRows(
int row,
int count, QModelIndex
const& parent = QModelIndex());
69 virtual QModelIndex parent(QModelIndex
const& index)
const;
70 virtual bool removeRow(
int row, QModelIndex
const& parent = QModelIndex());
71 virtual bool removeRows(
int row,
int count, QModelIndex
const& parent = QModelIndex());
72 virtual int rowCount(QModelIndex
const& parent = QModelIndex())
const;
74 enum ItemType { RootType, ProjectType, FileType };
87 bool Close(
const QModelIndex& index);
96 std::vector<QAction*> GetContextMenuActions(
const QModelIndex& index)
const;
106 const std::string& GetName(QModelIndex
const& index)
const;
116 ItemType GetType(QModelIndex
const& index)
const;
118 bool IsOpened(
const QModelIndex& index)
const;
120 bool Open(
const QModelIndex& index);
122 std::shared_ptr<IWorkspace>
Workspace() {
return m_workspace; }
146 : type(RootType), row(0), workspace() {}
148 Item(
int r,
const std::string& name,
const std::shared_ptr<IProject>& obj)
149 : type(ProjectType), row(r), project({name, obj, {}}) {}
151 Item(
int r,
const std::string& name, Item* parent,
const std::shared_ptr<IFile>& obj)
152 : type(FileType), row(r), file({name, parent, obj}) {}
155 std::vector<Item*> children;
159 std::shared_ptr<IProject> obj;
160 std::vector<Item*> children;
165 std::shared_ptr<IFile> obj;
177 for (
auto child : workspace.children)
181 for (
auto child : project.children)
192 void ListenWorkspaceEvent(
const Ws::Event::WorkspaceChanged&);
195 void ListenProjectEvent(Item* project_item,
const Ws::Event::ProjectChanged&);
197 int FindProjectRow(
const std::string& name);
198 int FindProjectRowInsert(IWorkspace::ConstProjectIterator);
199 int FindFileRow(Item* project_item,
const std::string& name);
200 int FindFileRowInsert(Item* project_item, IProject::ConstFileIterator);
203 std::shared_ptr<IWorkspace> m_workspace;
205 Controller::ProjectController* m_project_controller;
211 #endif // end_of_inclde_guard
see the online Qt documentation
Interface for IWorkspace.
Abstraction of workspace on file system.
ProjectController header.
see the online Qt documentation
Namespace for generic graphical shell for simulators.
see the online C++11 documentation
Abstraction of workspace on the filesystem.