• 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
  • qcachegrind
configdialog.cpp
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 2009 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  * QCachegrind configuration dialog
21  */
22 
23 #include "configdialog.h"
24 
25 #include <QWidget>
26 #include <QLabel>
27 #include <QFrame>
28 #include <QListWidget>
29 #include <QStackedWidget>
30 #include <QDialogButtonBox>
31 #include <QHBoxLayout>
32 #include <QVBoxLayout>
33 #include <QTimer>
34 
35 #include "generalsettings.h"
36 #include "sourcesettings.h"
37 #include "colorsettings.h"
38 
39 //
40 // ConfigDialog
41 //
42 
43 ConfigDialog::ConfigDialog(TraceData* data, QWidget* parent, QString s)
44  : QDialog(parent)
45 {
46  setWindowTitle(tr("Configure QCachegrind"));
47 
48  _listWidget = new QListWidget(this);
49  _listWidget->setMaximumWidth(140);
50  _widgetStack = new QStackedWidget(this);
51  _titleLabel = new QLabel(this);
52  QFont labelFont;
53  labelFont.setBold(true);
54  _titleLabel->setFont(labelFont);
55  _errorLabel = new QLabel(this);
56  _errorLabel->setIndent(9);
57 
58  QDialogButtonBox* bbox = new QDialogButtonBox(this);
59  bbox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
60 
61  QVBoxLayout* vbox1 = new QVBoxLayout();
62  vbox1->addWidget(_titleLabel);
63  QFrame* f1 = new QFrame(this);
64  f1->setFrameShape(QFrame::HLine);
65  vbox1->addWidget(f1);
66  vbox1->addWidget(_errorLabel);
67  vbox1->addWidget(_widgetStack);
68 
69  QHBoxLayout* hbox = new QHBoxLayout();
70  hbox->addWidget(_listWidget);
71  hbox->addLayout(vbox1);
72  QVBoxLayout* vbox = new QVBoxLayout(this);
73  vbox->addLayout(hbox);
74  QFrame* f2 = new QFrame(this);
75  f2->setFrameStyle(QFrame::HLine | QFrame::Sunken);
76  vbox->addWidget(f2);
77  vbox->addWidget(bbox);
78 
79  connect(bbox, SIGNAL(accepted()), this, SLOT(accept()));
80  connect(bbox, SIGNAL(rejected()), this, SLOT(reject()));
81  connect(_listWidget, SIGNAL(currentTextChanged(QString)),
82  this, SLOT(listItemChanged(QString)));
83  connect(&_clearTimer, SIGNAL(timeout()), this, SLOT(clearError()));
84 
85  addPage(new GeneralSettings(this));
86  addPage(new SourceSettings(data, this));
87  addPage(new ColorSettings(data, this));
88 
89  activate(s);
90 }
91 
92 void ConfigDialog::addPage(ConfigPage* p)
93 {
94  _widgetStack->addWidget(p);
95  _listWidget->addItem(p->title());
96  _pages.insert(p->title(), p);
97 }
98 
99 void ConfigDialog::listItemChanged(QString s)
100 {
101  ConfigPage* p = _pages.value(s);
102  if (!p) return;
103 
104  _titleLabel->setText(p->longTitle());
105  _widgetStack->setCurrentWidget(p);
106  if (!_activeSetting.isEmpty()) {
107  p->activate(_activeSetting);
108  _activeSetting.clear();
109  }
110 }
111 
112 void ConfigDialog::clearError()
113 {
114  _errorLabel->setText(QString());
115 }
116 
117 void ConfigDialog::activate(QString s)
118 {
119  if (s.isEmpty())
120  _listWidget->setCurrentRow(0);
121 
122  QString page = s;
123  _activeSetting.clear();
124  int p = s.indexOf("/");
125  if (p>0) {
126  page = s.left(p);
127  _activeSetting = s.mid(p+1);
128  }
129 
130  for(int row=0; row<_listWidget->count(); row++) {
131  QListWidgetItem* i = _listWidget->item(row);
132  if (i->text() != page) continue;
133 
134  if (_listWidget->currentRow() == row)
135  // even without page change, forward activation
136  listItemChanged(page);
137  else
138  _listWidget->setCurrentRow(row);
139  }
140 }
141 
142 QString ConfigDialog::currentPage()
143 {
144  return _listWidget->currentItem()->text();
145 }
146 
147 void ConfigDialog::accept()
148 {
149  ConfigPage* p;
150  QString errorMsg, errorItem;
151  foreach(p, _pages)
152  if (!p->check(errorMsg, errorItem)) {
153  if (!errorMsg.isEmpty()) {
154  errorMsg = QString("<font color=red>%1</color>").arg(errorMsg);
155  _errorLabel->setText(errorMsg);
156  _clearTimer.start(5000);
157  }
158  activate(QString("%1/%2").arg(p->title(), errorItem));
159  return;
160  }
161 
162  foreach(p, _pages)
163  p->accept();
164 
165  QDialog::accept();
166 }
167 
168 #include "configdialog.moc"
ConfigPage::accept
virtual void accept()
Definition: configpage.cpp:53
ConfigPage::longTitle
QString longTitle()
Definition: configpage.h:37
QDialog
SourceSettings
Definition: sourcesettings.h:32
ConfigDialog::currentPage
QString currentPage()
Definition: configdialog.cpp:142
QWidget
ConfigPage::check
virtual bool check(QString &errorMsg, QString &errorItem)
Definition: configpage.cpp:48
ConfigPage::title
QString title()
Definition: configpage.h:36
configdialog.h
colorsettings.h
ConfigDialog::ConfigDialog
ConfigDialog(TraceData *data, QWidget *parent, QString s=QString::null)
Definition: configdialog.cpp:43
ColorSettings
Definition: colorsettings.h:33
GeneralSettings
Definition: generalsettings.h:29
ConfigPage
Definition: configpage.h:30
ConfigDialog::activate
void activate(QString)
Definition: configdialog.cpp:117
sourcesettings.h
ConfigPage::activate
virtual void activate(QString)
Definition: configpage.cpp:42
TraceData
This class holds profiling data of multiple tracefiles generated with cachegrind on one command...
Definition: tracedata.h:1363
ConfigDialog::accept
void accept()
Definition: configdialog.cpp:147
generalsettings.h
ConfigDialog::listItemChanged
void listItemChanged(QString)
Definition: configdialog.cpp:99
ConfigDialog::clearError
void clearError()
Definition: configdialog.cpp:112
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:03:26 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