1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
//-*-C++-*-
/*
**************************************************************************
description
--------------------
copyright : (C) 2000-2003 by Andreas Zehender
email : zehender@kde.org
**************************************************************************
**************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
**************************************************************************/
#ifndef PMTREEVIEW_H
#define PMTREEVIEW_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <qlistview.h>
#include "pmobject.h"
#include "pmviewbase.h"
#include "pmviewfactory.h"
class PMTreeViewItem;
class PMPart;
/**
* Wrapper class for the treeview/dock widget
*/
class PMTreeViewWidget : public PMViewBase
{
public:
/**
* Default constructor
*/
PMTreeViewWidget( PMPart* pare, QWidget* parent, const char* name = 0 );
/** */
virtual QString viewType( ) const { return QString( "treeview" ); }
/** */
virtual QString description( ) const;
};
/**
* Widget that displays the scene as tree view
*/
class PMTreeView : public QListView
{
Q_OBJECT
friend class PMTreeViewItem;
public:
/**
* Creates a PMTreeView with parent and name that displays the
* document doc
*/
PMTreeView( PMPart* part, QWidget* parent = 0, const char* name = 0 );
/**
* Deletes the PMTreeView
*/
~PMTreeView( );
/**
* Returns true PMTreeViewItem::setSelected should be accepted
*/
bool acceptSelect( ) const { return m_acceptSelect; }
/**
* Returns the connected part
*/
PMPart* part( ) const { return m_pPart; }
public slots:
/**
* Called when an object is changed.
* @see PMPart::objectChanged( ) */
void slotObjectChanged( PMObject* obj, const int mode, QObject* sender );
/**
* Refreshes the whole csg tree
*/
void slotRefresh( );
/**
* Clears all data
*/
void slotClear( );
signals:
/**
* Emitted, when an object is selected or deselected
*/
void objectChanged( PMObject* obj, const int mode, QObject* sender );
/**
* Emitted in the destructor
*/
void destroyed( PMTreeView* v );
protected:
void contentsMousePressEvent( QMouseEvent * e );
void contentsMouseMoveEvent( QMouseEvent * e );
void itemSelected( PMTreeViewItem* item, bool selected );
void viewportMousePressEvent( QMouseEvent * e );
void viewportMouseReleaseEvent( QMouseEvent* e );
void viewportMouseMoveEvent( QMouseEvent* e );
void viewportDragMoveEvent( QDragMoveEvent *e );
void viewportDragEnterEvent( QDragEnterEvent *e );
void viewportDragLeaveEvent( QDragLeaveEvent* e );
void viewportDropEvent( QDropEvent* e );
void focusOutEvent( QFocusEvent* e );
void focusInEvent( QFocusEvent* e );
void keyPressEvent( QKeyEvent* e );
private:
/**
* Adds child items of item to the tree view
*/
void addChildItems( PMTreeViewItem* item );
/**
* Returns the ListViewItem connected with the PMObject obj
*/
PMTreeViewItem* findObject( const PMObject* obj );
/**
* Selects the item. Expands the tree if necessary
*/
void selectItem( QListViewItem* item );
/**
* Returns true if the drop target is a tree view for the same part
*/
bool targetDisplaysPart( QWidget* target );
/**
* the displayed document
*/
PMPart* m_pPart;
/**
* the selected items
*/
// QPtrList<PMTreeViewItem> m_selectedItems;
PMTreeViewItem* m_pLastSelected;
bool m_itemSelected;
bool m_itemDeselected;
bool m_selectionCleared;
bool m_event;
bool m_acceptSelect;
bool m_selectOnReleaseEvent;
PMTreeViewItem* m_pDragOverItem;
// QStringList m_lstDropFormats;
// for drag and drop, copied from KonqBaseListViewWidget
bool m_pressed;
QPoint m_pressedPos;
PMTreeViewItem* m_pressedItem;
};
/**
* Factory class for the tree view
*/
class PMTreeViewFactory : public PMViewTypeFactory
{
public:
PMTreeViewFactory( ) { }
virtual QString viewType( ) const { return QString( "treeview" ); }
virtual QString description( ) const;
virtual QString iconName( ) const { return QString( "pmtreeview" ); }
virtual PMViewBase* newInstance( QWidget* parent, PMPart* part ) const
{
return new PMTreeViewWidget( part, parent );
}
};
#endif
|