summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-08-23 14:55:39 +0200
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-08-23 14:55:39 +0200
commit00e954ca817f89958a8a8777d93d3843252dc88c (patch)
tree1e270f03368f967e8cb90b26bb44068009f79936
parent6fc62c47739cedb5f3bc8de3004f68b62de991f2 (diff)
downloadqt4-tools-00e954ca817f89958a8a8777d93d3843252dc88c.tar.gz
Qt Designer/Integrations: Add properties for use by C++-IDEs.
...such as the header suffix (like ".h") or whether headers should be lowercase only. Allows for using different suffixes and conventions like 'CamelCase.hxx", etc. Reviewed-by: Jarek Kobus <jaroslaw.kobus@nokia.com> API-reviewed-by: Kai Koehne <kai.koehne@nokia.com> Task-number: QTCREATORBUG-163
-rw-r--r--tools/designer/src/lib/sdk/abstractintegration.cpp49
-rw-r--r--tools/designer/src/lib/sdk/abstractintegration.h10
-rw-r--r--tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp12
-rw-r--r--tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h11
4 files changed, 79 insertions, 3 deletions
diff --git a/tools/designer/src/lib/sdk/abstractintegration.cpp b/tools/designer/src/lib/sdk/abstractintegration.cpp
index c5a60db0e0..e8b0005310 100644
--- a/tools/designer/src/lib/sdk/abstractintegration.cpp
+++ b/tools/designer/src/lib/sdk/abstractintegration.cpp
@@ -42,13 +42,62 @@
#include "abstractintegration.h"
#include "abstractformeditor.h"
+#include <QtCore/QVariant>
+#include <QtCore/QSharedPointer>
+
QT_BEGIN_NAMESPACE
+// Add 'private' struct as a dynamic property.
+
+static const char privatePropertyC[] = "_q_integrationprivate";
+
+struct QDesignerIntegrationInterfacePrivate {
+ QDesignerIntegrationInterfacePrivate() :
+ headerSuffix(QLatin1String(".h")),
+ headerLowercase(true) {}
+
+ QString headerSuffix;
+ bool headerLowercase;
+};
+
+typedef QSharedPointer<QDesignerIntegrationInterfacePrivate> QDesignerIntegrationInterfacePrivatePtr;
+
+Q_DECLARE_METATYPE(QDesignerIntegrationInterfacePrivatePtr)
+
+static QDesignerIntegrationInterfacePrivatePtr integrationD(const QObject *o)
+{
+ const QVariant property = o->property(privatePropertyC);
+ Q_ASSERT(qVariantCanConvert<QDesignerIntegrationInterfacePrivatePtr>(property));
+ return qvariant_cast<QDesignerIntegrationInterfacePrivatePtr>(property);
+}
+
QDesignerIntegrationInterface::QDesignerIntegrationInterface(QDesignerFormEditorInterface *core, QObject *parent)
: QObject(parent),
m_core(core)
{
core->setIntegration(this);
+ const QDesignerIntegrationInterfacePrivatePtr d(new QDesignerIntegrationInterfacePrivate);
+ setProperty(privatePropertyC, qVariantFromValue<QDesignerIntegrationInterfacePrivatePtr>(d));
+}
+
+QString QDesignerIntegrationInterface::headerSuffix() const
+{
+ return integrationD(this)->headerSuffix;
+}
+
+void QDesignerIntegrationInterface::setHeaderSuffix(const QString &headerSuffix)
+{
+ integrationD(this)->headerSuffix = headerSuffix;
+}
+
+bool QDesignerIntegrationInterface::isHeaderLowercase() const
+{
+ return integrationD(this)->headerLowercase;
+}
+
+void QDesignerIntegrationInterface::setHeaderLowercase(bool headerLowercase)
+{
+ integrationD(this)->headerLowercase = headerLowercase;
}
QT_END_NAMESPACE
diff --git a/tools/designer/src/lib/sdk/abstractintegration.h b/tools/designer/src/lib/sdk/abstractintegration.h
index 9b2b856822..acac711279 100644
--- a/tools/designer/src/lib/sdk/abstractintegration.h
+++ b/tools/designer/src/lib/sdk/abstractintegration.h
@@ -45,6 +45,7 @@
#include <QtDesigner/sdk_global.h>
#include <QtCore/QObject>
+#include <QtCore/QString>
QT_BEGIN_HEADER
@@ -55,6 +56,9 @@ class QDesignerFormEditorInterface;
class QDESIGNER_SDK_EXPORT QDesignerIntegrationInterface: public QObject
{
Q_OBJECT
+ Q_PROPERTY(QString headerSuffix READ headerSuffix WRITE setHeaderSuffix)
+ Q_PROPERTY(bool headerLowercase READ isHeaderLowercase WRITE setHeaderLowercase)
+
public:
QDesignerIntegrationInterface(QDesignerFormEditorInterface *core, QObject *parent = 0);
@@ -62,6 +66,12 @@ public:
virtual QWidget *containerWindow(QWidget *widget) const = 0;
+ QString headerSuffix() const;
+ void setHeaderSuffix(const QString &headerSuffix);
+
+ bool isHeaderLowercase() const;
+ void setHeaderLowercase(bool headerLowerCase);
+
private:
QDesignerFormEditorInterface *m_core;
};
diff --git a/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp b/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
index eca66157e1..1fbfccbaef 100644
--- a/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_promotiondialog.cpp
@@ -49,6 +49,7 @@
#include <QtDesigner/QDesignerFormWindowInterface>
#include <QtDesigner/QDesignerPromotionInterface>
#include <QtDesigner/QDesignerWidgetDataBaseItemInterface>
+#include <QtDesigner/QDesignerIntegrationInterface>
#include <abstractdialoggui_p.h>
#include <QtCore/QTimer>
@@ -152,8 +153,13 @@ namespace qdesigner_internal {
void NewPromotedClassPanel::slotNameChanged(const QString &className) {
// Suggest a name
if (!className.isEmpty()) {
- QString suggestedHeader = className.toLower().replace(QLatin1String("::"), QString(QLatin1Char('_')));
- suggestedHeader += QLatin1String(".h");
+ const QChar dot(QLatin1Char('.'));
+ QString suggestedHeader = m_promotedHeaderLowerCase ?
+ className.toLower() : className;
+ suggestedHeader.replace(QLatin1String("::"), QString(QLatin1Char('_')));
+ if (!m_promotedHeaderSuffix.startsWith(dot))
+ suggestedHeader += dot;
+ suggestedHeader += m_promotedHeaderSuffix;
const bool blocked = m_includeFileEdit->blockSignals(true);
m_includeFileEdit->setText(suggestedHeader);
@@ -248,6 +254,8 @@ namespace qdesigner_internal {
preselectedBaseClass = baseClassNameList.indexOf(QLatin1String("QFrame"));
NewPromotedClassPanel *newPromotedClassPanel = new NewPromotedClassPanel(baseClassNameList, preselectedBaseClass);
+ newPromotedClassPanel->setPromotedHeaderSuffix(core->integration()->headerSuffix());
+ newPromotedClassPanel->setPromotedHeaderLowerCase(core->integration()->isHeaderLowercase());
connect(newPromotedClassPanel, SIGNAL(newPromotedClass(PromotionParameters,bool*)), this, SLOT(slotNewPromotedClass(PromotionParameters,bool*)));
connect(this, SIGNAL(selectedBaseClassChanged(QString)),
newPromotedClassPanel, SLOT(chooseBaseClass(QString)));
diff --git a/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h b/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h
index 1e63d8134f..f2a2b2a9b7 100644
--- a/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_promotiondialog_p.h
@@ -84,7 +84,13 @@ namespace qdesigner_internal {
int selectedBaseClass = -1,
QWidget *parent = 0);
- signals:
+ QString promotedHeaderSuffix() const { return m_promotedHeaderSuffix; }
+ void setPromotedHeaderSuffix(const QString &s) { m_promotedHeaderSuffix = s; }
+
+ bool isPromotedHeaderLowerCase() const { return m_promotedHeaderLowerCase; }
+ void setPromotedHeaderLowerCase(bool l) { m_promotedHeaderLowerCase = l; }
+
+ signals:
void newPromotedClass(const PromotionParameters &, bool *ok);
public slots:
@@ -100,6 +106,9 @@ namespace qdesigner_internal {
PromotionParameters promotionParameters() const;
void enableButtons();
+ QString m_promotedHeaderSuffix;
+ bool m_promotedHeaderLowerCase;
+
QComboBox *m_baseClassCombo;
QLineEdit *m_classNameEdit;
QLineEdit *m_includeFileEdit;