• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

kcachegrind

  • sources
  • kde-4.12
  • kdesdk
  • kcachegrind
  • libviews
multiview.cpp
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
3 
4  KCachegrind is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation, version 2.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; see the file COPYING. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 /*
20  * MultiView, enclosing multiple TabView's with a user choosable
21  * active view (i.e. focus), separated by a splitter.
22  * Selection of the active view is shown in the next to the right view
23  * (with wrap around).
24  */
25 
26 #include "multiview.h"
27 
28 #include <QDebug>
29 
30 #include "config.h"
31 #include "tabview.h"
32 
33 
34 //
35 // MultiView
36 //
37 
38 MultiView::MultiView(TopLevelBase* top, QWidget* parent)
39  : QSplitter(parent), TraceItemView(0, top)
40 {
41  // default
42  setOrientation(Qt::Horizontal);
43 
44  appendView();
45  _active = _views.first();
46  _active->setActive(true);
47 }
48 
49 void MultiView::setData(TraceData* d)
50 {
51  TraceItemView::setData(d);
52 
53  foreach(TabView* tv, _views)
54  tv->setData(d);
55 }
56 
57 void MultiView::setChildCount(int n)
58 {
59  while(n< _views.count()) removeView();
60  while(n> _views.count()) appendView();
61 }
62 
63 void MultiView::appendView()
64 {
65  int n = _views.count()+1;
66 
67  TabView* tv = new TabView(this, this);
68  tv->setObjectName(QString("TabView-%1").arg(n));
69  connect(tv, SIGNAL(tabActivated(TabView*)),
70  this, SLOT(tabActivated(TabView*)) );
71  _views.append(tv);
72  tv->show();
73 
74  // no need to waste time with update merging
75  tv->setMergeUpdates(false);
76 
77  // set same attributes as in active view
78  tv->set(0, _data, _eventType, _eventType2,
79  _groupType, _partList, _activeItem, 0);
80 
81  if (0) qDebug() << "MultiView::appendView, now "
82  << _views.count();
83 }
84 
85 void MultiView::removeView()
86 {
87  if (_views.count()<=1) return;
88 
89  TabView* last = _views.last();
90 
91  // if last tab is active, make first active
92  if (last == _active) {
93  TabView* newActive = _views.first();
94  newActive->setActive(true);
95  tabActivated(newActive);
96  }
97 
98  _views.removeAll(last);
99  delete last;
100 
101  if (0) qDebug() << "MultiView::removeView, now "
102  << _views.count();
103 }
104 
105 
106 void MultiView::tabActivated(TabView* newActiveTab)
107 {
108  if (_active == newActiveTab) return;
109 
110  if (0) qDebug() << "MultiView::tabActivated "
111  << newActiveTab->objectName();
112 
113  CostItem* oldActiveItem = 0;
114  if (_active) {
115  oldActiveItem = _active->activeItem();
116  _active->setActive(false);
117  }
118  _active = newActiveTab;
119 
120  // make the active item of the new TabView active
121  if (_active && (oldActiveItem != _active->activeItem()))
122  TraceItemView::activated(_active->activeItem());
123 }
124 
125 void MultiView::selected(TraceItemView* sender, CostItem* i)
126 {
127  if (0) qDebug() << "MultiView::selected " << i->name()
128  << ", sender " << sender->widget()->objectName();
129 
130  // we react only on selection changes of the active TabView
131  if (sender != (TraceItemView*)_active) return;
132 
133  int idx = _views.indexOf(_active);
134  idx++;
135  if (idx == _views.count()) idx = 0;
136  TabView* next = _views.at(idx);
137 
138  // do not change item of active tab
139  if (next == _active) return;
140 
141  next->activate(i);
142 }
143 
144 void MultiView::activated(TraceItemView* sender, CostItem* i)
145 {
146  if (0) qDebug() << "MultiView::activated " << i->name()
147  << ", sender " << sender->widget()->objectName();
148 
149  // we react only on selection changes of the active TabView
150  if (sender != (TraceItemView*)_active) return;
151 
152  TraceItemView::activated(sender,i);
153 }
154 
155 void MultiView::doUpdate(int changeType, bool force)
156 {
157  foreach(TabView* tv, _views) {
158  tv->set(changeType, _data, _eventType, _eventType2,
159  _groupType, _partList,
160  (tv == _active) ? _activeItem : tv->activeItem(),
161  tv->selectedItem());
162  tv->notifyChange(changeType);
163  if (tv->isViewVisible())
164  tv->updateView(force);
165  }
166 }
167 
168 
169 void MultiView::restoreLayout(const QString& prefix, const QString& postfix)
170 {
171  ConfigGroup* g = ConfigStorage::group(prefix, postfix);
172 
173  int panelCount = g->value("Panels", 1).toInt();;
174  QString o = g->value("Orientation", QString("Vertical")).toString();
175  QString active = g->value("ActivePanel", QString()).toString();
176 
177  setChildCount(panelCount);
178  setOrientation( o == QString("Horizontal") ?
179  Qt::Horizontal : Qt::Vertical );
180  if ( panelCount>1 ) {
181  QList<int> sizes = toIntList(g->value("PanelSizes", QStringList()).toStringList());
182  setSizes(sizes);
183  }
184  delete g;
185 
186  TabView* activeTV = 0;
187  foreach(TabView* tv, _views) {
188  if (tv->objectName() == active) activeTV=tv;
189  tv->restoreLayout( QString("%1-%2").arg(prefix).arg(tv->objectName()),
190  postfix);
191  }
192 
193  // activate panel after restoring
194  if (!activeTV) activeTV = _views.first();
195 
196  if (_active == activeTV)
197  TraceItemView::activated(_active->activeItem());
198  else
199  activeTV->setActive(true);
200 }
201 
202 void MultiView::saveLayout(const QString& prefix, const QString& postfix)
203 {
204  ConfigGroup* g = ConfigStorage::group(prefix + postfix);
205 
206  g->setValue("Panels", childCount());
207  g->setValue("Orientation",
208  QString( (orientation() == Qt::Horizontal) ?
209  "Horizontal" : "Vertical"),
210  QString("Vertical"));
211 
212  g->setValue("PanelSizes", toStringList(sizes()));
213  g->setValue("ActivePanel",
214  _active ? QString(_active->objectName()) : QString("none"));
215  delete g;
216 
217  foreach(TabView* tv, _views)
218  tv->saveLayout(QString("%1-%2").arg(prefix).arg(tv->objectName()),
219  postfix);
220 }
221 
222 
223 
224 void MultiView::restoreOptions(const QString& prefix, const QString& postfix)
225 {
226  foreach(TabView* tv, _views)
227  tv->restoreOptions(QString("%1-%2").arg(prefix).arg(tv->objectName()),
228  postfix);
229 }
230 
231 void MultiView::saveOptions(const QString& prefix, const QString& postfix)
232 {
233  foreach(TabView* tv, _views)
234  tv->saveOptions(QString("%1-%2").arg(prefix).arg(tv->objectName()),
235  postfix);
236 }
237 
238 
239 #include "multiview.moc"
MultiView::selected
void selected(TraceItemView *, CostItem *)
Notification from child views.
Definition: multiview.cpp:125
MultiView::saveLayout
void saveLayout(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:202
TraceItemView::set
void set(ProfileContext::Type g)
Definition: traceitemview.h:115
TabView::setData
void setData(TraceData *)
Definition: tabview.cpp:435
QWidget
TraceItemView::_data
TraceData * _data
Definition: traceitemview.h:209
ConfigGroup::setValue
virtual void setValue(const QString &key, const QVariant &value, const QVariant &defaultValue=QVariant())
Definition: config.cpp:57
CostItem
Base class for cost items.
Definition: costitem.h:37
config.h
TraceItemView::updateView
void updateView(bool force=false)
Definition: traceitemview.cpp:185
TraceItemView::_groupType
ProfileContext::Type _groupType
Definition: traceitemview.h:213
TraceItemView::setMergeUpdates
void setMergeUpdates(bool b)
Definition: traceitemview.h:128
MultiView::MultiView
MultiView(TopLevelBase *top, QWidget *parent=0)
Definition: multiview.cpp:38
TraceItemView::_eventType2
EventType * _eventType2
Definition: traceitemview.h:212
ConfigStorage::group
static ConfigGroup * group(const QString &group, const QString &optSuffix=QString())
Definition: config.cpp:80
TraceItemView
Abstract Base Class for KCachegrind Views.
Definition: traceitemview.h:70
TraceItemView::setData
virtual void setData(TraceData *d)
Definition: traceitemview.cpp:165
TraceItemView::selectedItem
CostItem * selectedItem() const
Definition: traceitemview.h:150
TraceItemView::_eventType
EventType * _eventType
Definition: traceitemview.h:212
MultiView::restoreOptions
void restoreOptions(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:224
CostItem::name
virtual QString name() const
Returns dynamic name info (without type)
Definition: costitem.cpp:53
MultiView::setData
void setData(TraceData *)
Definition: multiview.cpp:49
TopLevelBase
Definition: toplevelbase.h:34
TraceItemView::_activeItem
CostItem * _activeItem
Definition: traceitemview.h:211
TraceItemView::activate
bool activate(CostItem *i)
Definition: traceitemview.cpp:110
TabView::restoreOptions
void restoreOptions(const QString &prefix, const QString &postfix)
Definition: tabview.cpp:984
ConfigGroup
A group of configuration settings.
Definition: config.h:35
TraceItemView::notifyChange
void notifyChange(int changeType)
Definition: traceitemview.h:120
TraceItemView::activated
virtual void activated(TraceItemView *sender, CostItem *)
Definition: traceitemview.cpp:342
MultiView::appendView
void appendView()
Definition: multiview.cpp:63
TabView::setActive
void setActive(bool)
Definition: tabview.cpp:708
TabView::restoreLayout
void restoreLayout(const QString &prefix, const QString &postfix)
Definition: tabview.cpp:820
TraceItemView::activeItem
CostItem * activeItem() const
Definition: traceitemview.h:149
TabView::saveLayout
void saveLayout(const QString &prefix, const QString &postfix)
Definition: tabview.cpp:903
MultiView::restoreLayout
void restoreLayout(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:169
MultiView::removeView
void removeView()
Definition: multiview.cpp:85
TabView::saveOptions
void saveOptions(const QString &prefix, const QString &postfix)
Definition: tabview.cpp:1017
MultiView::tabActivated
void tabActivated(TabView *)
Definition: multiview.cpp:106
MultiView::activated
void activated(TraceItemView *, CostItem *)
Definition: multiview.cpp:144
toStringList
QStringList toStringList(QList< int > l)
Definition: config.cpp:36
TraceItemView::widget
virtual QWidget * widget()=0
MultiView::setChildCount
void setChildCount(int)
Definition: multiview.cpp:57
TabView
Definition: tabview.h:115
TraceData
This class holds profiling data of multiple tracefiles generated with cachegrind on one command...
Definition: tracedata.h:1363
multiview.h
MultiView::childCount
int childCount()
Definition: multiview.h:50
TabView::isViewVisible
bool isViewVisible()
Definition: tabview.h:127
tabview.h
TraceItemView::_partList
TracePartList _partList
Definition: traceitemview.h:210
MultiView::saveOptions
void saveOptions(const QString &prefix, const QString &postfix)
Definition: multiview.cpp:231
QSplitter
QList
ConfigGroup::value
virtual QVariant value(const QString &key, const QVariant &defaultValue) const
Definition: config.cpp:60
toIntList
QList< int > toIntList(QStringList l)
Definition: config.cpp:26
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:03:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kcachegrind

Skip menu "kcachegrind"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal