summaryrefslogtreecommitdiffstats
path: root/tdecachegrind/tdecachegrind/toplevel.h
blob: 10e7cde5ec9e6c9a4f4eabb3c0888795af481110 (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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/* This file is part of KCachegrind.
   Copyright (C) 2002, 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>

   KCachegrind 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, version 2.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

/*
 * KCachegrind top level window
 */

#ifndef TOPLEVEL_H
#define TOPLEVEL_H

#include <tqdatetime.h>

#include <dcopobject.h>
#include <kmainwindow.h>

#include "traceitemview.h"
#include "tracedata.h"

class MultiView;
class TQLineEdit;
class TQDockWidget;
class TQLabel;
class TQProgressBar;
class TQPopupMenu;

class KURL;
class KSelectAction;
class KToggleAction;
class KToolBarPopupAction;

class TraceData;
class KRecentFilesAction;
class MainWidget;
class PartSelection;
class FunctionSelection;
class DumpSelection;
class StackSelection;
class TraceFunction;

class TopLevel : public KMainWindow, public DCOPObject
{
  Q_OBJECT
  TQ_OBJECT

public:
  TopLevel(const char *name = 0);
  ~TopLevel();

  TraceData* data() { return _data; }
  void setData(TraceData*);

  virtual void saveProperties(KConfig*);
  virtual void readProperties(KConfig*);

  void createActions();
  void createDocks();

  TraceItem::CostType groupType() { return _groupType; }
  TraceCostType* costType() { return _costType; }
  TraceCostType* costType2() { return _costType2; }
  TracePartList activeParts() { return _activeParts; }
  TracePartList hiddenParts() { return _hiddenParts; }

  // current config
  bool showPercentage() const { return _showPercentage; }
  bool showExpanded() const { return _showExpanded; }
  bool showCycles() const { return _showCycles; }

  /* convenience functions for often used context menu items */
  void addCostMenu(TQPopupMenu*,bool);
  void addGoMenu(TQPopupMenu*);

public slots:
  void newTrace();
  void loadTrace();
  void loadTrace(const KURL&);
  void loadTrace(TQString);
  void addTrace();
  void addTrace(const KURL&);
  void addTrace(TQString);

  // for quick showing the main window...
  void loadDelayed(TQString);

  void reload();
  void exportGraph();
  void newWindow();
  void configure();
  void querySlot();
  void dummySlot();

  // layouts
  void layoutDuplicate();
  void layoutRemove();
  void layoutNext();
  void layoutPrevious();
  void layoutSave();
  void layoutRestore();
  void updateLayoutActions();

  void updateStatusBar();
  void costTypeSelected(const TQString&);
  void costType2Selected(const TQString&);
  void groupTypeSelected(int);
  void splitSlot();
  void splitDirSlot();
  void configureToolbars();
  void configureKeys();
  bool queryExit();
  bool queryClose();
  void togglePartDock();
  void toggleStackDock();
  void toggleFunctionDock();
  void toggleDumpDock();
  void toggleStatusBar();
  void partVisibilityChanged(bool);
  void dumpVisibilityChanged(bool);
  void stackVisibilityChanged(bool);
  void functionVisibilityChanged(bool);
  void togglePercentage();
  void setPercentage(bool);
  void setAbsoluteCost();
  void setRelativeCost();
  void toggleExpanded();
  void toggleCycles();
  void forceTrace();
  void forceTraceReload();
  void forwardAboutToShow();
  void backAboutToShow();
  void upAboutToShow();
  void forwardActivated(int);
  void backActivated(int);
  void upActivated(int);

  bool setCostType(TraceCostType*);
  bool setCostType2(TraceCostType*);
  bool setCostType(TQString);
  bool setCostType2(TQString);
  bool setCostType(int);
  bool setCostType2(int);
  bool setGroupType(TraceItem::CostType);
  bool setGroupType(TQString);
  bool setGroup(TraceCostItem*);
  bool setGroup(TQString);
  bool setFunction(TraceFunction*);
  bool setFunction(TQString);
  void activePartsChangedSlot(const TracePartList& list);
  void partsHideSelectedSlot();
  void partsUnhideAllSlot();

  /* These go back to mainloop first by using a timer.
   * So they can be called from event handlers that
   * aren't allowed to delete list entries.
   */
  void setCostTypeDelayed(TraceCostType*);
  void setCostType2Delayed(TraceCostType*);
  void setGroupTypeDelayed(TraceItem::CostType);
  void setGroupDelayed(TraceCostItem*);
  void setTraceItemDelayed(TraceItem*);
  void partsHideSelectedSlotDelayed();
  void partsUnhideAllSlotDelayed();
  void goBack();
  void goForward();
  void goUp();
  void setDirectionDelayed(TraceItemView::Direction);

  /* SingleShot Slots (without parameters) for the delayed versions */
  void setCostTypeDelayed();
  void setCostType2Delayed();
  void setGroupTypeDelayed();
  void setGroupDelayed();
  void setTraceItemDelayed();
  void loadTraceDelayed();
  void setDirectionDelayed();

  // configuration has changed
  void configChanged();

  //void refresh();
  void slotShowTipOnStart();
  void slotShowTip();

  // progress in status bar, empty message disables progress display
  void showStatus(TQString msg, int progress);
  void showMessage(const TQString&, int msec);

private:
  void init();
  void createLayoutActions();
  void createMiscActions();
  void setupMainWidget(MainWidget*);
  void setupPartSelection(PartSelection*);
  void restoreCurrentState(TQString postfix);
  void saveCurrentState(TQString postfix);
  void saveTraceSettings();
  TQString traceKey();
  void restoreTraceTypes();
  void restoreTraceSettings();

  KStatusBar* _statusbar;
  TQLabel* _statusLabel;
  KRecentFilesAction* _openRecent;
  bool _twoMainWidgets;
  Qt::Orientation _spOrientation;

  MultiView* _multiView;
  FunctionSelection* _functionSelection;
  DumpSelection* _dumpSelection;
  PartSelection* _partSelection;
  StackSelection* _stackSelection;
  TQLineEdit* queryLineEdit;

  TQDockWindow *_partDock, *_stackDock, *_functionDock, *_dumpDock;
  bool _forcePartDock;

  KSelectAction *_saCost, *_saCost2, *saGroup;
  KToggleAction *_partDockShown, *_stackDockShown;
  KToggleAction *_functionDockShown, *_dumpDockShown;
  KToggleAction *_taPercentage, *_taExpanded, *_taCycles;
  KToggleAction *_taDump, *_taSplit, *_taSplitDir;
  KToolBarPopupAction *_paForward, *_paBack, *_paUp;

  TraceFunction* _function;
  const TQObject* _lastSender;

  // trace data shown in this window
  TraceData* _data;
  // subcost types used for visualisation
  TraceCostType* _costType;
  TraceCostType* _costType2;
  // grouping of function list
  TraceItem::CostType _groupType;
  // selected group
  TraceCostItem* _group;
  // selected parts
  TracePartList _activeParts;
  // hidden parts
  TracePartList _hiddenParts;
  // layouts
  int _layoutCurrent, _layoutCount;

  // for delayed slots
  TraceCostType* _costTypeDelayed;
  TraceCostType* _costType2Delayed;
  TraceItem::CostType _groupTypeDelayed;
  TraceCostItem* _groupDelayed;
  TraceItem* _traceItemDelayed;
  TQString _loadTraceDelayed;
  TraceItemView::Direction _directionDelayed;

  // for status progress display
  TQString _progressMsg;
  TQTime _progressStart;
  TQProgressBar* _progressBar;

  // toplevel configuration options
  bool _showPercentage, _showExpanded, _showCycles;
};

#endif