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

This commit is contained in:
Kavindra Devi Palaraja
2009-07-01 16:47:00 +02:00
56 changed files with 1535 additions and 687 deletions

View File

@@ -62,9 +62,10 @@ int qtGhVersion = QT_VERSION;
#endif #endif
#if USE_QT_GUI #if USE_QT_GUI
# include <QtGui/QWidget> # include <QtGui/QApplication>
# include <QtGui/QPixmap>
# include <QtGui/QImage> # include <QtGui/QImage>
# include <QtGui/QPixmap>
# include <QtGui/QWidget>
#endif #endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@@ -1457,7 +1458,9 @@ static void qDumpQHashNode(QDumper &d)
static void qDumpQImage(QDumper &d) static void qDumpQImage(QDumper &d)
{ {
const QImage &im = *reinterpret_cast<const QImage *>(d.data); const QImage &im = *reinterpret_cast<const QImage *>(d.data);
d.putItem("value", "(").put(im.width()).put("x").put(im.height()).put(")"); d.beginItem("value");
d.put("(").put(im.width()).put("x").put(im.height()).put(")");
d.endItem();
d.putItem("type", NS"QImage"); d.putItem("type", NS"QImage");
d.putItem("numchild", "1"); d.putItem("numchild", "1");
if (d.dumpChildren) { if (d.dumpChildren) {
@@ -2234,7 +2237,9 @@ static void qDumpQObjectSlotList(QDumper &d)
static void qDumpQPixmap(QDumper &d) static void qDumpQPixmap(QDumper &d)
{ {
const QPixmap &im = *reinterpret_cast<const QPixmap *>(d.data); const QPixmap &im = *reinterpret_cast<const QPixmap *>(d.data);
d.putItem("value", "(").put(im.width()).put("x").put(im.height()).put(")"); d.beginItem("value");
d.put("(").put(im.width()).put("x").put(im.height()).put(")");
d.endItem();
d.putItem("type", NS"QPixmap"); d.putItem("type", NS"QPixmap");
d.putItem("numchild", "0"); d.putItem("numchild", "0");
d.disarm(); d.disarm();
@@ -2455,7 +2460,7 @@ static void qDumpQVariant(QDumper &d)
d.putItem("value", "(invalid)"); d.putItem("value", "(invalid)");
} else if (value.isEmpty()) { } else if (value.isEmpty()) {
d.beginItem("value"); d.beginItem("value");
d.put("(").put(v.typeName()).put(") ").put(qPrintable(value)); d.put("(").put(v.typeName()).put(") ");
d.endItem(); d.endItem();
} else { } else {
QByteArray ba; QByteArray ba;
@@ -2464,7 +2469,7 @@ static void qDumpQVariant(QDumper &d)
ba += ") "; ba += ") ";
ba += qPrintable(value); ba += qPrintable(value);
d.putItem("value", ba); d.putItem("value", ba);
d.putItem("valueencoded", "4"); d.putItem("valueencoded", "5");
} }
d.putItem("type", NS"QVariant"); d.putItem("type", NS"QVariant");
d.putItem("numchild", (isInvalid ? "0" : "1")); d.putItem("numchild", (isInvalid ? "0" : "1"));
@@ -3023,6 +3028,14 @@ static void handleProtocolVersion2and3(QDumper & d)
} // anonymous namespace } // anonymous namespace
#if USE_QT_GUI
extern "C" Q_DECL_EXPORT
void *watchPoint(int x, int y)
{
return QApplication::widgetAt(x, y);
}
#endif
extern "C" Q_DECL_EXPORT extern "C" Q_DECL_EXPORT
void *qDumpObjectData440( void *qDumpObjectData440(
int protocolVersion, int protocolVersion,
@@ -3115,7 +3128,7 @@ void *qDumpObjectData440(
.put(""NS"QStringList=\"").put(sizeof(QStringList)).put("\",") .put(""NS"QStringList=\"").put(sizeof(QStringList)).put("\",")
.put(""NS"QObject=\"").put(sizeof(QObject)).put("\",") .put(""NS"QObject=\"").put(sizeof(QObject)).put("\",")
#if USE_QT_GUI #if USE_QT_GUI
.put(""NS"QWidget=\"").put(sizeof(QWidget)<< "\",") .put(""NS"QWidget=\"").put(sizeof(QWidget)).put("\",")
#endif #endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
.put("string=\"").put(sizeof(std::string)).put("\",") .put("string=\"").put(sizeof(std::string)).put("\",")

View File

@@ -1,13 +1,12 @@
TEMPLATE = lib TEMPLATE = lib
CONFIG += shared CONFIG += shared
QT = core
linux-* { linux-* {
CONFIG -= release CONFIG -= release
CONFIG += debug CONFIG += debug
} }
SOURCES=gdbmacros.cpp SOURCES=gdbmacros.cpp
true { false {
DEFINES += USE_QT_GUI=0 DEFINES += USE_QT_GUI=0
QT = core QT = core
} else { } else {

View File

@@ -0,0 +1,291 @@
<!DOCTYPE QPH>
<QPH language="fr">
<phrase>
<source>debugger</source>
<target>débogueur</target>
</phrase>
<phrase>
<source>Start Debugger</source>
<target>Lancer le débogueur</target>
</phrase>
<phrase>
<source>Executable:</source>
<target>Exécutable:</target>
</phrase>
<phrase>
<source>Filter:</source>
<target>Filtre:</target>
</phrase>
<phrase>
<source>Clear</source>
<target>Effacer</target>
</phrase>
<phrase>
<source>Host and port:</source>
<target>Hôte et port:</target>
</phrase>
<phrase>
<source>Architecture:</source>
<target>Architecture:</target>
</phrase>
<phrase>
<source>Server start script:</source>
<target>Script de démarrage du serveur:</target>
</phrase>
<phrase>
<source>&amp;Undo</source>
<target>Annu&amp;ler</target>
</phrase>
<phrase>
<source>Add Bookmark</source>
<target>Ajouter un signet</target>
</phrase>
<phrase>
<source>Bookmark:</source>
<target>Signet:</target>
</phrase>
<phrase>
<source>Add in Folder:</source>
<target>Ajouter dans le dossier:</target>
</phrase>
<phrase>
<source>+</source>
<target>+</target>
</phrase>
<phrase>
<source>New Folder</source>
<target>Nouveau Dossier</target>
</phrase>
<phrase>
<source>Bookmarks</source>
<target>Signets</target>
</phrase>
<phrase>
<source>Rename Folder</source>
<target>Renommer le Dossier</target>
</phrase>
<phrase>
<source>Bookmark</source>
<target>Signet</target>
</phrase>
<phrase>
<source>Remove</source>
<target>Retirer</target>
</phrase>
<phrase>
<source>Delete Folder</source>
<target>Supprimer le Dossier</target>
</phrase>
<phrase>
<source>Show Bookmark</source>
<target>Afficher le Signet</target>
</phrase>
<phrase>
<source>Show Bookmark in New Tab</source>
<target>Afficher le Signet dans un Nouvel Onglet</target>
</phrase>
<phrase>
<source>Delete Bookmark</source>
<target>Supprimer le Signet</target>
</phrase>
<phrase>
<source>Rename Bookmark</source>
<target>Renommer le Signet</target>
</phrase>
<phrase>
<source>Add</source>
<target>Ajouter</target>
</phrase>
<phrase>
<source>Move Up</source>
<target>Vers le Haut</target>
</phrase>
<phrase>
<source>Move Down</source>
<target>Vers le Bas</target>
</phrase>
<phrase>
<source>Previous Bookmark</source>
<target>Signet Précédent</target>
</phrase>
<phrase>
<source>Next Bookmark</source>
<target>Signet Suivant</target>
</phrase>
<phrase>
<source>Condition:</source>
<target>Condition:</target>
</phrase>
<phrase>
<source>Working Directory:</source>
<target>Répertoire de Travail:</target>
</phrase>
<phrase>
<source>Environment</source>
<target>Environnement</target>
</phrase>
<phrase>
<source>Arguments</source>
<target>Arguments</target>
</phrase>
<phrase>
<source>Build directory:</source>
<target>Répertoire de compilation:</target>
</phrase>
<phrase>
<source>Path:</source>
<target>Chemin:</target>
</phrase>
<phrase>
<source>CodePaster Error</source>
<target>Erreur dans CodePaster</target>
</phrase>
<phrase>
<source>General</source>
<target>Général</target>
</phrase>
<phrase>
<source>Username:</source>
<target>Nom d&apos;utilisateur:</target>
</phrase>
<phrase>
<source>CodePaster</source>
<target>CodePaster</target>
</phrase>
<phrase>
<source>User interface</source>
<target>Interface utilisateur</target>
</phrase>
<phrase>
<source>&lt;unlimited&gt;</source>
<target>&lt;illimitée&gt;</target>
</phrase>
<phrase>
<source>Open Link</source>
<target>Ouvrir le Lien</target>
</phrase>
<phrase>
<source> [read only]</source>
<target> [lecture seule]</target>
</phrase>
<phrase>
<source> [directory]</source>
<target> [répertoire]</target>
</phrase>
<phrase>
<source>Close</source>
<target>Fermer</target>
</phrase>
<phrase>
<source>Close All</source>
<target>Fermer Tout</target>
</phrase>
<phrase>
<source>Failed!</source>
<target>Échec!</target>
</phrase>
<phrase>
<source>Proceed</source>
<target>Continuer</target>
</phrase>
<phrase>
<source>Cancel</source>
<target>Annuler</target>
</phrase>
<phrase>
<source>Make writable</source>
<target>Rendre Inscriptible</target>
</phrase>
<phrase>
<source>Qt Creator</source>
<target>Qt Creator</target>
</phrase>
<phrase>
<source>&amp;File</source>
<target>&amp;Fichier</target>
</phrase>
<phrase>
<source>&amp;Edit</source>
<target>&amp;Édition</target>
</phrase>
<phrase>
<source>&amp;Redo</source>
<target>Re&amp;faire</target>
</phrase>
<phrase>
<source>Activate %1</source>
<target>Activer %1</target>
</phrase>
<phrase>
<source>Split</source>
<target>Scinder</target>
</phrase>
<phrase>
<source>New Project</source>
<target>Nouveau Projet</target>
</phrase>
<phrase>
<source>Close %1</source>
<target>Fermer %1</target>
</phrase>
<phrase>
<source>*</source>
<target>*</target>
</phrase>
<phrase>
<source>&amp;Undo</source>
<target>Annu&amp;ler</target>
</phrase>
<phrase>
<source>Bookmarks</source>
<target>Signets</target>
</phrase>
<phrase>
<source>New Folder</source>
<target>Nouveau dossier</target>
</phrase>
<phrase>
<source>Bookmark</source>
<target>Signet</target>
</phrase>
<phrase>
<source>Bookmarks</source>
<target>Signets</target>
</phrase>
<phrase>
<source>New Folder</source>
<target>Nouveau dossier</target>
</phrase>
<phrase>
<source>Add</source>
<target>Ajouter</target>
</phrase>
<phrase>
<source>&amp;Change</source>
<target>&amp;Modifier</target>
</phrase>
<phrase>
<source>Close</source>
<target>Fermer</target>
</phrase>
<phrase>
<source>General</source>
<target>Général</target>
</phrase>
<phrase>
<source>Close %1</source>
<target>Fermer %1</target>
</phrase>
<phrase>
<source>Close Other Editors</source>
<target>Fermer les autres éditeurs</target>
</phrase>
<phrase>
<source>Close All Except %1</source>
<target>Fermer tout sauf %1</target>
</phrase>
<phrase>
<source>C++</source>
<target></target>
</phrase>
</QPH>

File diff suppressed because it is too large Load Diff

View File

@@ -38,10 +38,22 @@ FastPreprocessor::FastPreprocessor(const Snapshot &snapshot)
QByteArray FastPreprocessor::run(QString fileName, const QString &source) QByteArray FastPreprocessor::run(QString fileName, const QString &source)
{ {
#ifdef QTCREATOR_WITH_MERGED_ENVIRONMENT
if (Document::Ptr doc = _snapshot.value(fileName)) {
_merged.insert(fileName);
foreach (const Document::Include &i, doc->includes())
mergeEnvironment(i.fileName());
}
#endif
const QByteArray preprocessed = _preproc(fileName, source); const QByteArray preprocessed = _preproc(fileName, source);
return preprocessed; return preprocessed;
} }
void FastPreprocessor::sourceNeeded(QString &fileName, IncludeType, unsigned)
{ mergeEnvironment(fileName); }
void FastPreprocessor::mergeEnvironment(const QString &fileName) void FastPreprocessor::mergeEnvironment(const QString &fileName)
{ {
if (! _merged.contains(fileName)) { if (! _merged.contains(fileName)) {

View File

@@ -54,8 +54,7 @@ public:
QByteArray run(QString fileName, const QString &source); QByteArray run(QString fileName, const QString &source);
// CPlusPlus::Client // CPlusPlus::Client
virtual void sourceNeeded(QString &fileName, IncludeType, unsigned) virtual void sourceNeeded(QString &fileName, IncludeType, unsigned);
{ mergeEnvironment(fileName); }
virtual void macroAdded(const Macro &) {} virtual void macroAdded(const Macro &) {}

View File

@@ -771,7 +771,11 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source,
} else { } else {
if (_dot->whitespace) { if (_dot->whitespace) {
const unsigned endOfPreviousToken = (_dot - 1)->end(); unsigned endOfPreviousToken = 0;
if (_dot != _tokens.constBegin())
endOfPreviousToken = (_dot - 1)->end();
const unsigned beginOfToken = _dot->begin(); const unsigned beginOfToken = _dot->begin();
const char *start = _source.constBegin() + endOfPreviousToken; const char *start = _source.constBegin() + endOfPreviousToken;

View File

@@ -107,6 +107,14 @@ SideBarWidget *SideBar::insertSideBarWidget(int position, const QString &title)
return item; return item;
} }
void SideBar::removeSideBarWidget(SideBarWidget *widget)
{
widget->removeCurrentItem();
m_widgets.removeOne(widget);
widget->hide();
widget->deleteLater();
}
void SideBar::split() void SideBar::split()
{ {
SideBarWidget *original = qobject_cast<SideBarWidget*>(sender()); SideBarWidget *original = qobject_cast<SideBarWidget*>(sender());
@@ -121,10 +129,7 @@ void SideBar::close()
SideBarWidget *widget = qobject_cast<SideBarWidget*>(sender()); SideBarWidget *widget = qobject_cast<SideBarWidget*>(sender());
if (!widget) if (!widget)
return; return;
widget->removeCurrentItem(); removeSideBarWidget(widget);
m_widgets.removeOne(widget);
widget->hide();
widget->deleteLater();
updateWidgets(); updateWidgets();
} }
} }
@@ -148,6 +153,9 @@ void SideBar::saveSettings(QSettings *settings)
void SideBar::readSettings(QSettings *settings) void SideBar::readSettings(QSettings *settings)
{ {
foreach (SideBarWidget *widget, m_widgets)
removeSideBarWidget(widget);
if (settings->contains("HelpSideBar/Views")) { if (settings->contains("HelpSideBar/Views")) {
QStringList views = settings->value("HelpSideBar/Views").toStringList(); QStringList views = settings->value("HelpSideBar/Views").toStringList();
if (views.count()) { if (views.count()) {

View File

@@ -31,6 +31,7 @@
#define SIDEBAR_H #define SIDEBAR_H
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtCore/QPointer>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
@@ -117,6 +118,8 @@ private slots:
private: private:
Internal::SideBarWidget *insertSideBarWidget(int position, Internal::SideBarWidget *insertSideBarWidget(int position,
const QString &title = QString()); const QString &title = QString());
void removeSideBarWidget(Internal::SideBarWidget *widget);
QList<Internal::SideBarWidget*> m_widgets; QList<Internal::SideBarWidget*> m_widgets;
QMap<QString, SideBarItem*> m_itemMap; QMap<QString, SideBarItem*> m_itemMap;

View File

@@ -165,6 +165,9 @@ DebuggerSettings *DebuggerSettings::instance()
item = new SavedAction(instance); item = new SavedAction(instance);
instance->insertItem(AssignType, item); instance->insertItem(AssignType, item);
item = new SavedAction(instance);
instance->insertItem(WatchPoint, item);
// //
// DebuggingHelper // DebuggingHelper
// //
@@ -173,18 +176,21 @@ DebuggerSettings *DebuggerSettings::instance()
item->setText(tr("Use debugging helper")); item->setText(tr("Use debugging helper"));
item->setCheckable(true); item->setCheckable(true);
item->setDefaultValue(true); item->setDefaultValue(true);
item->setValue(true);
instance->insertItem(UseDebuggingHelpers, item); instance->insertItem(UseDebuggingHelpers, item);
item = new SavedAction(instance); item = new SavedAction(instance);
item->setSettingsKey(debugModeGroup, QLatin1String("UseCustomDebuggingHelperLocation")); item->setSettingsKey(debugModeGroup, QLatin1String("UseCustomDebuggingHelperLocation"));
item->setCheckable(true); item->setCheckable(true);
item->setDefaultValue(false); item->setDefaultValue(false);
item->setValue(false);
instance->insertItem(UseCustomDebuggingHelperLocation, item); instance->insertItem(UseCustomDebuggingHelperLocation, item);
item = new SavedAction(instance); item = new SavedAction(instance);
item->setSettingsKey(debugModeGroup, QLatin1String("CustomDebuggingHelperLocation")); item->setSettingsKey(debugModeGroup, QLatin1String("CustomDebuggingHelperLocation"));
item->setCheckable(true); item->setCheckable(true);
item->setDefaultValue(QString()); item->setDefaultValue(QString());
item->setValue(QString());
instance->insertItem(CustomDebuggingHelperLocation, item); instance->insertItem(CustomDebuggingHelperLocation, item);
item = new SavedAction(instance); item = new SavedAction(instance);
@@ -192,6 +198,7 @@ DebuggerSettings *DebuggerSettings::instance()
item->setText(tr("Debug debugging helper")); item->setText(tr("Debug debugging helper"));
item->setCheckable(true); item->setCheckable(true);
item->setDefaultValue(false); item->setDefaultValue(false);
item->setValue(false);
instance->insertItem(DebugDebuggingHelpers, item); instance->insertItem(DebugDebuggingHelpers, item);

View File

@@ -94,7 +94,7 @@ enum DebuggerActionCode
WatchExpression, WatchExpression,
WatchExpressionInWindow, WatchExpressionInWindow,
RemoveWatchExpression, RemoveWatchExpression,
WatchModelUpdate, WatchPoint,
UseToolTips, UseToolTips,
AssignValue, AssignValue,
AssignType, AssignType,

View File

@@ -434,7 +434,8 @@ void DebuggerManager::init()
connect(theDebuggerAction(ExecuteCommand), SIGNAL(triggered()), connect(theDebuggerAction(ExecuteCommand), SIGNAL(triggered()),
this, SLOT(executeDebuggerCommand())); this, SLOT(executeDebuggerCommand()));
connect(theDebuggerAction(WatchPoint), SIGNAL(triggered()),
this, SLOT(watchPoint()));
m_breakDock = createDockForWidget(m_breakWindow); m_breakDock = createDockForWidget(m_breakWindow);
@@ -1089,6 +1090,13 @@ void DebuggerManager::nextIExec()
m_engine->nextIExec(); m_engine->nextIExec();
} }
void DebuggerManager::watchPoint()
{
if (QAction *action = qobject_cast<QAction *>(sender()))
if (m_engine)
m_engine->watchPoint(action->data().toPoint());
}
void DebuggerManager::executeDebuggerCommand() void DebuggerManager::executeDebuggerCommand()
{ {
if (QAction *action = qobject_cast<QAction *>(sender())) if (QAction *action = qobject_cast<QAction *>(sender()))

View File

@@ -318,6 +318,8 @@ public slots:
void executeDebuggerCommand(); void executeDebuggerCommand();
void executeDebuggerCommand(const QString &command); void executeDebuggerCommand(const QString &command);
void watchPoint();
void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever
private slots: private slots:

View File

@@ -58,8 +58,8 @@ using ProjectExplorer::ApplicationRunConfiguration;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// A factory to create DebuggerRunControls // A factory to create DebuggerRunControls
DebuggerRunner::DebuggerRunner(DebuggerManager *manager) : DebuggerRunner::DebuggerRunner(DebuggerManager *manager)
m_manager(manager) : m_manager(manager)
{} {}
bool DebuggerRunner::canRun(RunConfigurationPtr runConfiguration, const QString &mode) bool DebuggerRunner::canRun(RunConfigurationPtr runConfiguration, const QString &mode)
@@ -73,7 +73,7 @@ QString DebuggerRunner::displayName() const
return tr("Debug"); return tr("Debug");
} }
RunControl* DebuggerRunner::run(RunConfigurationPtr runConfiguration, RunControl *DebuggerRunner::run(RunConfigurationPtr runConfiguration,
const QString &mode, const QString &mode,
const QSharedPointer<DebuggerStartParameters> &sp, const QSharedPointer<DebuggerStartParameters> &sp,
DebuggerStartMode startMode) DebuggerStartMode startMode)
@@ -81,13 +81,13 @@ RunControl* DebuggerRunner::run(RunConfigurationPtr runConfiguration,
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0); QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0);
ApplicationRunConfigurationPtr rc = ApplicationRunConfigurationPtr rc =
runConfiguration.dynamicCast<ApplicationRunConfiguration>(); runConfiguration.dynamicCast<ApplicationRunConfiguration>();
Q_ASSERT(!rc.isNull()); QTC_ASSERT(!rc.isNull(), return 0);
//qDebug() << "***** Debugging" << rc->name() << rc->executable(); //qDebug() << "***** Debugging" << rc->name() << rc->executable();
DebuggerRunControl *runControl = new DebuggerRunControl(m_manager, startMode, sp, rc); DebuggerRunControl *runControl = new DebuggerRunControl(m_manager, startMode, sp, rc);
return runControl; return runControl;
} }
RunControl* DebuggerRunner::run(RunConfigurationPtr runConfiguration, RunControl *DebuggerRunner::run(RunConfigurationPtr runConfiguration,
const QString &mode) const QString &mode)
{ {
const QSharedPointer<DebuggerStartParameters> sp(new DebuggerStartParameters); const QSharedPointer<DebuggerStartParameters> sp(new DebuggerStartParameters);

View File

@@ -103,6 +103,42 @@ static int &currentToken()
return token; return token;
} }
// reads a MI-encoded item frome the consolestream
static bool parseConsoleStream(const GdbResultRecord &record, GdbMi *contents)
{
GdbMi output = record.data.findChild("consolestreamoutput");
QByteArray out = output.data();
int markerPos = out.indexOf('"') + 1; // position of 'success marker'
if (markerPos == 0 || out.at(markerPos) == 'f') { // 't' or 'f'
// custom dumper produced no output
return false;
}
out = out.mid(markerPos + 1);
out = out.left(out.lastIndexOf('"'));
// optimization: dumper output never needs real C unquoting
out.replace('\\', "");
out = "dummy={" + out + "}";
contents->fromString(out);
//qDebug() << "CONTENTS" << contents->toString(true);
return contents->isValid();
}
static QByteArray parsePlainConsoleStream(const GdbResultRecord &record)
{
GdbMi output = record.data.findChild("consolestreamoutput");
QByteArray out = output.data();
// FIXME: proper decoding needed
if (out.endsWith("\\n"))
out.chop(2);
while (out.endsWith('\n') || out.endsWith(' '))
out.chop(1);
int pos = out.indexOf(" = ");
return out.mid(pos + 3);
}
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// //
// GdbEngine // GdbEngine
@@ -2820,9 +2856,10 @@ static void setWatchDataSAddress(WatchData &data, const GdbMi &mi)
void GdbEngine::setUseDebuggingHelpers(const QVariant &on) void GdbEngine::setUseDebuggingHelpers(const QVariant &on)
{ {
qDebug() << "SWITCHING ON/OFF DUMPER DEBUGGING:" << on; //qDebug() << "SWITCHING ON/OFF DUMPER DEBUGGING:" << on;
// FIXME: a bit too harsh, but otherwise the treeview sometimes look funny // FIXME: a bit too harsh, but otherwise the treeview sometimes look funny
//m_expandedINames.clear(); //m_expandedINames.clear();
Q_UNUSED(on);
setTokenBarrier(); setTokenBarrier();
updateLocals(); updateLocals();
} }
@@ -3111,16 +3148,9 @@ void GdbEngine::handleQueryDebuggingHelper(const GdbResultRecord &record, const
{ {
m_dumperHelper.clear(); m_dumperHelper.clear();
//qDebug() << "DATA DUMPER TRIAL:" << record.toString(); //qDebug() << "DATA DUMPER TRIAL:" << record.toString();
GdbMi output = record.data.findChild("consolestreamoutput");
QByteArray out = output.data();
out = out.mid(out.indexOf('"') + 2); // + 1 is success marker
out = out.left(out.lastIndexOf('"'));
out.replace('\\', ""); // optimization: dumper output never needs real C unquoting
out = "dummy={" + out + "}";
//qDebug() << "OUTPUT:" << out;
GdbMi contents; GdbMi contents;
contents.fromString(out); QTC_ASSERT(parseConsoleStream(record, &contents), /**/);
GdbMi simple = contents.findChild("dumpers"); GdbMi simple = contents.findChild("dumpers");
m_dumperHelper.setQtNamespace(_(contents.findChild("namespace").data())); m_dumperHelper.setQtNamespace(_(contents.findChild("namespace").data()));
@@ -3281,11 +3311,7 @@ void GdbEngine::handleDebuggingHelperValue1(const GdbResultRecord &record,
if (record.resultClass == GdbResultDone) { if (record.resultClass == GdbResultDone) {
// ignore this case, data will follow // ignore this case, data will follow
} else if (record.resultClass == GdbResultError) { } else if (record.resultClass == GdbResultError) {
// Record an extra result, as the socket result will be lost
// in transmission
//--m_pendingRequests;
QString msg = QString::fromLocal8Bit(record.data.findChild("msg").data()); QString msg = QString::fromLocal8Bit(record.data.findChild("msg").data());
//qDebug() << "CUSTOM DUMPER ERROR MESSAGE:" << msg;
#ifdef QT_DEBUG #ifdef QT_DEBUG
// Make debugging of dumpers easier // Make debugging of dumpers easier
if (theDebuggerBoolSetting(DebugDebuggingHelpers) if (theDebuggerBoolSetting(DebugDebuggingHelpers)
@@ -3296,12 +3322,6 @@ void GdbEngine::handleDebuggingHelperValue1(const GdbResultRecord &record,
return; return;
} }
#endif #endif
//if (msg.startsWith("The program being debugged was sig"))
// msg = strNotInScope;
//if (msg.startsWith("The program being debugged stopped while"))
// msg = strNotInScope;
//data.setError(msg);
//insertData(data);
} }
} }
@@ -3310,6 +3330,7 @@ void GdbEngine::handleDebuggingHelperValue2(const GdbResultRecord &record,
{ {
WatchData data = cookie.value<WatchData>(); WatchData data = cookie.value<WatchData>();
QTC_ASSERT(data.isValid(), return); QTC_ASSERT(data.isValid(), return);
//qDebug() << "CUSTOM VALUE RESULT:" << record.toString(); //qDebug() << "CUSTOM VALUE RESULT:" << record.toString();
//qDebug() << "FOR DATA:" << data.toString() << record.resultClass; //qDebug() << "FOR DATA:" << data.toString() << record.resultClass;
if (record.resultClass != GdbResultDone) { if (record.resultClass != GdbResultDone) {
@@ -3317,26 +3338,8 @@ void GdbEngine::handleDebuggingHelperValue2(const GdbResultRecord &record,
return; return;
} }
GdbMi output = record.data.findChild("consolestreamoutput");
QByteArray out = output.data();
int markerPos = out.indexOf('"') + 1; // position of 'success marker'
if (markerPos == 0 || out.at(markerPos) == 'f') { // 't' or 'f'
// custom dumper produced no output
data.setError(strNotInScope);
insertData(data);
return;
}
out = out.mid(markerPos + 1);
out = out.left(out.lastIndexOf('"'));
out.replace('\\', ""); // optimization: dumper output never needs real C unquoting
out = "dummy={" + out + "}";
GdbMi contents; GdbMi contents;
contents.fromString(out); if (!parseConsoleStream(record, &contents)) {
//qDebug() << "CONTENTS" << contents.toString(true);
if (!contents.isValid()) {
data.setError(strNotInScope); data.setError(strNotInScope);
insertData(data); insertData(data);
return; return;
@@ -3759,60 +3762,6 @@ void GdbEngine::handleVarListChildren(const GdbResultRecord &record,
} }
} }
/*
void GdbEngine::handleToolTip(const GdbResultRecord &record,
const QVariant &cookie)
{
const QByteArray &what = cookie.toByteArray();
//qDebug() << "HANDLE TOOLTIP:" << what << m_toolTip.toString();
// << "record: " << record.toString();
if (record.resultClass == GdbResultError) {
if (what == "create") {
postCommand(_("ptype ") + m_toolTip.exp,
Discardable, CB(handleToolTip), QByteArray("ptype"));
return;
}
if (what == "evaluate") {
QByteArray msg = record.data.findChild("msg").data();
if (msg.startsWith("Cannot look up value of a typedef")) {
m_toolTip.value = tr("%1 is a typedef.").arg(m_toolTip.exp);
//return;
}
}
} else if (record.resultClass == GdbResultDone) {
if (what == "create") {
setWatchDataType(m_toolTip, record.data.findChild("type"));
setWatchDataChildCount(m_toolTip, record.data.findChild("numchild"));
if (hasDebuggingHelperForType(m_toolTip.type))
runDebuggingHelper(m_toolTip, false);
else
q->showStatusMessage(tr("Retrieving data for tooltip..."), 10000);
postCommand(_("-data-evaluate-expression ") + m_toolTip.exp,
Discardable, CB(handleToolTip), QByteArray("evaluate"));
return;
}
if (what == "evaluate") {
m_toolTip.value = m_toolTip.type + _c(' ') + m_toolTip.exp
+ _(" = " + record.data.findChild("value").data());
//return;
}
if (what == "ptype") {
GdbMi mi = record.data.findChild("consolestreamoutput");
m_toolTip.value = extractTypeFromPTypeOutput(_(mi.data()));
//return;
}
}
m_toolTip.iname = tooltipIName;
m_toolTip.setChildrenUnneeded();
m_toolTip.setHasChildrenUnneeded();
insertData(m_toolTip);
qDebug() << "DATA INSERTED";
QTimer::singleShot(0, this, SLOT(updateWatchModel2()));
qDebug() << "HANDLE TOOLTIP END";
}
*/
#if 0 #if 0
void GdbEngine::handleChangedItem(QStandardItem *item) void GdbEngine::handleChangedItem(QStandardItem *item)
{ {
@@ -3933,6 +3882,29 @@ bool GdbEngine::startModeAllowsDumpers() const
|| q->startMode() == AttachExternal; || q->startMode() == AttachExternal;
} }
void GdbEngine::watchPoint(const QPoint &pnt)
{
//qDebug() << "WATCH " << pnt;
postCommand(_("call (void*)watchPoint(%1,%2)").arg(pnt.x()).arg(pnt.y()),
NeedsStop, CB(handleWatchPoint));
}
void GdbEngine::handleWatchPoint(const GdbResultRecord &record, const QVariant &)
{
//qDebug() << "HANDLE WATCH POINT:" << record.toString();
if (record.resultClass == GdbResultDone) {
GdbMi contents = record.data.findChild("consolestreamoutput");
// "$5 = (void *) 0xbfa7ebfc\n"
QString str = _(parsePlainConsoleStream(record));
// "(void *) 0xbfa7ebfc"
QString addr = str.mid(9);
QString ns = m_dumperHelper.qtNamespace();
QString type = ns.isEmpty() ? _("QWidget*") : _("'%1QWidget'*").arg(ns);
QString exp = _("(*(%1)%2)").arg(type).arg(addr);
theDebuggerAction(WatchExpression)->trigger(exp);
}
}
IDebuggerEngine *createGdbEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *opts) IDebuggerEngine *createGdbEngine(DebuggerManager *parent, QList<Core::IOptionsPage*> *opts)
{ {
opts->push_back(new GdbOptionsPage); opts->push_back(new GdbOptionsPage);

View File

@@ -115,6 +115,7 @@ private:
void assignValueInDebugger(const QString &expr, const QString &value); void assignValueInDebugger(const QString &expr, const QString &value);
void executeDebuggerCommand(const QString & command); void executeDebuggerCommand(const QString & command);
void watchPoint(const QPoint &);
void loadSymbols(const QString &moduleName); void loadSymbols(const QString &moduleName);
void loadAllSymbols(); void loadAllSymbols();
@@ -220,6 +221,7 @@ private:
void handleExit(const GdbResultRecord &, const QVariant &); void handleExit(const GdbResultRecord &, const QVariant &);
void handleSetTargetAsync(const GdbResultRecord &, const QVariant &); void handleSetTargetAsync(const GdbResultRecord &, const QVariant &);
void handleTargetRemote(const GdbResultRecord &, const QVariant &); void handleTargetRemote(const GdbResultRecord &, const QVariant &);
void handleWatchPoint(const GdbResultRecord &, const QVariant &);
void debugMessage(const QString &msg); void debugMessage(const QString &msg);
bool showToolTip(); bool showToolTip();

View File

@@ -93,6 +93,8 @@ public:
virtual void reloadSourceFiles() = 0; virtual void reloadSourceFiles() = 0;
virtual void reloadFullStack() = 0; virtual void reloadFullStack() = 0;
virtual void watchPoint(const QPoint &) {}
}; };
} // namespace Internal } // namespace Internal

View File

@@ -82,16 +82,16 @@ static int generationCounter = 0;
class WatchItem : public WatchData class WatchItem : public WatchData
{ {
public: public:
WatchItem() { parent = 0; fetchedTriggered = 0; } WatchItem() { parent = 0; fetchTriggered = false; }
WatchItem(const WatchData &data) : WatchData(data) WatchItem(const WatchData &data) : WatchData(data)
{ parent = 0; fetchedTriggered = 0; } { parent = 0; fetchTriggered = false; }
void setData(const WatchData &data) void setData(const WatchData &data)
{ static_cast<WatchData &>(*this) = data; } { static_cast<WatchData &>(*this) = data; }
WatchItem *parent; WatchItem *parent;
bool fetchedTriggered; // children fetch has been triggered bool fetchTriggered; // children fetch has been triggered
QList<WatchItem *> children; // fetched children QList<WatchItem *> children; // fetched children
}; };
@@ -303,7 +303,7 @@ WatchModel::WatchModel(WatchHandler *handler, WatchType type)
item->hasChildren = true; item->hasChildren = true;
item->state = 0; item->state = 0;
item->parent = m_root; item->parent = m_root;
item->fetchedTriggered = true; item->fetchTriggered = true;
m_root->children.append(item); m_root->children.append(item);
} }
@@ -346,9 +346,11 @@ void WatchModel::removeOutdatedHelper(WatchItem *item)
{ {
if (item->generation < generationCounter) if (item->generation < generationCounter)
removeItem(item); removeItem(item);
else else {
foreach (WatchItem *child, item->children) foreach (WatchItem *child, item->children)
removeOutdatedHelper(child); removeOutdatedHelper(child);
item->fetchTriggered = false;
}
} }
void WatchModel::removeItem(WatchItem *item) void WatchModel::removeItem(WatchItem *item)
@@ -479,15 +481,15 @@ QString niceType(QString type)
bool WatchModel::canFetchMore(const QModelIndex &index) const bool WatchModel::canFetchMore(const QModelIndex &index) const
{ {
return index.isValid() && !watchItem(index)->fetchedTriggered; return index.isValid() && !watchItem(index)->fetchTriggered;
} }
void WatchModel::fetchMore(const QModelIndex &index) void WatchModel::fetchMore(const QModelIndex &index)
{ {
QTC_ASSERT(index.isValid(), return); QTC_ASSERT(index.isValid(), return);
QTC_ASSERT(!watchItem(index)->fetchedTriggered, return); QTC_ASSERT(!watchItem(index)->fetchTriggered, return);
if (WatchItem *item = watchItem(index)) { if (WatchItem *item = watchItem(index)) {
item->fetchedTriggered = true; item->fetchTriggered = true;
WatchData data = *item; WatchData data = *item;
data.setChildrenNeeded(); data.setChildrenNeeded();
emit m_handler->watchDataUpdateNeeded(data); emit m_handler->watchDataUpdateNeeded(data);

View File

@@ -376,6 +376,9 @@ QString decodeData(const QByteArray &ba, int encoding)
const QByteArray decodedBa = QByteArray::fromBase64(ba); const QByteArray decodedBa = QByteArray::fromBase64(ba);
return QString::fromUtf16(reinterpret_cast<const ushort *>(decodedBa.data()), decodedBa.size() / 2); return QString::fromUtf16(reinterpret_cast<const ushort *>(decodedBa.data()), decodedBa.size() / 2);
} }
case 5: { // base64 encoded 8 bit data, without quotes (see 1)
return quoteUnprintableLatin1(QByteArray::fromBase64(ba));
}
} }
return QCoreApplication::translate("Debugger", "<Encoding error>"); return QCoreApplication::translate("Debugger", "<Encoding error>");
} }

View File

@@ -114,6 +114,8 @@ public:
WatchWindow::WatchWindow(Type type, QWidget *parent) WatchWindow::WatchWindow(Type type, QWidget *parent)
: QTreeView(parent), m_alwaysResizeColumnsToContents(true), m_type(type) : QTreeView(parent), m_alwaysResizeColumnsToContents(true), m_type(type)
{ {
m_grabbing = false;
QAction *act = theDebuggerAction(UseAlternatingRowColors); QAction *act = theDebuggerAction(UseAlternatingRowColors);
setWindowTitle(tr("Locals and Watchers")); setWindowTitle(tr("Locals and Watchers"));
setAlternatingRowColors(act->isChecked()); setAlternatingRowColors(act->isChecked());
@@ -219,6 +221,8 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
QAction *act3 = new QAction(tr("Insert new watch item"), &menu); QAction *act3 = new QAction(tr("Insert new watch item"), &menu);
menu.addAction(act3); menu.addAction(act3);
QAction *act4 = new QAction(tr("Select widget to watch"), &menu);
menu.addAction(act4);
menu.addSeparator(); menu.addSeparator();
menu.addAction(theDebuggerAction(RecheckDebuggingHelpers)); menu.addAction(theDebuggerAction(RecheckDebuggingHelpers));
@@ -233,7 +237,12 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
else if (act == act2) else if (act == act2)
setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents); setAlwaysResizeColumnsToContents(!m_alwaysResizeColumnsToContents);
else if (act == act3) else if (act == act3)
theDebuggerAction(WatchExpression)->trigger(WatchHandler::watcherEditPlaceHolder()); theDebuggerAction(WatchExpression)
->trigger(WatchHandler::watcherEditPlaceHolder());
else if (act == act4) {
grabMouse(Qt::CrossCursor);
m_grabbing = true;
}
} }
void WatchWindow::resizeColumnsToContents() void WatchWindow::resizeColumnsToContents()
@@ -253,6 +262,17 @@ void WatchWindow::setAlwaysResizeColumnsToContents(bool on)
header()->setResizeMode(1, mode); header()->setResizeMode(1, mode);
} }
bool WatchWindow::event(QEvent *ev)
{
if (m_grabbing && ev->type() == QEvent::MouseButtonPress) {
QMouseEvent *mev = static_cast<QMouseEvent *>(ev);
m_grabbing = false;
releaseMouse();
theDebuggerAction(WatchPoint)->trigger(mapToGlobal(mev->pos()));
}
return QTreeView::event(ev);
}
void WatchWindow::editItem(const QModelIndex &idx) void WatchWindow::editItem(const QModelIndex &idx)
{ {
Q_UNUSED(idx); // FIXME Q_UNUSED(idx); // FIXME

View File

@@ -69,13 +69,14 @@ private:
void dragEnterEvent(QDragEnterEvent *ev); void dragEnterEvent(QDragEnterEvent *ev);
void dropEvent(QDropEvent *ev); void dropEvent(QDropEvent *ev);
void dragMoveEvent(QDragMoveEvent *ev); void dragMoveEvent(QDragMoveEvent *ev);
bool event(QEvent *ev);
void editItem(const QModelIndex &idx); void editItem(const QModelIndex &idx);
void resetHelper(const QModelIndex &idx); void resetHelper(const QModelIndex &idx);
bool m_alwaysResizeColumnsToContents; bool m_alwaysResizeColumnsToContents;
Type m_type; Type m_type;
bool m_grabbing;
}; };

View File

@@ -5,11 +5,14 @@ DEFINES+=CPP_ENABLED
HEADERS+=$$PWD/formclasswizardpage.h \ HEADERS+=$$PWD/formclasswizardpage.h \
$$PWD/formclasswizarddialog.h \ $$PWD/formclasswizarddialog.h \
$$PWD/formclasswizard.h \ $$PWD/formclasswizard.h \
$$PWD/formclasswizardparameters.h $$PWD/formclasswizardparameters.h \
$$PWD/cppsettingspage.h
SOURCES+=$$PWD/formclasswizardpage.cpp \ SOURCES+=$$PWD/formclasswizardpage.cpp \
$$PWD/formclasswizarddialog.cpp \ $$PWD/formclasswizarddialog.cpp \
$$PWD/formclasswizard.cpp \ $$PWD/formclasswizard.cpp \
$$PWD/formclasswizardparameters.cpp $$PWD/formclasswizardparameters.cpp \
$$PWD/cppsettingspage.cpp
FORMS+=$$PWD/formclasswizardpage.ui FORMS+=$$PWD/formclasswizardpage.ui \
$$PWD/cppsettingspagewidget.ui

View File

@@ -0,0 +1,136 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
**
**************************************************************************/
#include "cppsettingspage.h"
#include "designerconstants.h"
#include <QtCore/QCoreApplication>
#include <coreplugin/icore.h>
namespace Designer {
namespace Internal {
// ---------- CppSettingsPageWidget
CppSettingsPageWidget::CppSettingsPageWidget(QWidget *parent) :
QWidget(parent)
{
m_ui.setupUi(this);
}
FormClassWizardGenerationParameters CppSettingsPageWidget::parameters() const
{
FormClassWizardGenerationParameters rc;
rc.setEmbedding(static_cast<FormClassWizardGenerationParameters::UiClassEmbedding>(uiEmbedding()));
rc.setRetranslationSupport(m_ui.retranslateCheckBox->isChecked());
rc.setIncludeQtModule(m_ui.includeQtModuleCheckBox->isChecked());
return rc;
}
void CppSettingsPageWidget::setParameters(const FormClassWizardGenerationParameters &p)
{
m_ui.retranslateCheckBox->setChecked(p.retranslationSupport());
m_ui.includeQtModuleCheckBox->setChecked(p.includeQtModule());
setUiEmbedding(p.embedding());
}
int CppSettingsPageWidget::uiEmbedding() const
{
if (m_ui.ptrAggregationRadioButton->isChecked())
return FormClassWizardGenerationParameters::PointerAggregatedUiClass;
if (m_ui.aggregationButton->isChecked())
return FormClassWizardGenerationParameters::AggregatedUiClass;
return FormClassWizardGenerationParameters::InheritedUiClass;
}
void CppSettingsPageWidget::setUiEmbedding(int v)
{
switch (v) {
case FormClassWizardGenerationParameters::PointerAggregatedUiClass:
m_ui.ptrAggregationRadioButton->setChecked(true);
break;
case FormClassWizardGenerationParameters::AggregatedUiClass:
m_ui.aggregationButton->setChecked(true);
break;
case FormClassWizardGenerationParameters::InheritedUiClass:
m_ui.multipleInheritanceButton->setChecked(true);
break;
}
}
// ---------- CppSettingsPage
CppSettingsPage::CppSettingsPage(QObject *parent) : Core::IOptionsPage(parent)
{
m_parameters.fromSettings(Core::ICore::instance()->settings());
}
QString CppSettingsPage::id() const
{
return QLatin1String(Designer::Constants::SETTINGS_CPP_SETTINGS);
}
QString CppSettingsPage::trName() const
{
return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_CPP_SETTINGS);
}
QString CppSettingsPage::category() const
{
return QLatin1String(Designer::Constants::SETTINGS_CATEGORY);
}
QString CppSettingsPage::trCategory() const
{
return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_CATEGORY);
}
QWidget *CppSettingsPage::createPage(QWidget *parent)
{
m_widget = new CppSettingsPageWidget(parent);
m_widget->setParameters(m_parameters);
return m_widget;
}
void CppSettingsPage::apply()
{
if (m_widget) {
const FormClassWizardGenerationParameters newParameters = m_widget->parameters();
if (newParameters != m_parameters) {
m_parameters = newParameters;
m_parameters.toSettings(Core::ICore::instance()->settings());
}
}
}
void CppSettingsPage::finish()
{
}
} // namespace Internal
} // namespace Designer

View File

@@ -0,0 +1,81 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://www.qtsoftware.com/contact.
**
**************************************************************************/
#ifndef CPPSETTINGSPAGE_H
#define CPPSETTINGSPAGE_H
#include "formclasswizardparameters.h"
#include "ui_cppsettingspagewidget.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <QtCore/QPointer>
namespace Designer {
namespace Internal {
class CppSettingsPageWidget : public QWidget
{
Q_OBJECT
public:
explicit CppSettingsPageWidget(QWidget *parent = 0);
FormClassWizardGenerationParameters parameters() const;
void setParameters(const FormClassWizardGenerationParameters &p);
private:
int uiEmbedding() const;
void setUiEmbedding(int);
Ui::CppSettingsPageWidget m_ui;
};
class CppSettingsPage : public Core::IOptionsPage
{
public:
explicit CppSettingsPage(QObject *parent = 0);
virtual QString id() const;
virtual QString trName() const;
virtual QString category() const;
virtual QString trCategory() const;
virtual QWidget *createPage(QWidget *parent);
virtual void apply();
virtual void finish();
private:
QPointer<CppSettingsPageWidget> m_widget;
FormClassWizardGenerationParameters m_parameters;
};
} // namespace Internal
} // namespace Designer
#endif // CPPSETTINGSPAGE_H

View File

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Designer::Internal::CppSettingsPageWidget</class>
<widget class="QWidget" name="Designer::Internal::CppSettingsPageWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>526</width>
<height>369</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="uiclassGroupBox">
<property name="title">
<string>Embedding of the UI Class</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="ptrAggregationRadioButton">
<property name="text">
<string>Aggregation as a pointer member</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="aggregationButton">
<property name="text">
<string>Aggregation</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="multipleInheritanceButton">
<property name="text">
<string>Multiple Inheritance</string>
</property>
</widget>
</item>
</layout>
<zorder>aggregationButton</zorder>
<zorder>multipleInheritanceButton</zorder>
<zorder>ptrAggregationRadioButton</zorder>
</widget>
</item>
<item>
<widget class="QGroupBox" name="codeGenerationGroupBox">
<property name="title">
<string>Code Generation</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="retranslateCheckBox">
<property name="text">
<string>Support for changing languages at runtime</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="includeQtModuleCheckBox">
<property name="text">
<string>Include Qt module name</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>169</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -87,17 +87,17 @@ QWizard *FormClassWizard::createWizardDialog(QWidget *parent,
Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *errorMessage) const Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *errorMessage) const
{ {
const FormClassWizardDialog *wizardDialog = qobject_cast<const FormClassWizardDialog *>(w); const FormClassWizardDialog *wizardDialog = qobject_cast<const FormClassWizardDialog *>(w);
const FormClassWizardParameters params = wizardDialog->parameters(); const Designer::FormClassWizardParameters params = wizardDialog->parameters();
if (params.uiTemplate.isEmpty()) { if (params.uiTemplate().isEmpty()) {
*errorMessage = QLatin1String("Internal error: FormClassWizard::generateFiles: empty template contents"); *errorMessage = QLatin1String("Internal error: FormClassWizard::generateFiles: empty template contents");
return Core::GeneratedFiles(); return Core::GeneratedFiles();
} }
// header // header
const QString formFileName = buildFileName(params.path, params.uiFile, formSuffix()); const QString formFileName = buildFileName(params.path(), params.uiFile(), formSuffix());
const QString headerFileName = buildFileName(params.path, params.headerFile, headerSuffix()); const QString headerFileName = buildFileName(params.path(), params.headerFile(), headerSuffix());
const QString sourceFileName = buildFileName(params.path, params.sourceFile, sourceSuffix()); const QString sourceFileName = buildFileName(params.path(), params.sourceFile(), sourceSuffix());
Core::GeneratedFile headerFile(headerFileName); Core::GeneratedFile headerFile(headerFileName);
headerFile.setEditorKind(QLatin1String(CppEditor::Constants::CPPEDITOR_KIND)); headerFile.setEditorKind(QLatin1String(CppEditor::Constants::CPPEDITOR_KIND));
@@ -108,11 +108,13 @@ Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *e
// UI // UI
Core::GeneratedFile uiFile(formFileName); Core::GeneratedFile uiFile(formFileName);
uiFile.setContents(params.uiTemplate); uiFile.setContents(params.uiTemplate());
uiFile.setEditorKind(QLatin1String(Constants::C_FORMEDITOR)); uiFile.setEditorKind(QLatin1String(Constants::C_FORMEDITOR));
QString source, header; QString source, header;
params.generateCpp(&header, &source); Designer::FormClassWizardGenerationParameters generationParameters;
generationParameters.fromSettings(Core::ICore::instance()->settings());
params.generateCpp(generationParameters, &header, &source);
sourceFile.setContents(source); sourceFile.setContents(source);
headerFile.setContents(header); headerFile.setContents(header);

View File

@@ -98,7 +98,7 @@ FormClassWizardParameters FormClassWizardDialog::parameters() const
FormClassWizardParameters rc; FormClassWizardParameters rc;
m_classPage->getParameters(&rc); m_classPage->getParameters(&rc);
// Name the ui class in the Ui namespace after the class specified // Name the ui class in the Ui namespace after the class specified
rc.uiTemplate = FormTemplateWizardPage::changeUiClassName(m_rawFormTemplate, rc.className); rc.setUiTemplate(FormTemplateWizardPage::changeUiClassName(m_rawFormTemplate, rc.className()));
return rc; return rc;
} }

View File

@@ -37,9 +37,12 @@ namespace Core {
} }
namespace Designer { namespace Designer {
namespace Internal {
struct FormClassWizardParameters; struct FormClassWizardParameters;
namespace Internal {
class FormClassWizardPage; class FormClassWizardPage;
class FormTemplateWizardPage; class FormTemplateWizardPage;
@@ -56,7 +59,7 @@ public:
QString path() const; QString path() const;
FormClassWizardParameters parameters() const; Designer::FormClassWizardParameters parameters() const;
bool validateCurrentPage(); bool validateCurrentPage();

View File

@@ -43,10 +43,6 @@
#include <QtGui/QAbstractButton> #include <QtGui/QAbstractButton>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
static const char *formClassWizardPageGroupC = "FormClassWizardPage";
static const char *translationKeyC = "RetranslationSupport";
static const char *embeddingModeKeyC = "Embedding";
namespace Designer { namespace Designer {
namespace Internal { namespace Internal {
@@ -64,13 +60,7 @@ FormClassWizardPage::FormClassWizardPage(QWidget * parent) :
m_ui->newClassWidget->setAllowDirectories(true); m_ui->newClassWidget->setAllowDirectories(true);
connect(m_ui->newClassWidget, SIGNAL(validChanged()), this, SLOT(slotValidChanged())); connect(m_ui->newClassWidget, SIGNAL(validChanged()), this, SLOT(slotValidChanged()));
m_ui->extensionWidget->setVisible(false);
connect(m_ui->moreButton, SIGNAL(clicked(bool)), m_ui->extensionWidget, SLOT(setVisible(bool)));
connect(m_ui->settingsToolButton, SIGNAL(clicked()), this, SLOT(slotSettings())); connect(m_ui->settingsToolButton, SIGNAL(clicked()), this, SLOT(slotSettings()));
restoreSettings();
} }
FormClassWizardPage::~FormClassWizardPage() FormClassWizardPage::~FormClassWizardPage()
@@ -79,13 +69,13 @@ FormClassWizardPage::~FormClassWizardPage()
} }
// Retrieve settings of CppTools plugin. // Retrieve settings of CppTools plugin.
static inline bool lowerCaseFiles(const Core::ICore *core) static bool inline lowerCaseFiles(const Core::ICore *core)
{ {
QString camelCaseSettingsKey = QLatin1String(CppTools::Constants::CPPTOOLS_SETTINGSGROUP); QString lowerCaseSettingsKey = QLatin1String(CppTools::Constants::CPPTOOLS_SETTINGSGROUP);
camelCaseSettingsKey += QLatin1Char('/'); lowerCaseSettingsKey += QLatin1Char('/');
camelCaseSettingsKey += QLatin1String(CppTools::Constants::LOWERCASE_CPPFILES_KEY); lowerCaseSettingsKey += QLatin1String(CppTools::Constants::LOWERCASE_CPPFILES_KEY);
return core->settings()->value(camelCaseSettingsKey, QVariant(false)).toBool(); return core->settings()->value(lowerCaseSettingsKey, QVariant(false)).toBool();
} }
// Set up new class widget from settings // Set up new class widget from settings
@@ -115,40 +105,6 @@ void FormClassWizardPage::setClassName(const QString &suggestedClassName)
slotValidChanged(); slotValidChanged();
} }
int FormClassWizardPage::uiClassEmbedding() const
{
if (m_ui->ptrAggregationRadioButton->isChecked())
return PointerAggregatedUiClass;
if (m_ui->aggregationButton->isChecked())
return AggregatedUiClass;
return InheritedUiClass;
}
void FormClassWizardPage::setUiClassEmbedding(int v)
{
switch (v) {
case PointerAggregatedUiClass:
m_ui->ptrAggregationRadioButton->setChecked(true);
break;
case AggregatedUiClass:
m_ui->aggregationButton->setChecked(true);
break;
case InheritedUiClass:
m_ui->multipleInheritanceButton->setChecked(true);
break;
}
}
bool FormClassWizardPage::hasRetranslationSupport() const
{
return m_ui->retranslateCheckBox->isChecked();
}
void FormClassWizardPage::setRetranslationSupport(bool v)
{
m_ui->retranslateCheckBox->setChecked(v);
}
QString FormClassWizardPage::path() const QString FormClassWizardPage::path() const
{ {
return m_ui->newClassWidget->path(); return m_ui->newClassWidget->path();
@@ -161,13 +117,11 @@ void FormClassWizardPage::setPath(const QString &p)
void FormClassWizardPage::getParameters(FormClassWizardParameters *p) const void FormClassWizardPage::getParameters(FormClassWizardParameters *p) const
{ {
p->embedding = static_cast<UiClassEmbedding>(uiClassEmbedding()); p->setClassName(m_ui->newClassWidget->className());
p->languageChange = m_ui->retranslateCheckBox->isChecked(); p->setPath(path());
p->className = m_ui->newClassWidget->className(); p->setSourceFile(m_ui->newClassWidget->sourceFileName());
p->path = path(); p->setHeaderFile(m_ui->newClassWidget->headerFileName());
p->sourceFile = m_ui->newClassWidget->sourceFileName(); p->setUiFile(m_ui->newClassWidget-> formFileName());
p->headerFile = m_ui->newClassWidget->headerFileName();
p->uiFile = m_ui->newClassWidget-> formFileName();
} }
void FormClassWizardPage::slotValidChanged() void FormClassWizardPage::slotValidChanged()
@@ -188,47 +142,11 @@ bool FormClassWizardPage::validatePage()
{ {
QString errorMessage; QString errorMessage;
const bool rc = m_ui->newClassWidget->isValid(&errorMessage); const bool rc = m_ui->newClassWidget->isValid(&errorMessage);
if (rc) { if (!rc) {
saveSettings();
} else {
QMessageBox::critical(this, tr("%1 - Error").arg(title()), errorMessage); QMessageBox::critical(this, tr("%1 - Error").arg(title()), errorMessage);
} }
return rc; return rc;
} }
void FormClassWizardPage::saveSettings()
{
Core::ICore *core = Core::ICore::instance();
if (QSettings *settings = core->settings()) {
settings->beginGroup(QLatin1String(formClassWizardPageGroupC));
settings->setValue(QLatin1String(translationKeyC), hasRetranslationSupport());
settings->setValue(QLatin1String(embeddingModeKeyC), uiClassEmbedding());
settings->endGroup();
}
}
void FormClassWizardPage::restoreSettings()
{
bool retranslationSupport = true;
int embedding = PointerAggregatedUiClass;
Core::ICore *core = Core::ICore::instance();
if (QSettings *settings = core->settings()) {
QString key = QLatin1String(formClassWizardPageGroupC);
key += QLatin1Char('/');
const int groupLength = key.size();
key += QLatin1String(translationKeyC);
retranslationSupport = settings->value(key, retranslationSupport).toBool();
key.truncate(groupLength);
key += QLatin1String(embeddingModeKeyC);
embedding = settings->value(key, embedding).toInt();
}
setUiClassEmbedding(embedding);
setRetranslationSupport(retranslationSupport);
}
} // namespace Internal } // namespace Internal
} // namespace Designer } // namespace Designer

View File

@@ -33,13 +33,16 @@
#include <QtGui/QWizardPage> #include <QtGui/QWizardPage>
namespace Designer { namespace Designer {
struct FormClassWizardParameters;
struct FormClassWizardGenerationParameters;
namespace Internal { namespace Internal {
namespace Ui { namespace Ui {
class FormClassWizardPage; class FormClassWizardPage;
} }
struct FormClassWizardParameters;
class FormClassWizardPage : public QWizardPage class FormClassWizardPage : public QWizardPage
{ {
@@ -52,18 +55,17 @@ public:
virtual bool isComplete () const; virtual bool isComplete () const;
virtual bool validatePage(); virtual bool validatePage();
int uiClassEmbedding() const;
bool hasRetranslationSupport() const;
QString path() const; QString path() const;
// Fill out applicable parameters // Fill out applicable parameters
void getParameters(FormClassWizardParameters *) const; void getParameters(FormClassWizardParameters *) const;
FormClassWizardGenerationParameters generationParameters() const;
void setGenerationParameters(const FormClassWizardGenerationParameters &gp);
public slots: public slots:
void setClassName(const QString &suggestedClassName); void setClassName(const QString &suggestedClassName);
void setPath(const QString &); void setPath(const QString &);
void setRetranslationSupport(bool);
void setUiClassEmbedding(int v);
void slotSettings(); void slotSettings();
private slots: private slots:
@@ -71,8 +73,6 @@ private slots:
private: private:
void initParameters(); void initParameters();
void saveSettings();
void restoreSettings();
Ui::FormClassWizardPage *m_ui; Ui::FormClassWizardPage *m_ui;
bool m_isValid; bool m_isValid;

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>552</width> <width>542</width>
<height>498</height> <height>267</height>
</rect> </rect>
</property> </property>
<property name="title"> <property name="title">
@@ -21,7 +21,7 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="Core::Utils::NewClassWidget" name="newClassWidget" native="true"/> <widget class="Core::Utils::NewClassWidget" name="newClassWidget"/>
</item> </item>
</layout> </layout>
</widget> </widget>
@@ -48,114 +48,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="moreButton">
<property name="text">
<string>More</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="1" column="0">
<widget class="QWidget" name="extensionWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="uiclassGroupBox">
<property name="title">
<string>Embedding of the UI class</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="ptrAggregationRadioButton">
<property name="text">
<string>Aggregation as a pointer member</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="aggregationButton">
<property name="text">
<string>Aggregation</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="multipleInheritanceButton">
<property name="text">
<string>Multiple Inheritance</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
</layout>
<zorder>aggregationButton</zorder>
<zorder>multipleInheritanceButton</zorder>
<zorder>ptrAggregationRadioButton</zorder>
</widget>
</item>
<item>
<widget class="QGroupBox" name="variousGroupBox">
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="retranslateCheckBox">
<property name="text">
<string>Support for changing languages at runtime</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>57</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>

View File

@@ -34,32 +34,298 @@
#include <cpptools/cppmodelmanagerinterface.h> #include <cpptools/cppmodelmanagerinterface.h>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>
#include <QtCore/QSettings>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QSharedData>
static const char *uiMemberC = "m_ui"; static const char *uiMemberC = "m_ui";
static const char *uiNamespaceC = "Ui"; static const char *uiNamespaceC = "Ui";
namespace Designer { static const char *formClassWizardPageGroupC = "FormClassWizardPage";
namespace Internal { static const char *translationKeyC = "RetranslationSupport";
static const char *embeddingModeKeyC = "Embedding";
FormClassWizardParameters::FormClassWizardParameters() : // TODO: These 2 are general coding convention settings and
embedding(PointerAggregatedUiClass), // should go to CppTools...
languageChange(true) static const char *includeQtModuleKeyC = "IncludeQtModule";
static const char *indentNamespaceKeyC = "IndentNamespace";
namespace Designer {
class FormClassWizardGenerationParametersPrivate : public QSharedData
{
public:
FormClassWizardGenerationParametersPrivate();
void fromSettings(const QSettings *);
void toSettings(QSettings *) const;
bool equals(const FormClassWizardGenerationParametersPrivate &rhs) const;
FormClassWizardGenerationParameters::UiClassEmbedding embedding;
bool retranslationSupport; // Add handling for language change events
bool includeQtModule; // Include "<QtGui/[Class]>" or just "<[Class]>"
bool indentNamespace;
};
FormClassWizardGenerationParametersPrivate::FormClassWizardGenerationParametersPrivate() :
embedding(FormClassWizardGenerationParameters::PointerAggregatedUiClass),
retranslationSupport(true),
includeQtModule(false),
indentNamespace(false)
{ {
} }
bool FormClassWizardParameters::generateCpp(QString *header, QString *source, int indentation) const void FormClassWizardGenerationParametersPrivate::fromSettings(const QSettings *settings)
{
QString key = QLatin1String(formClassWizardPageGroupC);
key += QLatin1Char('/');
const int groupLength = key.size();
key += QLatin1String(translationKeyC);
retranslationSupport = settings->value(key, true).toBool();
key.truncate(groupLength);
key += QLatin1String(embeddingModeKeyC);
embedding = static_cast<FormClassWizardGenerationParameters::UiClassEmbedding>(settings->value(key, int(FormClassWizardGenerationParameters::PointerAggregatedUiClass)).toInt());
key.truncate(groupLength);
key += QLatin1String(includeQtModuleKeyC);
includeQtModule = settings->value(key, false).toBool();
key.truncate(groupLength);
key += QLatin1String(indentNamespaceKeyC);
indentNamespace = settings->value(key, false).toBool();
}
void FormClassWizardGenerationParametersPrivate::toSettings(QSettings *settings) const
{
settings->beginGroup(QLatin1String(formClassWizardPageGroupC));
settings->setValue(QLatin1String(translationKeyC), retranslationSupport);
settings->setValue(QLatin1String(embeddingModeKeyC), embedding);
settings->setValue(QLatin1String(includeQtModuleKeyC), includeQtModule);
settings->setValue(QLatin1String(indentNamespaceKeyC), indentNamespace);
settings->endGroup();
}
bool FormClassWizardGenerationParametersPrivate::equals(const FormClassWizardGenerationParametersPrivate &rhs) const
{
return embedding == rhs.embedding && retranslationSupport == rhs.retranslationSupport
&& includeQtModule == rhs.includeQtModule && indentNamespace == rhs.indentNamespace;
}
FormClassWizardGenerationParameters::FormClassWizardGenerationParameters() :
m_d(new FormClassWizardGenerationParametersPrivate)
{
}
FormClassWizardGenerationParameters::~FormClassWizardGenerationParameters()
{
}
FormClassWizardGenerationParameters::FormClassWizardGenerationParameters(const FormClassWizardGenerationParameters &rhs) :
m_d(rhs.m_d)
{
}
FormClassWizardGenerationParameters &FormClassWizardGenerationParameters::operator=(const FormClassWizardGenerationParameters &rhs)
{
if (this != &rhs)
m_d.operator=(rhs.m_d);
return *this;
}
bool FormClassWizardGenerationParameters::equals(const FormClassWizardGenerationParameters &rhs) const
{
return m_d->equals(*rhs.m_d.constData());
}
FormClassWizardGenerationParameters::UiClassEmbedding FormClassWizardGenerationParameters::embedding() const
{
return m_d->embedding;
}
void FormClassWizardGenerationParameters::setEmbedding(UiClassEmbedding e)
{
m_d->embedding = e;
}
bool FormClassWizardGenerationParameters::retranslationSupport() const
{
return m_d->retranslationSupport;
}
void FormClassWizardGenerationParameters::setRetranslationSupport(bool v)
{
m_d->retranslationSupport = v;
}
bool FormClassWizardGenerationParameters::includeQtModule() const
{
return m_d->includeQtModule;
}
void FormClassWizardGenerationParameters::setIncludeQtModule(bool v)
{
m_d->includeQtModule = v;
}
bool FormClassWizardGenerationParameters::indentNamespace() const
{
return m_d->indentNamespace;
}
void FormClassWizardGenerationParameters::setIndentNamespace(bool v)
{
m_d->indentNamespace = v;
}
void FormClassWizardGenerationParameters::fromSettings(const QSettings *settings)
{
m_d->fromSettings(settings);
}
void FormClassWizardGenerationParameters::toSettings(QSettings *settings) const
{
m_d->toSettings(settings);
}
// -----------
class FormClassWizardParametersPrivate : public QSharedData {
public:
bool generateCpp(const FormClassWizardGenerationParameters &fgp,
QString *header, QString *source, int indentation) const;
QString uiTemplate;
QString className;
QString path;
QString sourceFile;
QString headerFile;
QString uiFile;
};
FormClassWizardParameters::FormClassWizardParameters() :
m_d(new FormClassWizardParametersPrivate)
{
}
FormClassWizardParameters::~FormClassWizardParameters()
{
}
FormClassWizardParameters::FormClassWizardParameters(const FormClassWizardParameters &rhs) :
m_d(rhs.m_d)
{
}
FormClassWizardParameters &FormClassWizardParameters::operator=(const FormClassWizardParameters &rhs)
{
if (this != &rhs)
m_d.operator =(rhs.m_d);
return *this;
}
QString FormClassWizardParameters::uiTemplate() const
{
return m_d->uiTemplate;
}
void FormClassWizardParameters::setUiTemplate(const QString &s)
{
m_d->uiTemplate = s;
}
QString FormClassWizardParameters::className() const
{
return m_d->className;
}
void FormClassWizardParameters::setClassName(const QString &s)
{
m_d->className = s;
}
QString FormClassWizardParameters::path() const
{
return m_d->path;
}
void FormClassWizardParameters::setPath(const QString &s)
{
m_d->path = s;
}
QString FormClassWizardParameters::sourceFile() const
{
return m_d->sourceFile;
}
void FormClassWizardParameters::setSourceFile(const QString &s)
{
m_d->sourceFile = s;
}
QString FormClassWizardParameters::headerFile() const
{
return m_d->headerFile;
}
void FormClassWizardParameters::setHeaderFile(const QString &s)
{
m_d->headerFile = s;
}
QString FormClassWizardParameters::uiFile() const
{
return m_d->uiFile;
}
void FormClassWizardParameters::setUiFile(const QString &s)
{
m_d->uiFile = s;
}
bool FormClassWizardParameters::getUIXmlData(const QString &uiXml, QString *formBaseClass, QString *uiClassName)
{
return Designer::Internal::FormTemplateWizardPage::getUIXmlData(uiXml, formBaseClass, uiClassName);
}
QString FormClassWizardParameters::changeUiClassName(const QString &uiXml, const QString &newUiClassName)
{
return Designer::Internal::FormTemplateWizardPage::changeUiClassName(uiXml, newUiClassName);
}
// Write out how to access the Ui class in the source code.
static inline void writeUiMemberAccess(const FormClassWizardGenerationParameters &fp, QTextStream &str)
{
switch(fp.embedding()) {
case FormClassWizardGenerationParameters::PointerAggregatedUiClass:
str << uiMemberC << "->";
break;
case FormClassWizardGenerationParameters::AggregatedUiClass:
str << uiMemberC << '.';
break;
case FormClassWizardGenerationParameters::InheritedUiClass:
break;
}
}
bool FormClassWizardParametersPrivate::generateCpp(const FormClassWizardGenerationParameters &generationParameters,
QString *header, QString *source, int indentation) const
{ {
const QString indent = QString(indentation, QLatin1Char(' ')); const QString indent = QString(indentation, QLatin1Char(' '));
QString formBaseClass; QString formBaseClass;
QString uiClassName; QString uiClassName;
if (!FormTemplateWizardPage::getUIXmlData(uiTemplate, &formBaseClass, &uiClassName)) { if (!FormClassWizardParameters::getUIXmlData(uiTemplate, &formBaseClass, &uiClassName)) {
qWarning("Unable to determine the form base class from %s.", uiTemplate.toUtf8().constData()); qWarning("Unable to determine the form base class from %s.", uiTemplate.toUtf8().constData());
return false; return false;
} }
// Build the ui class (Ui::Foo) name relative to the namespace (which is the same): // Build the ui class (Ui::Foo) name relative to the namespace (which is the same):
const FormClassWizardGenerationParameters::UiClassEmbedding embedding = generationParameters.embedding();
const QString colonColon = QLatin1String("::"); const QString colonColon = QLatin1String("::");
const int lastSeparator = uiClassName.lastIndexOf(colonColon); const int lastSeparator = uiClassName.lastIndexOf(colonColon);
if (lastSeparator != -1) if (lastSeparator != -1)
@@ -87,88 +353,89 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
<< "\n#define " << guard << '\n' << '\n'; << "\n#define " << guard << '\n' << '\n';
// Include 'ui_' // Include 'ui_'
if (embedding != PointerAggregatedUiClass) { if (embedding != FormClassWizardGenerationParameters::PointerAggregatedUiClass) {
Core::Utils::writeIncludeFileDirective(uiInclude, false, headerStr); Core::Utils::writeIncludeFileDirective(uiInclude, false, headerStr);
} else { } else {
// Todo: Can we obtain the header from the code model for custom widgets? // Todo: Can we obtain the header from the code model for custom widgets?
// Alternatively, from Designer. // Alternatively, from Designer.
if (formBaseClass.startsWith(QLatin1Char('Q'))) { if (formBaseClass.startsWith(QLatin1Char('Q'))) {
QString baseInclude = QLatin1String("QtGui/"); QString baseInclude = formBaseClass;
baseInclude += formBaseClass; if (generationParameters.includeQtModule())
baseInclude.insert(0, QLatin1String("QtGui/"));
Core::Utils::writeIncludeFileDirective(baseInclude, true, headerStr); Core::Utils::writeIncludeFileDirective(baseInclude, true, headerStr);
} }
} }
const QString namespaceIndent = Core::Utils::writeOpeningNameSpaces(namespaceList, indent, headerStr); const QString namespaceIndent = Core::Utils::writeOpeningNameSpaces(namespaceList,
generationParameters.indentNamespace() ? indent : QString(),
headerStr);
// Forward-declare the UI class // Forward-declare the UI class
if (embedding == PointerAggregatedUiClass) { if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass) {
headerStr << '\n' headerStr << '\n'
<< namespaceIndent << "namespace " << uiNamespaceC << " {\n" << namespaceIndent << "namespace " << uiNamespaceC << " {\n"
<< namespaceIndent << indent << "class " << FormTemplateWizardPage::stripNamespaces(uiClassName) << ";\n" << namespaceIndent << indent << "class " << Internal::FormTemplateWizardPage::stripNamespaces(uiClassName) << ";\n"
<< namespaceIndent << "}\n"; << namespaceIndent << "}\n";
} }
// Class declaration // Class declaration
headerStr << '\n' << namespaceIndent << "class " << unqualifiedClassName headerStr << '\n' << namespaceIndent << "class " << unqualifiedClassName
<< " : public " << formBaseClass; << " : public " << formBaseClass;
if (embedding == InheritedUiClass) { if (embedding == FormClassWizardGenerationParameters::InheritedUiClass) {
headerStr << ", private " << uiClassName; headerStr << ", private " << uiClassName;
} }
headerStr << " {\n" << namespaceIndent << indent << "Q_OBJECT\n" headerStr << " {\n" << namespaceIndent << indent << "Q_OBJECT\n"
<< namespaceIndent << "public:\n" << namespaceIndent << "public:\n"
<< namespaceIndent << indent << unqualifiedClassName << "(QWidget *parent = 0);\n"; << namespaceIndent << indent << unqualifiedClassName << "(QWidget *parent = 0);\n";
if (embedding == PointerAggregatedUiClass) if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass)
headerStr << namespaceIndent << indent << "~" << unqualifiedClassName << "();\n"; headerStr << namespaceIndent << indent << "~" << unqualifiedClassName << "();\n";
// retranslation // retranslation
if (languageChange) if (generationParameters.retranslationSupport())
headerStr << '\n' << namespaceIndent << "protected:\n" headerStr << '\n' << namespaceIndent << "protected:\n"
<< namespaceIndent << indent << "void changeEvent(QEvent *e);\n"; << namespaceIndent << indent << "void changeEvent(QEvent *e);\n";
// Member variable // Member variable
if (embedding != InheritedUiClass) { if (embedding != FormClassWizardGenerationParameters::InheritedUiClass) {
headerStr << '\n' << namespaceIndent << "private:\n" headerStr << '\n' << namespaceIndent << "private:\n"
<< namespaceIndent << indent << uiClassName << ' '; << namespaceIndent << indent << uiClassName << ' ';
if (embedding == PointerAggregatedUiClass) if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass)
headerStr << '*'; headerStr << '*';
headerStr << uiMemberC << ";\n"; headerStr << uiMemberC << ";\n";
} }
headerStr << namespaceIndent << "};\n\n"; headerStr << namespaceIndent << "};\n\n";
Core::Utils::writeClosingNameSpaces(namespaceList, indent, headerStr); Core::Utils::writeClosingNameSpaces(namespaceList, generationParameters.indentNamespace() ? indent : QString(), headerStr);
headerStr << "#endif // "<< guard << '\n'; headerStr << "#endif // "<< guard << '\n';
// 2) Source file // 2) Source file
QTextStream sourceStr(source); QTextStream sourceStr(source);
sourceStr << license; sourceStr << license;
Core::Utils::writeIncludeFileDirective(headerFile, false, sourceStr); Core::Utils::writeIncludeFileDirective(headerFile, false, sourceStr);
if (embedding == PointerAggregatedUiClass) if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass)
Core::Utils::writeIncludeFileDirective(uiInclude, false, sourceStr); Core::Utils::writeIncludeFileDirective(uiInclude, false, sourceStr);
// NameSpaces( // NameSpaces(
Core::Utils::writeOpeningNameSpaces(namespaceList, indent, sourceStr); Core::Utils::writeOpeningNameSpaces(namespaceList, generationParameters.indentNamespace() ? indent : QString(), sourceStr);
// Constructor with setupUi // Constructor with setupUi
sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName << "(QWidget *parent) :\n" sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName << "(QWidget *parent) :\n"
<< namespaceIndent << indent << formBaseClass << "(parent)"; << namespaceIndent << indent << formBaseClass << "(parent)";
if (embedding == PointerAggregatedUiClass) if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass)
sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiClassName << ")\n"; sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiClassName << ")\n";
sourceStr << namespaceIndent << "{\n" << namespaceIndent << indent; sourceStr << namespaceIndent << "{\n" << namespaceIndent << indent;
if (embedding != InheritedUiClass) writeUiMemberAccess(generationParameters, sourceStr);
sourceStr << uiMemberC << (embedding == PointerAggregatedUiClass ? "->" : ".");
sourceStr << "setupUi(this);\n" << namespaceIndent << "}\n"; sourceStr << "setupUi(this);\n" << namespaceIndent << "}\n";
// Deleting destructor for ptr // Deleting destructor for ptr
if (embedding == PointerAggregatedUiClass) { if (embedding == FormClassWizardGenerationParameters::PointerAggregatedUiClass) {
sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::~" << unqualifiedClassName sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::~" << unqualifiedClassName
<< "()\n" << namespaceIndent << "{\n" << "()\n" << namespaceIndent << "{\n"
<< namespaceIndent << indent << "delete " << uiMemberC << ";\n" << namespaceIndent << indent << "delete " << uiMemberC << ";\n"
<< namespaceIndent << "}\n"; << namespaceIndent << "}\n";
} }
// retranslation // retranslation
if (languageChange) { if (generationParameters.retranslationSupport()) {
sourceStr << '\n' << namespaceIndent << "void " << unqualifiedClassName << "::" << "changeEvent(QEvent *e)\n" sourceStr << '\n' << namespaceIndent << "void " << unqualifiedClassName << "::" << "changeEvent(QEvent *e)\n"
<< namespaceIndent << "{\n" << namespaceIndent << "{\n"
<< namespaceIndent << indent << formBaseClass << "::changeEvent(e);\n" << namespaceIndent << indent << formBaseClass << "::changeEvent(e);\n"
<< namespaceIndent << indent << "switch (e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n" << namespaceIndent << indent << "switch (e->type()) {\n" << namespaceIndent << indent << "case QEvent::LanguageChange:\n"
<< namespaceIndent << indent << indent; << namespaceIndent << indent << indent;
if (embedding != InheritedUiClass) writeUiMemberAccess(generationParameters, sourceStr);
sourceStr << uiMemberC << (embedding == PointerAggregatedUiClass ? "->" : ".");
sourceStr << "retranslateUi(this);\n" sourceStr << "retranslateUi(this);\n"
<< namespaceIndent << indent << indent << "break;\n" << namespaceIndent << indent << indent << "break;\n"
<< namespaceIndent << indent << "default:\n" << namespaceIndent << indent << "default:\n"
@@ -176,9 +443,15 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
<< namespaceIndent << indent << "}\n" << namespaceIndent << indent << "}\n"
<< namespaceIndent << "}\n"; << namespaceIndent << "}\n";
} }
Core::Utils::writeClosingNameSpaces(namespaceList, indent, sourceStr); Core::Utils::writeClosingNameSpaces(namespaceList, generationParameters.indentNamespace() ? indent : QString(), sourceStr);
return true; return true;
} }
} // namespace Internal bool FormClassWizardParameters::generateCpp(const FormClassWizardGenerationParameters &fgp,
QString *header, QString *source, int indentation) const
{
return m_d->generateCpp(fgp, header, source, indentation);
}
} // namespace Designer } // namespace Designer

View File

@@ -30,35 +30,99 @@
#ifndef FORMCLASSWIZARDPARAMETERS_H #ifndef FORMCLASSWIZARDPARAMETERS_H
#define FORMCLASSWIZARDPARAMETERS_H #define FORMCLASSWIZARDPARAMETERS_H
#include "../designer_export.h"
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QSharedDataPointer>
QT_BEGIN_NAMESPACE
class QSettings;
QT_END_NAMESPACE
namespace Designer { namespace Designer {
namespace Internal {
class FormClassWizardGenerationParametersPrivate;
class FormClassWizardParametersPrivate;
enum UiClassEmbedding { // Parameters influencing the code generation.
PointerAggregatedUiClass, class DESIGNER_EXPORT FormClassWizardGenerationParameters {
AggregatedUiClass, public:
InheritedUiClass // How to embed the Ui::Form class.
enum UiClassEmbedding {
PointerAggregatedUiClass, // "Ui::Form *m_ui";
AggregatedUiClass, // "Ui::Form m_ui";
InheritedUiClass // "...private Ui::Form..."
};
FormClassWizardGenerationParameters();
~FormClassWizardGenerationParameters();
FormClassWizardGenerationParameters(const FormClassWizardGenerationParameters&);
FormClassWizardGenerationParameters &operator=(const FormClassWizardGenerationParameters &);
void fromSettings(const QSettings *);
void toSettings(QSettings *) const;
UiClassEmbedding embedding() const;
void setEmbedding(UiClassEmbedding e);
bool retranslationSupport() const; // Add handling for language change events
void setRetranslationSupport(bool v);
bool includeQtModule() const; // Include "<QtGui/[Class]>" or just "<[Class]>"
void setIncludeQtModule(bool v);
bool indentNamespace() const;
void setIndentNamespace(bool v);
bool equals(const FormClassWizardGenerationParameters &rhs) const;
private:
QSharedDataPointer<FormClassWizardGenerationParametersPrivate> m_d;
}; };
struct FormClassWizardParameters { inline bool operator==(const FormClassWizardGenerationParameters &p1, const FormClassWizardGenerationParameters &p2) { return p1.equals(p2); }
explicit FormClassWizardParameters(); inline bool operator!=(const FormClassWizardGenerationParameters &p1, const FormClassWizardGenerationParameters &p2) { return !p1.equals(p2); }
bool generateCpp(QString *header, QString *source, int indentation = 4) const; // Parameters required to generate the code part of a form class with
// helpers for XML-processing ui templates.
class DESIGNER_EXPORT FormClassWizardParameters {
public:
FormClassWizardParameters();
~FormClassWizardParameters();
FormClassWizardParameters(const FormClassWizardParameters &);
FormClassWizardParameters &operator=(const FormClassWizardParameters &);
UiClassEmbedding embedding; bool generateCpp(const FormClassWizardGenerationParameters &fgp,
bool languageChange; // Add handling for language change events QString *header, QString *source, int indentation = 4) const;
QString uiTemplate;
QString className;
QString path; // Helper to parse UI XML forms to determine:
QString sourceFile; // 1) The ui class name from "<class>Designer::Internal::FormClassWizardPage</class>"
QString headerFile; // 2) the base class from: widget class="QWizardPage"...
QString uiFile; static bool getUIXmlData(const QString &uiXml, QString *formBaseClass, QString *uiClassName);
// Helper to change the class name in a UI XML form
static QString changeUiClassName(const QString &uiXml, const QString &newUiClassName);
QString uiTemplate() const;
void setUiTemplate(const QString &);
QString className() const;
void setClassName(const QString &);
QString path() const;
void setPath(const QString &);
QString sourceFile() const;
void setSourceFile(const QString &);
QString headerFile() const;
void setHeaderFile(const QString &);
QString uiFile() const;
void setUiFile(const QString &);
private:
QSharedDataPointer<FormClassWizardParametersPrivate> m_d;
}; };
} // namespace Internal
} // namespace Designer } // namespace Designer
#endif // FORMCLASSWIZARDPARAMETERS_H #endif // FORMCLASSWIZARDPARAMETERS_H

View File

@@ -30,9 +30,14 @@
#ifndef DESIGNERPLUGIN_CONSTANTS_H #ifndef DESIGNERPLUGIN_CONSTANTS_H
#define DESIGNERPLUGIN_CONSTANTS_H #define DESIGNERPLUGIN_CONSTANTS_H
#include <QtCore/QtGlobal>
namespace Designer { namespace Designer {
namespace Constants { namespace Constants {
const char * const SETTINGS_CATEGORY = QT_TRANSLATE_NOOP("Designer", "Designer");
const char * const SETTINGS_CPP_SETTINGS = QT_TRANSLATE_NOOP("Designer", "Class Generation");
// context // context
const char * const C_FORMEDITOR = "FormEditor"; const char * const C_FORMEDITOR = "FormEditor";
const char * const T_FORMEDITOR = "FormEditor.Toolbar"; const char * const T_FORMEDITOR = "FormEditor.Toolbar";

View File

@@ -35,6 +35,7 @@
#ifdef CPP_ENABLED #ifdef CPP_ENABLED
# include "formclasswizard.h" # include "formclasswizard.h"
# include <cppeditor/cppeditorconstants.h> # include <cppeditor/cppeditorconstants.h>
# include "cppsettingspage.h"
#endif #endif
#include "designerconstants.h" #include "designerconstants.h"
@@ -60,24 +61,12 @@
using namespace Designer::Internal; using namespace Designer::Internal;
using namespace Designer::Constants; using namespace Designer::Constants;
FormEditorPlugin::FormEditorPlugin() : FormEditorPlugin::FormEditorPlugin()
m_factory(0),
m_formWizard(0),
m_formClassWizard(0)
{ {
} }
FormEditorPlugin::~FormEditorPlugin() FormEditorPlugin::~FormEditorPlugin()
{ {
if (m_factory)
removeObject(m_factory);
if (m_formWizard)
removeObject(m_formWizard);
if (m_formClassWizard)
removeObject(m_formClassWizard);
delete m_factory;
delete m_formWizard;
delete m_formClassWizard;
FormEditorW::deleteInstance(); FormEditorW::deleteInstance();
} }
@@ -95,30 +84,28 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error)
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/formeditor/Designer.mimetypes.xml"), error)) if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/formeditor/Designer.mimetypes.xml"), error))
return false; return false;
if (!initializeTemplates(error)) initializeTemplates();
return false;
const int uid = core->uniqueIDManager()->uniqueIdentifier(QLatin1String(C_FORMEDITOR)); const int uid = core->uniqueIDManager()->uniqueIdentifier(QLatin1String(C_FORMEDITOR));
const QList<int> context = QList<int>() << uid; const QList<int> context = QList<int>() << uid;
m_factory = new FormEditorFactory; addAutoReleasedObject(new FormEditorFactory);
addObject(m_factory);
if (qgetenv("KDE_SESSION_VERSION") == QByteArray("4")) { if (qgetenv("KDE_SESSION_VERSION") == QByteArray("4")) {
// KDE 4, possibly dangerous... // KDE 4, possibly dangerous...
// KDE 4.2.0 had a nasty bug, which resulted in the File/Open Dialog crashing // KDE 4.2.0 had a nasty bug, which resulted in the File/Open Dialog crashing
// so check for that an fully load the plugins // so check for that an fully load the plugins
QProcess proc; QProcess proc;
proc.start("kde4-config", QStringList() << "--version"); proc.start(QLatin1String("kde4-config"), QStringList(QLatin1String("--version")));
proc.waitForFinished(); proc.waitForFinished();
QString output = proc.readAll(); const QByteArray output = proc.readAll();
if (output.contains("KDE: 4.2.0")) if (output.contains("KDE: 4.2.0"))
FormEditorW::ensureInitStage(FormEditorW::FullyInitialized); FormEditorW::ensureInitStage(FormEditorW::FullyInitialized);
} else { } else {
FormEditorW::ensureInitStage(FormEditorW::RegisterPlugins); FormEditorW::ensureInitStage(FormEditorW::RegisterPlugins);
} }
QString locale = qApp->property("qtc_locale").toString(); const QString locale = qApp->property("qtc_locale").toString();
if (!locale.isEmpty()) { if (!locale.isEmpty()) {
QTranslator *qtr = new QTranslator(this); QTranslator *qtr = new QTranslator(this);
const QString &creatorTrPath = const QString &creatorTrPath =
@@ -143,26 +130,23 @@ void FormEditorPlugin::extensionsInitialized()
// //
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
bool FormEditorPlugin::initializeTemplates(QString *error) void FormEditorPlugin::initializeTemplates()
{ {
Q_UNUSED(error);
FormWizard::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard); FormWizard::BaseFileWizardParameters wizardParameters(Core::IWizard::FileWizard);
wizardParameters.setCategory(QLatin1String("Qt")); wizardParameters.setCategory(QLatin1String("Qt"));
wizardParameters.setTrCategory(tr("Qt")); wizardParameters.setTrCategory(tr("Qt"));
const QString formFileType = QLatin1String(Constants::FORM_FILE_TYPE); const QString formFileType = QLatin1String(Constants::FORM_FILE_TYPE);
wizardParameters.setName(tr("Qt Designer Form")); wizardParameters.setName(tr("Qt Designer Form"));
wizardParameters.setDescription(tr("Creates a Qt Designer form file (.ui).")); wizardParameters.setDescription(tr("Creates a Qt Designer form file (.ui)."));
m_formWizard = new FormWizard(wizardParameters, this); addAutoReleasedObject(new FormWizard(wizardParameters, this));
addObject(m_formWizard);
#ifdef CPP_ENABLED #ifdef CPP_ENABLED
wizardParameters.setKind(Core::IWizard::ClassWizard); wizardParameters.setKind(Core::IWizard::ClassWizard);
wizardParameters.setName(tr("Qt Designer Form Class")); wizardParameters.setName(tr("Qt Designer Form Class"));
wizardParameters.setDescription(tr("Creates a Qt Designer form file (.ui) with a matching class.")); wizardParameters.setDescription(tr("Creates a Qt Designer form file (.ui) with a matching class."));
m_formClassWizard = new FormClassWizard(wizardParameters, this); addAutoReleasedObject(new FormClassWizard(wizardParameters, this));
addObject(m_formClassWizard); addAutoReleasedObject(new CppSettingsPage);
#endif #endif
return true;
} }
Q_EXPORT_PLUGIN(FormEditorPlugin) Q_EXPORT_PLUGIN(FormEditorPlugin)

View File

@@ -32,18 +32,9 @@
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
namespace Core {
class IWizard;
class ICore;
}
namespace Designer { namespace Designer {
namespace Internal { namespace Internal {
class FormEditorFactory;
class FormWizard;
class FormEditorW;
class FormEditorPlugin : public ExtensionSystem::IPlugin class FormEditorPlugin : public ExtensionSystem::IPlugin
{ {
Q_OBJECT Q_OBJECT
@@ -57,12 +48,7 @@ public:
void extensionsInitialized(); void extensionsInitialized();
private: private:
bool initializeTemplates(QString *error_message); void initializeTemplates();
FormEditorFactory *m_factory;
Core::IWizard *m_formWizard;
Core::IWizard *m_formClassWizard;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -54,7 +54,11 @@ public:
QString templateContents() const { return m_templateContents; } QString templateContents() const { return m_templateContents; }
// Parse UI XML forms to determine:
// 1) The ui class name from "<class>Designer::Internal::FormClassWizardPage</class>"
// 2) the base class from: widget class="QWizardPage"...
static bool getUIXmlData(const QString &uiXml, QString *formBaseClass, QString *uiClassName); static bool getUIXmlData(const QString &uiXml, QString *formBaseClass, QString *uiClassName);
// Change the class name in a UI XML form
static QString changeUiClassName(const QString &uiXml, const QString &newUiClassName); static QString changeUiClassName(const QString &uiXml, const QString &newUiClassName);
static QString stripNamespaces(const QString &className); static QString stripNamespaces(const QString &className);

View File

@@ -28,9 +28,11 @@
**************************************************************************/ **************************************************************************/
#include "settingspage.h" #include "settingspage.h"
#include "designerconstants.h"
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <qt_private/abstractoptionspage_p.h> #include <qt_private/abstractoptionspage_p.h>
#include <QtCore/QCoreApplication>
using namespace Designer::Internal; using namespace Designer::Internal;
@@ -55,12 +57,12 @@ QString SettingsPage::trName() const
QString SettingsPage::category() const QString SettingsPage::category() const
{ {
return QLatin1String("Designer"); return QLatin1String(Designer::Constants::SETTINGS_CATEGORY);
} }
QString SettingsPage::trCategory() const QString SettingsPage::trCategory() const
{ {
return tr("Designer"); return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_CATEGORY);
} }
QWidget *SettingsPage::createPage(QWidget *parent) QWidget *SettingsPage::createPage(QWidget *parent)

View File

@@ -53,8 +53,11 @@ ProjectWizardPage::~ProjectWizardPage()
void ProjectWizardPage::setProjects(const QStringList &l) void ProjectWizardPage::setProjects(const QStringList &l)
{ {
QStringList list = l;
list.removeDuplicates();
list.sort();
m_ui->projectComboBox->clear(); m_ui->projectComboBox->clear();
m_ui->projectComboBox->addItems(l); m_ui->projectComboBox->addItems(list);
} }
void ProjectWizardPage::setAddToProjectEnabled(bool b) void ProjectWizardPage::setAddToProjectEnabled(bool b)

View File

@@ -65,6 +65,8 @@ Core::GeneratedFiles CustomWidgetWizard::generateFiles(const QWizard *w,
p.name = cw->name(); p.name = cw->name();
p.path = cw->path(); p.path = cw->path();
p.license = CppTools::AbstractEditorSupport::licenseTemplate(); p.license = CppTools::AbstractEditorSupport::licenseTemplate();
p.templatePath = QtWizard::templateDir();
p.templatePath += QLatin1String("/customwidgetwizard");
return PluginGenerator::generatePlugin(p, *(cw->pluginOptions()), errorMessage); return PluginGenerator::generatePlugin(p, *(cw->pluginOptions()), errorMessage);
} }

View File

@@ -22,4 +22,4 @@ FORMS += \
$$PWD/classdefinition.ui \ $$PWD/classdefinition.ui \
$$PWD/customwidgetwidgetswizardpage.ui \ $$PWD/customwidgetwidgetswizardpage.ui \
$$PWD/customwidgetpluginwizardpage.ui $$PWD/customwidgetpluginwizardpage.ui
RESOURCES += $$PWD/templates/templates.qrc

View File

@@ -97,7 +97,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
sm.clear(); sm.clear();
sm.insert(QLatin1String("SINGLE_INCLUDE_GUARD"), headerGuard(wo.pluginHeaderFile)); sm.insert(QLatin1String("SINGLE_INCLUDE_GUARD"), headerGuard(wo.pluginHeaderFile));
sm.insert(QLatin1String("PLUGIN_CLASS"), wo.pluginClassName); sm.insert(QLatin1String("PLUGIN_CLASS"), wo.pluginClassName);
const QString pluginHeaderContents = processTemplate(QLatin1String(":/tpl_single.h"), sm, errorMessage); const QString pluginHeaderContents = processTemplate(p.templatePath + QLatin1String("/tpl_single.h"), sm, errorMessage);
if (pluginHeaderContents.isEmpty()) if (pluginHeaderContents.isEmpty())
return QList<Core::GeneratedFile>(); return QList<Core::GeneratedFile>();
Core::GeneratedFile pluginHeader(baseDir + wo.pluginHeaderFile); Core::GeneratedFile pluginHeader(baseDir + wo.pluginHeaderFile);
@@ -128,7 +128,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
wo.pluginClassName + wo.pluginClassName +
QLatin1Char(')') : QLatin1Char(')') :
QLatin1String("")); QLatin1String(""));
const QString pluginSourceContents = processTemplate(QLatin1String(":/tpl_single.cpp"), sm, errorMessage); const QString pluginSourceContents = processTemplate(p.templatePath + QLatin1String("/tpl_single.cpp"), sm, errorMessage);
if (pluginSourceContents.isEmpty()) if (pluginSourceContents.isEmpty())
return QList<Core::GeneratedFile>(); return QList<Core::GeneratedFile>();
Core::GeneratedFile pluginSource(baseDir + wo.pluginSourceFile); Core::GeneratedFile pluginSource(baseDir + wo.pluginSourceFile);
@@ -152,9 +152,9 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
if (pc.headers.isEmpty()) { if (pc.headers.isEmpty()) {
if (wo.sourceType == PluginOptions::WidgetOptions::LinkLibrary) { if (wo.sourceType == PluginOptions::WidgetOptions::LinkLibrary) {
pc.library = wo.widgetLibrary; pc.library = wo.widgetLibrary;
pc.tmpl = QLatin1String(":/tpl_widget_lib.pro"); pc.tmpl = p.templatePath + QLatin1String("/tpl_widget_lib.pro");
} else { } else {
pc.tmpl = QLatin1String(":/tpl_widget_include.pri"); pc.tmpl = p.templatePath + QLatin1String("/tpl_widget_include.pri");
} }
widgetProjectContents.insert(wo.widgetProjectFile, pc); widgetProjectContents.insert(wo.widgetProjectFile, pc);
} else { } else {
@@ -171,7 +171,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
sm.insert(QLatin1String("WIDGET_INCLUDE_GUARD"), headerGuard(wo.widgetHeaderFile)); sm.insert(QLatin1String("WIDGET_INCLUDE_GUARD"), headerGuard(wo.widgetHeaderFile));
sm.insert(QLatin1String("WIDGET_BASE_CLASS"), wo.widgetBaseClassName); sm.insert(QLatin1String("WIDGET_BASE_CLASS"), wo.widgetBaseClassName);
sm.insert(QLatin1String("WIDGET_CLASS"), wo.widgetClassName); sm.insert(QLatin1String("WIDGET_CLASS"), wo.widgetClassName);
const QString widgetHeaderContents = processTemplate(QLatin1String(":/tpl_widget.h"), sm, errorMessage); const QString widgetHeaderContents = processTemplate(p.templatePath + QLatin1String("/tpl_widget.h"), sm, errorMessage);
if (widgetHeaderContents.isEmpty()) if (widgetHeaderContents.isEmpty())
return QList<Core::GeneratedFile>(); return QList<Core::GeneratedFile>();
Core::GeneratedFile widgetHeader(baseDir + wo.widgetHeaderFile); Core::GeneratedFile widgetHeader(baseDir + wo.widgetHeaderFile);
@@ -180,7 +180,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
sm.remove(QLatin1String("WIDGET_INCLUDE_GUARD")); sm.remove(QLatin1String("WIDGET_INCLUDE_GUARD"));
sm.insert(QLatin1String("WIDGET_HEADER"), wo.widgetHeaderFile); sm.insert(QLatin1String("WIDGET_HEADER"), wo.widgetHeaderFile);
const QString widgetSourceContents = processTemplate(QLatin1String(":/tpl_widget.cpp"), sm, errorMessage); const QString widgetSourceContents = processTemplate(p.templatePath + QLatin1String("/tpl_widget.cpp"), sm, errorMessage);
if (widgetSourceContents.isEmpty()) if (widgetSourceContents.isEmpty())
return QList<Core::GeneratedFile>(); return QList<Core::GeneratedFile>();
Core::GeneratedFile widgetSource(baseDir + wo.widgetSourceFile); Core::GeneratedFile widgetSource(baseDir + wo.widgetSourceFile);
@@ -213,7 +213,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
sm.clear(); sm.clear();
sm.insert(QLatin1String("COLLECTION_INCLUDE_GUARD"), headerGuard(options.collectionHeaderFile)); sm.insert(QLatin1String("COLLECTION_INCLUDE_GUARD"), headerGuard(options.collectionHeaderFile));
sm.insert(QLatin1String("COLLECTION_PLUGIN_CLASS"), options.collectionClassName); sm.insert(QLatin1String("COLLECTION_PLUGIN_CLASS"), options.collectionClassName);
const QString collectionHeaderContents = processTemplate(QLatin1String(":/tpl_collection.h"), sm, errorMessage); const QString collectionHeaderContents = processTemplate(p.templatePath + QLatin1String("/tpl_collection.h"), sm, errorMessage);
if (collectionHeaderContents.isEmpty()) if (collectionHeaderContents.isEmpty())
return QList<Core::GeneratedFile>(); return QList<Core::GeneratedFile>();
Core::GeneratedFile collectionHeader(baseDir + options.collectionHeaderFile); Core::GeneratedFile collectionHeader(baseDir + options.collectionHeaderFile);
@@ -233,7 +233,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
QLatin1String(", ") + QLatin1String(", ") +
options.collectionClassName + options.collectionClassName +
QLatin1Char(')')); QLatin1Char(')'));
const QString collectionSourceFileContents = processTemplate(QLatin1String(":/tpl_collection.cpp"), sm, errorMessage); const QString collectionSourceFileContents = processTemplate(p.templatePath + QLatin1String("/tpl_collection.cpp"), sm, errorMessage);
if (collectionSourceFileContents.isEmpty()) if (collectionSourceFileContents.isEmpty())
return QList<Core::GeneratedFile>(); return QList<Core::GeneratedFile>();
Core::GeneratedFile collectionSource(baseDir + options.collectionSourceFile); Core::GeneratedFile collectionSource(baseDir + options.collectionSourceFile);
@@ -262,7 +262,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
// Create the resource file with the icons. // Create the resource file with the icons.
sm.clear(); sm.clear();
sm.insert(QLatin1String("ICON_FILES"), iconFiles); sm.insert(QLatin1String("ICON_FILES"), iconFiles);
const QString resourceFileContents = processTemplate(QLatin1String(":/tpl_resources.qrc"), sm, errorMessage); const QString resourceFileContents = processTemplate(p.templatePath + QLatin1String("/tpl_resources.qrc"), sm, errorMessage);
if (resourceFileContents.isEmpty()) if (resourceFileContents.isEmpty())
return QList<Core::GeneratedFile>(); return QList<Core::GeneratedFile>();
Core::GeneratedFile resourceFile(baseDir + options.resourceFile); Core::GeneratedFile resourceFile(baseDir + options.resourceFile);
@@ -277,7 +277,7 @@ QList<Core::GeneratedFile> PluginGenerator::generatePlugin(const GenerationPara
sm.insert(QLatin1String("PLUGIN_RESOURCES"), options.resourceFile); sm.insert(QLatin1String("PLUGIN_RESOURCES"), options.resourceFile);
sm.insert(QLatin1String("WIDGET_LIBS"), QStringList(widgetLibraries.toList()).join(QString(blank))); sm.insert(QLatin1String("WIDGET_LIBS"), QStringList(widgetLibraries.toList()).join(QString(blank)));
sm.insert(QLatin1String("INCLUSIONS"), QStringList(widgetProjects.toList()).join(QLatin1String("\n"))); sm.insert(QLatin1String("INCLUSIONS"), QStringList(widgetProjects.toList()).join(QLatin1String("\n")));
const QString proFileContents = processTemplate(QLatin1String(":/tpl_plugin.pro"), sm, errorMessage); const QString proFileContents = processTemplate(p.templatePath + QLatin1String("/tpl_plugin.pro"), sm, errorMessage);
if (proFileContents.isEmpty()) if (proFileContents.isEmpty())
return QList<Core::GeneratedFile>(); return QList<Core::GeneratedFile>();
Core::GeneratedFile proFile(baseDir + p.name + QLatin1String(".pro")); Core::GeneratedFile proFile(baseDir + p.name + QLatin1String(".pro"));

View File

@@ -52,6 +52,7 @@ struct GenerationParameters {
QString path; QString path;
QString name; QString name;
QString license; QString license;
QString templatePath;
}; };
class PluginGenerator : public QObject class PluginGenerator : public QObject

View File

@@ -1,14 +0,0 @@
<RCC>
<qresource prefix="/" >
<file>tpl_widget.h</file>
<file>tpl_widget.cpp</file>
<file>tpl_widget_include.pri</file>
<file>tpl_widget_lib.pro</file>
<file>tpl_single.h</file>
<file>tpl_single.cpp</file>
<file>tpl_collection.h</file>
<file>tpl_collection.cpp</file>
<file>tpl_plugin.pro</file>
<file>tpl_resources.qrc</file>
</qresource>
</RCC>

View File

@@ -37,9 +37,12 @@
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <projectexplorer/projectnodes.h> #include <projectexplorer/projectnodes.h>
#include <cpptools/cppmodelmanagerinterface.h> #include <cpptools/cppmodelmanagerinterface.h>
#include <designer/cpp/formclasswizardparameters.h>
#include <coreplugin/icore.h>
#include <QtCore/QDir> #include <QtCore/QDir>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QSettings>
#include <QtCore/QByteArray> #include <QtCore/QByteArray>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QTextStream> #include <QtCore/QTextStream>
@@ -89,6 +92,33 @@ QWizard *GuiAppWizard::createWizardDialog(QWidget *parent,
return dialog; return dialog;
} }
// Use the class generation utils provided by the designer plugin
static inline bool generateFormClass(const GuiAppParameters &params,
const Core::GeneratedFile &uiFile,
Core::GeneratedFile *formSource,
Core::GeneratedFile *formHeader,
QString *errorMessage)
{
// Retrieve parameters from settings
Designer::FormClassWizardGenerationParameters fgp;
fgp.fromSettings(Core::ICore::instance()->settings());
Designer::FormClassWizardParameters fp;
fp.setUiTemplate(uiFile.contents());
fp.setUiFile(uiFile.path());
fp.setClassName(params.className);
fp.setSourceFile(params.sourceFileName);
fp.setHeaderFile(params.headerFileName);
QString headerContents;
QString sourceContents;
if (!fp.generateCpp(fgp, &headerContents, &sourceContents, 4)) {
*errorMessage = QLatin1String("Internal error: Unable to generate the form classes.");
return false;
}
formHeader->setContents(headerContents);
formSource->setContents(sourceContents);
return true;
}
Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w, Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w,
QString *errorMessage) const QString *errorMessage) const
{ {
@@ -108,28 +138,32 @@ Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w,
if (!parametrizeTemplate(templatePath, QLatin1String("main.cpp"), params, &contents, errorMessage)) if (!parametrizeTemplate(templatePath, QLatin1String("main.cpp"), params, &contents, errorMessage))
return Core::GeneratedFiles(); return Core::GeneratedFiles();
mainSource.setContents(license + contents); mainSource.setContents(license + contents);
// Create files: form source // Create files: form source with or without form
const QString formSourceTemplate = params.designerForm ? QLatin1String("mywidget_form.cpp") : QLatin1String("mywidget.cpp");
const QString formSourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix()); const QString formSourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix());
Core::GeneratedFile formSource(formSourceFileName);
if (!parametrizeTemplate(templatePath, formSourceTemplate, params, &contents, errorMessage))
return Core::GeneratedFiles();
formSource.setContents(license + contents);
// Create files: form header
const QString formHeaderName = buildFileName(projectPath, params.headerFileName, headerSuffix()); const QString formHeaderName = buildFileName(projectPath, params.headerFileName, headerSuffix());
const QString formHeaderTemplate = params.designerForm ? QLatin1String("mywidget_form.h") : QLatin1String("mywidget.h"); Core::GeneratedFile formSource(formSourceFileName);
Core::GeneratedFile formHeader(formHeaderName); Core::GeneratedFile formHeader(formHeaderName);
if (!parametrizeTemplate(templatePath, formHeaderTemplate, params, &contents, errorMessage))
return Core::GeneratedFiles();
formHeader.setContents(license + contents);
// Create files: form
QSharedPointer<Core::GeneratedFile> form; QSharedPointer<Core::GeneratedFile> form;
if (params.designerForm) { if (params.designerForm) {
// Create files: form
const QString formName = buildFileName(projectPath, params.formFileName, formSuffix()); const QString formName = buildFileName(projectPath, params.formFileName, formSuffix());
form = QSharedPointer<Core::GeneratedFile>(new Core::GeneratedFile(formName)); form = QSharedPointer<Core::GeneratedFile>(new Core::GeneratedFile(formName));
if (!parametrizeTemplate(templatePath, QLatin1String("widget.ui"), params, &contents, errorMessage)) if (!parametrizeTemplate(templatePath, QLatin1String("widget.ui"), params, &contents, errorMessage))
return Core::GeneratedFiles(); return Core::GeneratedFiles();
form->setContents(contents); form->setContents(contents);
if (!generateFormClass(params, *form, &formSource, &formHeader, errorMessage))
return Core::GeneratedFiles();
} else {
const QString formSourceTemplate = QLatin1String("mywidget.cpp");
if (!parametrizeTemplate(templatePath, formSourceTemplate, params, &contents, errorMessage))
return Core::GeneratedFiles();
formSource.setContents(license + contents);
// Create files: form header
const QString formHeaderTemplate = QLatin1String("mywidget.h");
if (!parametrizeTemplate(templatePath, formHeaderTemplate, params, &contents, errorMessage))
return Core::GeneratedFiles();
formHeader.setContents(license + contents);
} }
// Create files: profile // Create files: profile
const QString profileName = buildFileName(projectPath, projectParams.name, profileSuffix()); const QString profileName = buildFileName(projectPath, projectParams.name, profileSuffix());

View File

@@ -468,6 +468,7 @@ void testQObject(int &argc, char *argv[])
#endif #endif
QString str = QString::fromUtf8("XXXXXXXXXXXXXXyyXXX ö"); QString str = QString::fromUtf8("XXXXXXXXXXXXXXyyXXX ö");
QLabel l(str); QLabel l(str);
l.setObjectName("Some Label");
l.show(); l.show();
app.exec(); app.exec();
} }
@@ -915,7 +916,13 @@ void testQVariant1()
void testQVariant2() void testQVariant2()
{ {
QVariant value;
QVariant::Type t = QVariant::String;
value = QVariant(t, (void*)0);
*(QString*)value.data() = QString("XXX");
int i = 1; int i = 1;
#if 0
QVariant var; QVariant var;
var.setValue(1); var.setValue(1);
var.setValue(2); var.setValue(2);
@@ -927,6 +934,7 @@ void testQVariant2()
var.setValue(QStringList() << "World" << "Hello"); var.setValue(QStringList() << "World" << "Hello");
var.setValue(QStringList() << "Hello" << "Hello"); var.setValue(QStringList() << "Hello" << "Hello");
var.setValue(QStringList() << "World" << "Hello" << "Hello"); var.setValue(QStringList() << "World" << "Hello" << "Hello");
#endif
#if 0 #if 0
QVariant var3; QVariant var3;
QHostAddress ha("127.0.0.1"); QHostAddress ha("127.0.0.1");