summaryrefslogtreecommitdiffstats
path: root/kpovmodeler/pmdialogview.h
blob: d4e2f47a8435090165d85a676cdebd9d46041a6d (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
//-*-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 PMDIALOGEDITVIEW_H
#define PMDIALOGEDITVIEW_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <tqwidget.h>
#include <tqscrollview.h>
#include <kpushbutton.h>

#include "pmviewbase.h"
#include "pmviewfactory.h"

class PMDialogEditBase;
class PMObject;
class PMPart;
class TQGroupBox;
class TQBoxLayout;
class TQLabel;

/**
 * Helper class for @ref PMDialogView
 */
class PMDialogEditContent : public TQScrollView
{
   Q_OBJECT
  TQ_OBJECT
public:
   PMDialogEditContent( TQWidget* parent, const char* name = 0 );
   void setContents( TQWidget* wid );
   void calculateSize( );
protected:
   void resizeEvent( TQResizeEvent* );
private:
   TQWidget* m_pContents;
};

/**
 * View to display and modify attributes of objects.
 *
 * This class creates the corresponding widget
 * (subclass of @ref PMDialogEditBase) for the active object and
 * displays it.
 */
class PMDialogView : public PMViewBase
{
   Q_OBJECT
  TQ_OBJECT
public:
   /**
    * Creates a new PMDialogView widget
    */
   PMDialogView( PMPart* part, TQWidget* parent, const char* name = 0 );
   /**
    * Deletes the widget
    */
   ~PMDialogView( );

   /** */
   virtual TQString viewType( ) const { return TQString( "dialogview" ); }
   /** */
   virtual TQString description( ) const;

public slots:
   /**
    * Called when an object is changed.
    * Mode is a bit combination of @ref PMChange constants
    */
   void slotObjectChanged( PMObject* obj, const int mode, TQObject* sender );
   /**
    * Called before the scene is rendered
    */
   void slotAboutToRender( );
   /**
    * Called when the whole documents contents have changed
    */
   void slotRefresh( );
   /**
    * Clears all data
    */
   void slotClear( );
signals:
   /**
    * Signal that is emitted when an object is changed.
    * Mode is a bit combination of @ref PMChange constants.
    */
   void objectChanged( PMObject* obj, const int mode, TQObject* sender );
   /**
    * Emitted in the destructor
    */
   void destroyed( PMDialogView* v );

protected:
   virtual void keyPressEvent( TQKeyEvent* );

private slots:
   void slotApply( );
   void slotHelp( );
   void slotCancel( );
   void slotDataChanged( );
   void slotSizeChanged( );
   void slotControlPointSelectionChanged( );

private:
   /**
    * Asks the user to save unsaved data in the displayed widget
    */
   bool shouldSaveData( );
   /**
    * Displays the object
    */
   void displayObject( PMObject* obj, bool updateDescription = true );

   PMDialogEditBase* m_pDisplayedWidget;
   TQBoxLayout* m_pLayout;

   KPushButton* m_pApplyButton;
   KPushButton* m_pCancelButton;
   KPushButton* m_pHelpButton;

   TQLabel* m_pPixmapLabel;
   TQLabel* m_pObjectTypeLabel;

   PMDialogEditContent* m_pHelper;

   bool m_unsavedData;
   PMPart* m_pPart;
};

/**
 * Factory class for dialog views
 */
class PMDialogViewFactory : public PMViewTypeFactory
{
public:
   PMDialogViewFactory( ) { }
   virtual TQString viewType( ) const { return TQString( "dialogview" ); }
   virtual TQString description( ) const;
   virtual TQString iconName( ) const { return TQString( "pmdialogview" ); }
   virtual PMViewBase* newInstance( TQWidget* parent, PMPart* part ) const
   {
      return new PMDialogView( part, parent );
   }
};

#endif