Commit 8414ba3b authored by Josef Weidendorfer's avatar Josef Weidendorfer
Browse files

qcachegrind: general settings page

svn path=/trunk/KDE/kdesdk/kcachegrind/; revision=1048528
parent ed4022ee
......@@ -515,3 +515,33 @@ int GlobalConfig::noCostInside()
{
return config()->_noCostInside;
}
void GlobalConfig::setPercentPrecision(int v)
{
if ((v<1) || (v >5)) return;
_percentPrecision = v;
}
void GlobalConfig::setMaxSymbolLength(int v)
{
if ((v<1) || (v >1000)) return;
_maxSymbolLength = v;
}
void GlobalConfig::setMaxSymbolCount(int v)
{
if ((v<1) || (v >50)) return;
_maxSymbolCount = v;
}
void GlobalConfig::setMaxListCount(int v)
{
if ((v<1) || (v >500)) return;
_maxListCount = v;
}
void GlobalConfig::setContext(int v)
{
if ((v<1) || (v >500)) return;
_context = v;
}
......@@ -71,6 +71,12 @@ public:
// how many lines without cost are still regarded as inside a function
static int noCostInside();
void setPercentPrecision(int);
void setMaxSymbolLength(int);
void setMaxSymbolCount(int);
void setMaxListCount(int);
void setContext(int);
static void setShowPercentage(bool);
static void setShowExpanded(bool);
......
include_directories(../libcore ../libviews)
set(qcachegrind_SRCS qcgmain.cpp qcgtoplevel.cpp qcgconfig.cpp
configdialog.cpp configpage.cpp)
configdialog.cpp configpage.cpp
generalsettings.cpp)
qt4_automoc(${qcachegrind_SRCS})
qt4_wrap_ui(qcachegrind_H generalsettings.ui)
qt4_add_resources(qcachegrind_RSRC qcachegrind.qrc)
add_executable(qcachegrind ${qcachegrind_SRCS} ${qcachegrind_RSRC})
add_executable(qcachegrind ${qcachegrind_SRCS} ${qcachegrind_H} ${qcachegrind_RSRC})
target_link_libraries(qcachegrind
core views
${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY}
${QT_QTDBUS_LIBRARY} ${QT_QT3SUPPORT_LIBRARY})
${QT_QTDBUS_LIBRARY} ${QT_QT3SUPPORT_LIBRARY})
# do not install example code...
# install(TARGETS qcachegrind ${INSTALL_TARGETS_DEFAULT_ARGS} )
......@@ -32,6 +32,7 @@
#include <QVBoxLayout>
#include <QTimer>
#include "generalsettings.h"
//
// ConfigDialog
......@@ -79,7 +80,8 @@ ConfigDialog::ConfigDialog(TraceData* /*data*/, QWidget* parent, QString s)
this, SLOT(listItemChanged(QString)));
connect(&_clearTimer, SIGNAL(timeout()), this, SLOT(clearError()));
addPage(new ConfigPage(this, "Test", "Test Page"));
addPage(new GeneralSettings(this));
activate(s);
}
......
/* This file is part of KCachegrind.
Copyright (C) 2009 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.
*/
/*
* General settings config page
*/
#include "generalsettings.h"
#include "globalconfig.h"
//
// GeneralSettings
//
GeneralSettings::GeneralSettings(QWidget* parent)
: ConfigPage(parent,
QObject::tr("General"), QObject::tr("General Settings"))
{
ui.setupUi(this);
GlobalConfig* c = GlobalConfig::config();
ui.maxListEdit->setText(QString::number(c->maxListCount()));
ui.symbolCount->setText(QString::number(c->maxSymbolCount()));
ui.symbolLength->setText(QString::number(c->maxSymbolLength()));
ui.precisionEdit->setText(QString::number(c->percentPrecision()));
ui.contextEdit->setText(QString::number(c->context()));
_names.insert(QString("maxListEdit"), ui.maxListEdit);
_names.insert(QString("symbolCount"), ui.symbolCount);
_names.insert(QString("symbolLength"), ui.symbolLength);
_names.insert(QString("precisionEdit"), ui.precisionEdit);
_names.insert(QString("contextEdit"), ui.contextEdit);
}
bool GeneralSettings::check(QString& errorMsg, QString& errorItem)
{
int v;
v = ui.maxListEdit->text().toUInt();
if ((v <1) || (v >500)) {
errorMsg = inRangeError(1, 500);
errorItem = QString("maxListEdit");
return false;
}
v = ui.symbolCount->text().toInt();
if ((v <1) || (v >50)) {
errorMsg = inRangeError(1, 50);
errorItem = QString("symbolCount");
return false;
}
v = ui.symbolLength->text().toInt();
if ((v <1) || (v >1000)) {
errorMsg = inRangeError(1, 1000);
errorItem = QString("symbolLength");
return false;
}
v = ui.precisionEdit->text().toInt();
if ((v <1) || (v >5)) {
errorMsg = inRangeError(1, 5);
errorItem = QString("precisionEdit");
return false;
}
v = ui.contextEdit->text().toInt();
if ((v <1) || (v >500)) {
errorMsg = inRangeError(1, 500);
errorItem = QString("contextEdit");
return false;
}
return true;
}
void GeneralSettings::accept()
{
GlobalConfig* c = GlobalConfig::config();
c->setMaxListCount(ui.maxListEdit->text().toUInt());
c->setMaxSymbolCount(ui.symbolCount->text().toInt());
c->setMaxSymbolLength(ui.symbolLength->text().toInt());
c->setPercentPrecision(ui.precisionEdit->text().toInt());
c->setContext(ui.contextEdit->text().toInt());
}
/* This file is part of KCachegrind.
Copyright (C) 2009 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.
*/
/*
* General settings config page
*/
#ifndef GENERALSETTINGS_H
#define GENERALSETTINGS_H
#include "configpage.h"
#include "ui_generalsettings.h"
class GeneralSettings: public ConfigPage
{
public:
GeneralSettings(QWidget* parent);
virtual ~GeneralSettings() {}
bool check(QString&, QString&);
void accept();
private:
Ui::GeneralSettings ui;
};
#endif // GENERALSETTINGS_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GeneralSettings</class>
<widget class="QWidget" name="GeneralSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>274</width>
<height>260</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="TextLabel4_3">
<property name="text">
<string>Precision of percentage values:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="precisionEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="TextLabel4_3_2">
<property name="text">
<string>Context lines in annotations:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="contextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QLabel" name="TextLabel5">
<property name="text">
<string>Maximum number of items in lists:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="maxListEdit"/>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="4">
<widget class="QLabel" name="TextLabel3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Symbols in tooltips and context menus truncated</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="Spacer6_2_2_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1" colspan="2">
<widget class="QLabel" name="TextLabel2_2">
<property name="text">
<string>with more entries than:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QLineEdit" name="symbolCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="Spacer6_2_2_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="TextLabel2">
<property name="text">
<string>with more characters than:</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QLineEdit" name="symbolLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="7" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>65</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -26,10 +26,13 @@ new_moc.input = NHEADERS
QMAKE_EXTRA_COMPILERS = new_moc
# Input
FORMS += generalsettings.ui
NHEADERS += qcgconfig.h \
qcgtoplevel.h \
configdialog.h \
configpage.h \
configdialog.h \
configpage.h \
generalsettings.h \
../libcore/context.h \
../libcore/costitem.h \
../libcore/subcost.h \
......@@ -72,11 +75,13 @@ NHEADERS += qcgconfig.h \
../libviews/sourceitem.h \
../libviews/sourceview.h \
../libviews/stackitem.h
SOURCES += qcgmain.cpp \
qcgconfig.cpp \
qcgtoplevel.cpp \
configdialog.cpp \
configpage.cpp \
configdialog.cpp \
configpage.cpp \
generalsettings.cpp \
../libcore/context.cpp \
../libcore/costitem.cpp \
../libcore/subcost.cpp \
......
......@@ -526,7 +526,7 @@ void QCGTopLevel::createActions()
_forwardAction->setToolTip( hint );
// settings menu actions
_configureAction = new QAction(tr("&Configure"), this);
_configureAction = new QAction(tr("&Configure..."), this);
_configureAction->setStatusTip(tr("Configure QCachegrind"));
connect(_configureAction, SIGNAL(triggered()), this, SLOT(configure()));
......@@ -535,7 +535,7 @@ void QCGTopLevel::createActions()
_aboutAction->setStatusTip(tr("Show the application's About box"));
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
_aboutQtAction = new QAction(tr("About Qt ..."), this);
_aboutQtAction = new QAction(tr("About Qt..."), this);
connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
// toolbar actions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment