| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2010 Werner Mayer <wmayer[at]users.sourceforge.net> * |
| 3 |
* * |
| 4 |
* This file is part of the FreeCAD CAx development system. * |
| 5 |
* * |
| 6 |
* This library is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Library General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 |
* GNU Library General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Library General Public * |
| 17 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 18 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 19 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 20 |
* * |
| 21 |
***************************************************************************/ |
| 22 |
|
| 23 |
|
| 24 |
#ifndef GUI_DOCUMENTMODEL_H |
| 25 |
#define GUI_DOCUMENTMODEL_H |
| 26 |
|
| 27 |
#include <QAbstractItemModel> |
| 28 |
#include <vector> |
| 29 |
|
| 30 |
|
| 31 |
namespace App |
| 32 |
{ |
| 33 |
class Property; |
| 34 |
} |
| 35 |
namespace Gui |
| 36 |
{ |
| 37 |
class Document; |
| 38 |
class ViewProviderDocumentObject; |
| 39 |
|
| 40 |
class DocumentModel: public QAbstractItemModel |
| 41 |
{ |
| 42 |
public: |
| 43 |
explicit DocumentModel(QObject* parent); |
| 44 |
~DocumentModel() override; |
| 45 |
|
| 46 |
int columnCount(const QModelIndex& parent = QModelIndex()) const override; |
| 47 |
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; |
| 48 |
bool setData(const QModelIndex& idx, const QVariant& value, int role) override; |
| 49 |
Qt::ItemFlags flags(const QModelIndex& index) const override; |
| 50 |
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; |
| 51 |
QModelIndex parent(const QModelIndex& index) const override; |
| 52 |
int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
| 53 |
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; |
| 54 |
bool setHeaderData( |
| 55 |
int section, |
| 56 |
Qt::Orientation orientation, |
| 57 |
const QVariant& value, |
| 58 |
int role = Qt::EditRole |
| 59 |
) override; |
| 60 |
|
| 61 |
private: |
| 62 |
void slotNewDocument(const Gui::Document&); |
| 63 |
void slotDeleteDocument(const Gui::Document&); |
| 64 |
void slotRenameDocument(const Gui::Document&); |
| 65 |
void slotActiveDocument(const Gui::Document&); |
| 66 |
void slotRelabelDocument(const Gui::Document&); |
| 67 |
void slotInEdit(const Gui::ViewProviderDocumentObject& v); |
| 68 |
void slotResetEdit(const Gui::ViewProviderDocumentObject& v); |
| 69 |
void slotNewObject(const Gui::ViewProviderDocumentObject& obj); |
| 70 |
void slotDeleteObject(const Gui::ViewProviderDocumentObject& obj); |
| 71 |
void slotChangeObject(const Gui::ViewProviderDocumentObject& obj, const App::Property& Prop); |
| 72 |
void slotRenameObject(const Gui::ViewProviderDocumentObject& obj); |
| 73 |
void slotActiveObject(const Gui::ViewProviderDocumentObject& obj); |
| 74 |
|
| 75 |
const Document* getDocument(const QModelIndex&) const; |
| 76 |
bool isPropertyLink(const App::Property&) const; |
| 77 |
std::vector<ViewProviderDocumentObject*> claimChildren( |
| 78 |
const Document&, |
| 79 |
const ViewProviderDocumentObject& |
| 80 |
) const; |
| 81 |
|
| 82 |
private: |
| 83 |
struct DocumentModelP* d; |
| 84 |
}; |
| 85 |
|
| 86 |
} // namespace Gui |
| 87 |
|
| 88 |
|
| 89 |
#endif // GUI_DOCUMENTMODEL_H |