Commit 824265d4 authored by dt's avatar dt
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents 73a8ffe2 c110da75
......@@ -101,7 +101,7 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
menu.addAction(act1);
menu.addAction(act2);
menu.addAction(act4);
menu.addAction(theDebuggerSetting(SettingsDialog)->action());
menu.addAction(theDebuggerAction(SettingsDialog));
QAction *act = menu.exec(ev->globalPos());
......
......@@ -44,28 +44,27 @@ namespace Internal {
//////////////////////////////////////////////////////////////////////////
//
// QtcSettingsItem
// DebuggerAction
//
//////////////////////////////////////////////////////////////////////////
QtcSettingsItem::QtcSettingsItem(QObject *parent)
: QObject(parent)
DebuggerAction::DebuggerAction(QObject *parent)
: QAction(parent)
{
m_action = new QAction(this);
connect(m_action, SIGNAL(triggered(bool)), this, SLOT(actionTriggered(bool)));
connect(this, SIGNAL(triggered(bool)), this, SLOT(actionTriggered(bool)));
}
QVariant QtcSettingsItem::value() const
QVariant DebuggerAction::value() const
{
return m_value;
}
void QtcSettingsItem::setValue(const QVariant &value, bool doemit)
void DebuggerAction::setValue(const QVariant &value, bool doemit)
{
if (value != m_value) {
m_value = value;
if (m_action->isCheckable())
m_action->setChecked(m_value.toBool());
if (this->isCheckable())
this->setChecked(m_value.toBool());
if (doemit) {
emit valueChanged(m_value);
emit boolValueChanged(m_value.toBool());
......@@ -74,63 +73,53 @@ void QtcSettingsItem::setValue(const QVariant &value, bool doemit)
}
}
QVariant QtcSettingsItem::defaultValue() const
QVariant DebuggerAction::defaultValue() const
{
return m_defaultValue;
}
void QtcSettingsItem::setDefaultValue(const QVariant &value)
void DebuggerAction::setDefaultValue(const QVariant &value)
{
m_defaultValue = value;
}
QString QtcSettingsItem::settingsKey() const
QString DebuggerAction::settingsKey() const
{
return m_settingsKey;
}
void QtcSettingsItem::setSettingsKey(const QString &key)
void DebuggerAction::setSettingsKey(const QString &key)
{
m_settingsKey = key;
}
void QtcSettingsItem::setSettingsKey(const QString &group, const QString &key)
void DebuggerAction::setSettingsKey(const QString &group, const QString &key)
{
m_settingsKey = key;
m_settingsGroup = group;
}
QString QtcSettingsItem::settingsGroup() const
QString DebuggerAction::settingsGroup() const
{
return m_settingsGroup;
}
void QtcSettingsItem::setSettingsGroup(const QString &group)
void DebuggerAction::setSettingsGroup(const QString &group)
{
m_settingsGroup = group;
}
QString QtcSettingsItem::text() const
{
return m_action->text();
}
void QtcSettingsItem::setText(const QString &value)
{
m_action->setText(value);
}
QString QtcSettingsItem::textPattern() const
QString DebuggerAction::textPattern() const
{
return m_textPattern;
}
void QtcSettingsItem::setTextPattern(const QString &value)
void DebuggerAction::setTextPattern(const QString &value)
{
m_textPattern = value;
}
QAction *QtcSettingsItem::updatedAction(const QString &text0)
QAction *DebuggerAction::updatedAction(const QString &text0)
{
QString text = text0;
bool enabled = true;
......@@ -144,13 +133,13 @@ QAction *QtcSettingsItem::updatedAction(const QString &text0)
text = m_textPattern.arg(text0);
}
}
m_action->setEnabled(enabled);
m_action->setData(text0);
m_action->setText(text);
return m_action;
this->setEnabled(enabled);
this->setData(text0);
this->setText(text);
return this;
}
void QtcSettingsItem::readSettings(QSettings *settings)
void DebuggerAction::readSettings(QSettings *settings)
{
if (m_settingsGroup.isEmpty() || m_settingsKey.isEmpty())
return;
......@@ -160,7 +149,7 @@ void QtcSettingsItem::readSettings(QSettings *settings)
settings->endGroup();
}
void QtcSettingsItem::writeSettings(QSettings *settings)
void DebuggerAction::writeSettings(QSettings *settings)
{
if (m_settingsGroup.isEmpty() || m_settingsKey.isEmpty())
return;
......@@ -170,12 +159,7 @@ void QtcSettingsItem::writeSettings(QSettings *settings)
settings->endGroup();
}
QAction *QtcSettingsItem::action()
{
return m_action;
}
void QtcSettingsItem::connectWidget(QWidget *widget, ApplyMode applyMode)
void DebuggerAction::connectWidget(QWidget *widget, ApplyMode applyMode)
{
using namespace Core::Utils;
//qDebug() << "CONNECT WIDGET " << widget << " TO " << m_settingsKey;
......@@ -206,22 +190,22 @@ void QtcSettingsItem::connectWidget(QWidget *widget, ApplyMode applyMode)
}
}
void QtcSettingsItem::apply(QSettings *s)
void DebuggerAction::apply(QSettings *s)
{
setValue(m_deferedValue);
if (s)
writeSettings(s);
}
void QtcSettingsItem::uncheckableButtonClicked()
void DebuggerAction::uncheckableButtonClicked()
{
QAbstractButton *button = qobject_cast<QAbstractButton *>(sender());
QTC_ASSERT(button, return);
//qDebug() << "UNCHECKABLE BUTTON: " << sender();
m_action->trigger();
QAction::trigger();
}
void QtcSettingsItem::checkableButtonClicked(bool)
void DebuggerAction::checkableButtonClicked(bool)
{
QAbstractButton *button = qobject_cast<QAbstractButton *>(sender());
QTC_ASSERT(button, return);
......@@ -232,7 +216,7 @@ void QtcSettingsItem::checkableButtonClicked(bool)
setValue(button->isChecked());
}
void QtcSettingsItem::lineEditEditingFinished()
void DebuggerAction::lineEditEditingFinished()
{
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(sender());
QTC_ASSERT(lineEdit, return);
......@@ -243,7 +227,7 @@ void QtcSettingsItem::lineEditEditingFinished()
setValue(lineEdit->text());
}
void QtcSettingsItem::pathChooserEditingFinished()
void DebuggerAction::pathChooserEditingFinished()
{
using namespace Core::Utils;
PathChooser *pathChooser = qobject_cast<PathChooser *>(sender());
......@@ -255,61 +239,63 @@ void QtcSettingsItem::pathChooserEditingFinished()
setValue(pathChooser->path());
}
void QtcSettingsItem::actionTriggered(bool on)
void DebuggerAction::actionTriggered(bool)
{
Q_UNUSED(on);
if (QAction *action = qobject_cast<QAction *>(sender())) {
if (action->isCheckable())
setValue(action->isChecked());
}
if (this->isCheckable())
setValue(this->isChecked());
}
void DebuggerAction::trigger(const QVariant &data)
{
setData(data);
QAction::trigger();
}
//////////////////////////////////////////////////////////////////////////
//
// QtcSettingsPool
// DebuggerSettings
//
//////////////////////////////////////////////////////////////////////////
QtcSettingsPool::QtcSettingsPool(QObject *parent)
DebuggerSettings::DebuggerSettings(QObject *parent)
: QObject(parent)
{}
QtcSettingsPool::~QtcSettingsPool()
DebuggerSettings::~DebuggerSettings()
{
qDeleteAll(m_items);
}
void QtcSettingsPool::insertItem(int code, QtcSettingsItem *item)
void DebuggerSettings::insertItem(int code, DebuggerAction *item)
{
m_items[code] = item;
}
void QtcSettingsPool::readSettings(QSettings *settings)
void DebuggerSettings::readSettings(QSettings *settings)
{
foreach (QtcSettingsItem *item, m_items)
foreach (DebuggerAction *item, m_items)
item->readSettings(settings);
}
void QtcSettingsPool::writeSettings(QSettings *settings)
void DebuggerSettings::writeSettings(QSettings *settings)
{
foreach (QtcSettingsItem *item, m_items)
foreach (DebuggerAction *item, m_items)
item->writeSettings(settings);
}
QtcSettingsItem *QtcSettingsPool::item(int code)
DebuggerAction *DebuggerSettings::item(int code)
{
QTC_ASSERT(m_items.value(code, 0), return 0);
return m_items.value(code, 0);
}
QString QtcSettingsPool::dump()
QString DebuggerSettings::dump()
{
QString out;
QTextStream ts(&out);
ts << "Debugger settings: ";
foreach (QtcSettingsItem *item, m_items)
foreach (DebuggerAction *item, m_items)
ts << "\n" << item->value().toString();
return out;
}
......@@ -318,175 +304,156 @@ QString QtcSettingsPool::dump()
//////////////////////////////////////////////////////////////////////////
//
// Debugger specific stuff
// Debugger specific actions and settings
//
//////////////////////////////////////////////////////////////////////////
#if 0
QString dump();
QString m_gdbCmd;
QString m_gdbEnv;
bool m_autoRun;
bool m_autoQuit;
bool m_useDumpers;
bool m_skipKnownFrames;
bool m_debugDumpers;
bool m_useToolTips;
bool m_listSourceFiles;
QString m_scriptFile;
bool m_pluginAllBreakpoints;
bool m_pluginSelectedBreakpoints;
bool m_pluginNoBreakpoints;
QString m_pluginSelectedBreakpointsPattern;
#endif
QtcSettingsPool *theDebuggerSettings()
DebuggerSettings *theDebuggerSettings()
{
static QtcSettingsPool *instance = 0;
static DebuggerSettings *instance = 0;
if (instance)
return instance;
instance = new QtcSettingsPool;
instance = new DebuggerSettings;
QtcSettingsItem *item = 0;
DebuggerAction *item = 0;
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(AdjustColumnWidths, item);
item->setText(QObject::tr("Adjust column widths to contents"));
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(AlwaysAdjustColumnWidths, item);
item->setText(QObject::tr("Always adjust column widths to contents"));
item->action()->setCheckable(true);
item->setCheckable(true);
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(WatchExpression, item);
item->setTextPattern(QObject::tr("Watch expression \"%1\""));
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(RemoveWatchExpression, item);
item->setTextPattern(QObject::tr("Remove watch expression \"%1\""));
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(WatchExpressionInWindow, item);
item->setTextPattern(QObject::tr("Watch expression \"%1\" in separate window"));
item = new DebuggerAction(instance);
instance->insertItem(AssignValue, item);
//
// Dumpers
//
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(SettingsDialog, item);
item->setText(QObject::tr("Debugger properties..."));
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(DebugDumpers, item);
item->setText(QObject::tr("Debug custom dumpers"));
item->action()->setCheckable(true);
item->setCheckable(true);
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(RecheckDumpers, item);
item->setText(QObject::tr("Recheck custom dumper availability"));
//
// Breakpoints
//
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(SynchronizeBreakpoints, item);
item->setText(QObject::tr("Syncronize breakpoints"));
//
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(AutoQuit, item);
item->setText(QObject::tr("Automatically quit debugger"));
item->action()->setCheckable(true);
item->setCheckable(true);
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(SkipKnownFrames, item);
item->setText(QObject::tr("Skip known frames"));
item->action()->setCheckable(true);
item->setCheckable(true);
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(UseToolTips, item);
item->setText(QObject::tr("Use tooltips when debugging"));
item->action()->setCheckable(true);
item->setCheckable(true);
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(ListSourceFiles, item);
item->setText(QObject::tr("List source files"));
item->action()->setCheckable(true);
item->setCheckable(true);
//
// Settings
//
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(GdbLocation, item);
item->setSettingsKey("DebugMode", "Location");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(GdbEnvironment, item);
item->setSettingsKey("DebugMode", "Environment");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(GdbScriptFile, item);
item->setSettingsKey("DebugMode", "ScriptFile");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(GdbAutoQuit, item);
item->setSettingsKey("DebugMode", "AutoQuit");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(GdbAutoRun, item);
item->setSettingsKey("DebugMode", "AutoRun");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(UseToolTips, item);
item->setSettingsKey("DebugMode", "UseToolTips");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(UseDumpers, item);
item->setSettingsKey("DebugMode", "UseCustomDumpers");
item->setText(QObject::tr("Use custom dumpers"));
item->action()->setCheckable(true);
item->setCheckable(true);
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(ListSourceFiles, item);
item->setSettingsKey("DebugMode", "ListSourceFiles");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(SkipKnownFrames, item);
item->setSettingsKey("DebugMode", "SkipKnownFrames");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(DebugDumpers, item);
item->setSettingsKey("DebugMode", "DebugDumpers");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(AllPluginBreakpoints, item);
item->setSettingsKey("DebugMode", "AllPluginBreakpoints");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(SelectedPluginBreakpoints, item);
item->setSettingsKey("DebugMode", "SelectedPluginBreakpoints");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(NoPluginBreakpoints, item);
item->setSettingsKey("DebugMode", "NoPluginBreakpoints");
item = new QtcSettingsItem(instance);
item = new DebuggerAction(instance);
instance->insertItem(SelectedPluginBreakpointsPattern, item);
item->setSettingsKey("DebugMode", "SelectedPluginBreakpointsPattern");
return instance;
}
QtcSettingsItem *theDebuggerSetting(int code)
DebuggerAction *theDebuggerAction(int code)
{
return theDebuggerSettings()->item(code);
}
......
......@@ -35,8 +35,9 @@
#include <QtCore/QVariant>
#include <QtCore/QList>
#include <QtGui/QAction>
QT_BEGIN_NAMESPACE
class QAction;
class QSettings;
QT_END_NAMESPACE
......@@ -46,12 +47,12 @@ namespace Internal {
enum ApplyMode { ImmediateApply, DeferedApply };
class QtcSettingsItem : public QObject
class DebuggerAction : public QAction
{
Q_OBJECT
public:
QtcSettingsItem(QObject *parent = 0);
DebuggerAction(QObject *parent = 0);
virtual QVariant value() const;
Q_SLOT virtual void setValue(const QVariant &value, bool doemit = true);
......@@ -59,8 +60,8 @@ public:
virtual QVariant defaultValue() const;
Q_SLOT virtual void setDefaultValue(const QVariant &value);
virtual QAction *action();
virtual QAction *updatedAction(const QString &newText);
Q_SLOT virtual void trigger(const QVariant &data);
// used for persistency
virtual QString settingsKey() const;
......@@ -76,9 +77,6 @@ public:
virtual void connectWidget(QWidget *widget, ApplyMode applyMode = DeferedApply);
Q_SLOT virtual void apply(QSettings *settings);
virtual QString text() const;
Q_SLOT virtual void setText(const QString &value);
virtual QString textPattern() const;
Q_SLOT virtual void setTextPattern(const QString &value);
......@@ -101,20 +99,19 @@ private:
QString m_settingsGroup;
QString m_textPattern;
QString m_textData;
QAction *m_action;
QHash<QObject *, ApplyMode> m_applyModes;
};
class QtcSettingsPool : public QObject
class DebuggerSettings : public QObject
{
Q_OBJECT
public:
QtcSettingsPool(QObject *parent = 0);
~QtcSettingsPool();
DebuggerSettings(QObject *parent = 0);
~DebuggerSettings();
void insertItem(int code, QtcSettingsItem *item);
QtcSettingsItem *item(int code);
void insertItem(int code, DebuggerAction *item);
DebuggerAction *item(int code);
QString dump();
......@@ -123,13 +120,13 @@ public slots:
void writeSettings(QSettings *settings);
private:
QHash<int, QtcSettingsItem *> m_items;
QHash<int, DebuggerAction *> m_items;
};
///////////////////////////////////////////////////////////
enum DebuggerSettingsCode
enum DebuggerActionCode
{
// General
SettingsDialog,
......@@ -154,6 +151,7 @@ enum DebuggerSettingsCode
UseDumpers,
DebugDumpers,
UseToolTips,
AssignValue,
// Source List
ListSourceFiles,
......@@ -172,8 +170,8 @@ enum DebuggerSettingsCode
};
// singleton access
QtcSettingsPool *theDebuggerSettings();
QtcSettingsItem *theDebuggerSetting(int code);
DebuggerSettings *theDebuggerSettings();
DebuggerAction *theDebuggerAction(int code);
// convienience