Tree.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef GUI_TREE_H
00025 #define GUI_TREE_H
00026
00027 #include <QTreeWidget>
00028
00029 #include <App/Document.h>
00030 #include <App/Application.h>
00031
00032 #include <Gui/DockWindow.h>
00033 #include <Gui/Selection.h>
00034
00035 namespace Gui {
00036
00037 class ViewProviderDocumentObject;
00038 class DocumentObjectItem;
00039 class DocumentItem;
00040
00044 class TreeWidget : public QTreeWidget, public SelectionObserver
00045 {
00046 Q_OBJECT
00047
00048 public:
00049 TreeWidget(QWidget* parent=0);
00050 ~TreeWidget();
00051
00052 void scrollItemToTop(Gui::Document*);
00053 void setItemsSelected (const QList<QTreeWidgetItem *> items, bool select);
00054
00055 static const int DocumentType;
00056 static const int ObjectType;
00057
00058 protected:
00060 void onSelectionChanged(const SelectionChanges& msg);
00061 void contextMenuEvent (QContextMenuEvent * e);
00062 void drawRow(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const;
00063 bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data,
00064 Qt::DropAction action);
00065 Qt::DropActions supportedDropActions () const;
00066 QMimeData * mimeData (const QList<QTreeWidgetItem *> items) const;
00067 void dragMoveEvent(QDragMoveEvent *event);
00068 void dropEvent(QDropEvent *event);
00069 void mouseDoubleClickEvent(QMouseEvent * event);
00070
00071 protected Q_SLOTS:
00072 void onCreateGroup();
00073 void onRelabelObject();
00074 void onActivateDocument(QAction*);
00075 void onStartEditing();
00076 void onFinishEditing();
00077
00078 private Q_SLOTS:
00079 void onItemSelectionChanged(void);
00080 void onItemEntered(QTreeWidgetItem * item);
00081 void onTestStatus(void);
00082
00083 private:
00084 void slotNewDocument(const Gui::Document&);
00085 void slotDeleteDocument(const Gui::Document&);
00086 void slotRenameDocument(const Gui::Document&);
00087 void slotActiveDocument(const Gui::Document&);
00088 void slotRelabelDocument(const Gui::Document&);
00089
00090 void changeEvent(QEvent *e);
00091
00092 private:
00093 QAction* createGroupAction;
00094 QAction* relabelObjectAction;
00095 QAction* finishEditingAction;
00096 QTreeWidgetItem* contextItem;
00097
00098 QTreeWidgetItem* rootItem;
00099 QTimer* statusTimer;
00100 static QPixmap* documentPixmap;
00101 std::map<const Gui::Document*,DocumentItem*> DocumentMap;
00102 bool fromOutside;
00103 };
00104
00110 class DocumentItem : public QTreeWidgetItem
00111 {
00112 public:
00113 DocumentItem(const Gui::Document* doc, QTreeWidgetItem * parent);
00114 ~DocumentItem();
00115
00116 const Gui::Document* document() const;
00117 void setObjectHighlighted(const char*, bool);
00118 void setObjectSelected(const char*, bool);
00119 void clearSelection(void);
00120 void updateSelection(void);
00121 void selectItems(void);
00122 void testStatus(void);
00123 void setData(int column, int role, const QVariant & value);
00124
00125 protected:
00129 void slotNewObject(const Gui::ViewProviderDocumentObject&);
00133 void slotDeleteObject(const Gui::ViewProviderDocumentObject&);
00134 void slotChangeObject(const Gui::ViewProviderDocumentObject&);
00135 void slotRenameObject(const Gui::ViewProviderDocumentObject&);
00136 void slotActiveObject(const Gui::ViewProviderDocumentObject&);
00137 void slotInEdit (const Gui::ViewProviderDocumentObject&);
00138 void slotResetEdit (const Gui::ViewProviderDocumentObject&);
00139
00140 private:
00141 const Gui::Document* pDocument;
00142 std::map<std::string,DocumentObjectItem*> ObjectMap;
00143 };
00144
00150 class DocumentObjectItem : public QTreeWidgetItem
00151 {
00152 public:
00153 DocumentObjectItem(Gui::ViewProviderDocumentObject* pcViewProvider, QTreeWidgetItem * parent);
00154 ~DocumentObjectItem();
00155
00156 Gui::ViewProviderDocumentObject* object() const;
00157 void testStatus();
00158 void displayStatusInfo();
00159 void setData(int column, int role, const QVariant & value);
00160
00161 protected:
00162 void slotChangeIcon();
00163 void slotChangeToolTip(const QString&);
00164 void slotChangeStatusTip(const QString&);
00165
00166 private:
00167 typedef boost::BOOST_SIGNALS_NAMESPACE::connection Connection;
00168 int previousStatus;
00169 Gui::ViewProviderDocumentObject* viewObject;
00170 Connection connectIcon;
00171 Connection connectTool;
00172 Connection connectStat;
00173
00174 friend class TreeWidget;
00175 };
00176
00181 class TreeDockWidget : public Gui::DockWindow
00182 {
00183 Q_OBJECT
00184
00185 public:
00186 TreeDockWidget(Gui::Document* pcDocument,QWidget *parent=0);
00187 ~TreeDockWidget();
00188
00189 private:
00190 QTreeWidget* treeWidget;
00191 };
00192
00193 }
00194
00195
00196 #endif // GUI_TREE_H
00197