summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmtreeview.h
blob: 445b53fdde826883ff59bcd359c68d1ff0df8fd3 (plain)
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
183
//-*-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 <tqlistview.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, TQWidget* tqparent, const char* name = 0 );
   
   /** */
   virtual TQString viewType( ) const { return TQString( "treeview" ); }
   /** */
   virtual TQString description( ) const;
};

/**
 * Widget that displays the scene as tree view
 */
class PMTreeView : public TQListView
{
   Q_OBJECT
  TQ_OBJECT
   friend class PMTreeViewItem;
public:
   /**
    * Creates a PMTreeView with tqparent and name that displays the
    * document doc
    */
   PMTreeView( PMPart* part, TQWidget* tqparent = 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, TQObject* 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, TQObject* sender );
   /**
    * Emitted in the destructor
    */
   void destroyed( PMTreeView* v );
   
protected:
   void contentsMousePressEvent( TQMouseEvent * e );
   void contentsMouseMoveEvent( TQMouseEvent * e );
   void itemSelected( PMTreeViewItem* item, bool selected );
   
   void viewportMousePressEvent( TQMouseEvent * e );
   void viewportMouseReleaseEvent( TQMouseEvent* e );
   void viewportMouseMoveEvent( TQMouseEvent* e );
   
   void viewportDragMoveEvent( TQDragMoveEvent *e );
   void viewportDragEnterEvent( TQDragEnterEvent *e );
   void viewportDragLeaveEvent( TQDragLeaveEvent* e );
   void viewportDropEvent( TQDropEvent* e );

   void focusOutEvent( TQFocusEvent* e );
   void focusInEvent( TQFocusEvent* e );
   
   void keyPressEvent( TQKeyEvent* 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( TQListViewItem* item );
   /**
    * Returns true if the drop target is a tree view for the same part
    */
   bool targetDisplaysPart( TQWidget* target );
   
   /**
    * the displayed document
    */
   PMPart* m_pPart;
   
   /**
    * the selected items
    */
//   TQPtrList<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;
//   TQStringList m_lstDropFormats;

   // for drag and drop, copied from KonqBaseListViewWidget
   bool m_pressed;
   TQPoint m_pressedPos;
   PMTreeViewItem* m_pressedItem;
};

/**
 * Factory class for the tree view
 */
class PMTreeViewFactory : public PMViewTypeFactory
{
public:
   PMTreeViewFactory( ) { }
   virtual TQString viewType( ) const { return TQString( "treeview" ); }
   virtual TQString description( ) const;
   virtual TQString iconName( ) const { return TQString( "pmtreeview" ); }
   virtual PMViewBase* newInstance( TQWidget* tqparent, PMPart* part ) const
   {
      return new PMTreeViewWidget( part, tqparent );
   }
};

#endif