summaryrefslogtreecommitdiffstats
path: root/kxsldbg/kxsldbgpart/xsldbginspector.cpp
blob: 9503eeae6c87af803e53fc16ade0e8a0d121a8e2 (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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/**
   File : xsldbginspector.cpp
   Author : Keith Isdale
   Date : 30th March 2002
   Description : Dialog to inspect stylesheet using xsldbg. Based on
                  file created by uic
 */

#include "xsldbginspector.h"

#include <klocale.h>

#include <tqvariant.h>
#include <tqlistbox.h>
#include <tqpushbutton.h>
#include <tqtabwidget.h>
#include <tqwidget.h>
#include <tqmime.h>
#include <tqdragobject.h>
#include <tqlayout.h>
#include <tqtooltip.h>
#include <tqwhatsthis.h>
#include <tqimage.h>
#include <tqpixmap.h>
#include <tqiconset.h>

#include <kpushbutton.h>
#include <kstdguiitem.h>
#include "xsldbgdebugger.h"
#include "xsldbgbreakpointsimpl.h"
#include "xsldbglocalvariablesimpl.h"
#include "xsldbgcallstackimpl.h"
#include "xsldbgtemplatesimpl.h"
#include "xsldbgsourcesimpl.h"
#include "xsldbgentitiesimpl.h"

static TQPixmap uic_load_pixmap_XsldbgInspector( const TQString &name )
{
    const TQMimeSource *m = TQMimeSourceFactory::defaultFactory()->data( name );
    if ( !m )
	return TQPixmap();
    TQPixmap pix;
    TQImageDrag::decode( m, pix );
    return pix;
}
/*
 *  Constructs a XsldbgInspector which is a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 *
 *  The dialog will by default be modeless, unless you set 'modal' to
 *  true to construct a modal dialog.
 */
XsldbgInspector::XsldbgInspector( XsldbgDebugger *debugger, TQWidget* parent,
				  const char* name, bool modal, WFlags fl )
    : TQDialog( parent, name, modal, fl )
{
    Q_CHECK_PTR(debugger);
    this->debugger = debugger;
    breakpointWidget = 0L;
    localWidget = 0L;
    callStackWidget = 0L;
    templateWidget = 0L;
    sourceWidget = 0L;
    entityWidget = 0L;
    if ( !name )
	setName( "XsldbgInspector" );
    resize( 597, 364 );
    setCaption( i18n( "Xsldbg Inspector" ) );
    setSizeGripEnabled( true );
    XsldbgInspectorLayout = new TQGridLayout( this, 1, 1, 11, 6,
					     "XsldbgInspectorLayout");

    tabWidget = new TQTabWidget( this, "tabWidget" );
    Q_CHECK_PTR( tabWidget );
    breakpointWidget = new XsldbgBreakpointsImpl( debugger, tabWidget );
    Q_CHECK_PTR( breakpointWidget );
    tabWidget->insertTab( breakpointWidget, i18n( "Breakpoints" ) );

    localWidget = new  XsldbgLocalVariablesImpl( debugger, tabWidget );
    Q_CHECK_PTR( localWidget );
    tabWidget->insertTab( localWidget,
	  TQIconSet( uic_load_pixmap_XsldbgInspector( "xsldbg_source.png" ) ),
	  i18n( "Variables" ) );

    callStackWidget = new  XsldbgCallStackImpl( debugger, tabWidget );
    Q_CHECK_PTR( callStackWidget );
    tabWidget->insertTab( callStackWidget,
	  TQIconSet( uic_load_pixmap_XsldbgInspector( "xsldbg_source.png" ) ),
	  i18n( "CallStack" ));

    templateWidget = new  XsldbgTemplatesImpl( debugger, tabWidget );
    Q_CHECK_PTR( templateWidget );
    tabWidget->insertTab( templateWidget,
	  TQIconSet( uic_load_pixmap_XsldbgInspector( "xsldbg_source.png" ) ),
          i18n( "Templates" ));

    sourceWidget = new  XsldbgSourcesImpl( debugger, tabWidget );
    Q_CHECK_PTR( sourceWidget );
    tabWidget->insertTab( sourceWidget,
	  TQIconSet( uic_load_pixmap_XsldbgInspector( "xsldbg_source.png" ) ),
	  i18n( "Sources" ));

    entityWidget = new  XsldbgEntitiesImpl( debugger, tabWidget );
    Q_CHECK_PTR( entityWidget );
    tabWidget->insertTab( entityWidget,
	  TQIconSet( uic_load_pixmap_XsldbgInspector( "xsldbg_data.png" ) ),
	  i18n( "Entities" ));

    XsldbgInspectorLayout->addWidget( tabWidget, 0, 1 );
    Layout1 = new TQHBoxLayout( 0, 0, 6, "Layout1");

    buttonHelp = new KPushButton( KStdGuiItem::help(), this, "buttonHelp" );
    buttonHelp->setAccel( 4144 );
    buttonHelp->setAutoDefault( true );
    Layout1->addWidget( buttonHelp );
    TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
    Layout1->addItem( spacer );

    buttonOk = new KPushButton( KStdGuiItem::ok(), this, "buttonOk" );
    buttonOk->setAccel( 0 );
    buttonOk->setAutoDefault( true );
    buttonOk->setDefault( true );
    Layout1->addWidget( buttonOk );

    buttonApply = new KPushButton( KStdGuiItem::apply(), this, "buttonApply" );
    TQToolTip::add(buttonApply, i18n("Apply changes to xsldbg after restarting execution"));
    buttonApply->setAccel( 0 );
    buttonApply->setAutoDefault( true );
    buttonApply->setDefault( true );
    Layout1->addWidget( buttonApply );

    buttonRefresh = new TQPushButton( this, "buttonRefresh" );
    buttonRefresh->setText( i18n( "&Refresh" ) );
    TQToolTip::add(buttonRefresh, i18n("Refresh values in inspectors from xsldbg"));
    buttonRefresh->setAccel( 0 );
    buttonRefresh->setAutoDefault( true );
    buttonRefresh->setDefault( true );
    Layout1->addWidget( buttonRefresh );

    buttonCancel = new KPushButton( KStdGuiItem::cancel(), this, "buttonCancel" );
    buttonCancel->setAccel( 0 );
    buttonCancel->setAutoDefault( true );
    Layout1->addWidget( buttonCancel );

    XsldbgInspectorLayout->addMultiCellLayout( Layout1, 1, 1, 0, 1 );

    // signals and slots connections
    connect( buttonOk, TQT_SIGNAL( clicked() ), this, TQT_SLOT( accept() ) );
    connect( buttonApply, TQT_SIGNAL ( clicked() ), this, TQT_SLOT ( update() ) );
    connect( buttonRefresh, TQT_SIGNAL ( clicked() ), this, TQT_SLOT ( refresh() ) );
    connect( buttonCancel, TQT_SIGNAL( clicked() ), this, TQT_SLOT( reject() ) );

    hide();
}

/*
 *  Destroys the object and frees any allocated resources
 */
XsldbgInspector::~XsldbgInspector()
{
  debugger = 0L;
  // no need to delete child widgets, TQt does it all for us
}


void XsldbgInspector::accept()
{
  TQDialog::accept();
}

void XsldbgInspector::reject()
{
  TQDialog::reject();
}


void XsldbgInspector::refresh()
{

  refreshBreakpoints();
  refreshVariables();

  if ( templateWidget != 0L)
    templateWidget->refresh();

  if ( sourceWidget != 0L)
    sourceWidget->refresh();

  if ( entityWidget != 0L)
    entityWidget->refresh();

}

void XsldbgInspector::refreshBreakpoints()
{
    if ( breakpointWidget != 0L )
      breakpointWidget->refresh();
}


void XsldbgInspector::refreshVariables()
{
    if ( localWidget != 0L )
      localWidget->refresh();

    if (callStackWidget != 0L)
      callStackWidget->refresh();
}

#include "xsldbginspector.moc"