summaryrefslogtreecommitdiffstats
path: root/tdecachegrind/tdecachegrind/tabview.h
blob: b9b402697682836c3a21a3aa7c650808056681be (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
/* This file is part of KCachegrind.
   Copyright (C) 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.
*/

/*
 * Tab View, enclosing detailed views for one trace item in
 * two tab widgets, separated by a splitter
 */

#ifndef TABVIEW_H
#define TABVIEW_H

#include <tqptrlist.h>
#include <tqwidget.h>
#include <tqtabwidget.h>
#include <tqtabbar.h>
#include <ksqueezedtextlabel.h>
#include "traceitemview.h"

class TQSplitter;
class TabView;

/**
 * Subclass of TQTabBar to enable context menu on tabs
 */
class TabBar : public TQTabBar
{
  Q_OBJECT
  TQ_OBJECT

 public:
  TabBar(TabView*, TQTabWidget* parent, const char *name = 0);
 protected:
  void mousePressEvent(TQMouseEvent *e);

 private:
  TQTabWidget* _tabWidget;
  TabView* _tabView;
};


/**
 * Own Splitter:
 * Call checkVisiblity for all TabWidget children of the splitter
 * on a MoveEvent. This typically is produced when collapsing the widget
 * inside of another splitter.
 */
class Splitter: public TQSplitter
{
  Q_OBJECT
  TQ_OBJECT

public:
  Splitter(Qt::Orientation o, TQWidget* parent = 0, const char* name = 0);
  void checkVisiblity();

protected:
  void moveEvent(TQMoveEvent *);
};


/**
 * Own TabView:
 * - A TQTabWidget able to track its visible rect via resizeEvents.
 *   This is needed to track if this widget is collapsed in a TQSplitter.
 * - Use own TabBar for context menu
 */
class TabWidget: public TQTabWidget
{
  Q_OBJECT
  TQ_OBJECT

public:

  TabWidget(TabView*, TQWidget* parent = 0,
            const char* name = 0, WFlags f = 0);

  bool hasVisibleRect() { return _hasVisibleRect; }
  void checkVisibility();

signals:
  void visibleRectChanged(TabWidget*);

protected:
  void resizeEvent(TQResizeEvent *);
  void showEvent(TQShowEvent *);
  void hideEvent(TQHideEvent *);
  void moveEvent(TQMoveEvent *);

private:
  bool _hasVisibleRect;
};



class TabView : public TQWidget, public TraceItemView
{
  Q_OBJECT
  TQ_OBJECT

public:

  TabView(TraceItemView* parentView,
          TQWidget* parent = 0, const char* name = 0);

  virtual TQWidget* widget() { return this; }
  TQString whatsThis() const ;
  void setData(TraceData*);
  bool isViewVisible() const { return !_isCollapsed; }
  void selected(TraceItemView*, TraceItem*);
  bool active() const { return _active; }
  void setActive(bool);

  /**
   * Rearrange tabs
   * if <w> == 0, move hidden tabs
   */
  void moveTab(TQWidget* w, Position, bool wholeArea = false);

  Position tabPosition(TQWidget*);
  int visibleTabs();
  int visibleAreas();

  void readViewConfig(KConfig*, TQString prefix, TQString postfix, bool);
  void saveViewConfig(KConfig*, TQString prefix, TQString postfix, bool);

public slots:
  void tabChanged(TQWidget*);
  void visibleRectChangedSlot(TabWidget*);

signals:
  void activated(TabView*);

protected:
  void resizeEvent(TQResizeEvent *);
  bool eventFilter(TQObject*, TQEvent*);
  void mousePressEvent(TQMouseEvent*);

private:
  TraceItemView* addTab(TQString, TraceItemView*);
  void addTop(TraceItemView*);
  void addBottom(TraceItemView*);
  TabWidget* tabWidget(Position);
  void updateVisibility();
  void doUpdate(int);
  void installFocusFilters();

  // this is true if width or height <= 1, and no child updates are done
  bool _isCollapsed;

  KSqueezedTextLabel* _nameLabel;
  TQSplitter *_mainSplitter, *_leftSplitter, *_bottomSplitter;
  TabWidget *_topTW, *_leftTW, *_bottomTW, *_rightTW;
  TQPtrList<TraceItemView> _tabs;

  TQWidget* _lastFocus;
  bool _active;
};

#endif