summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/designer/src/lib/sdk/abstractintegration.cpp51
-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, 81 insertions, 3 deletions
diff --git a/tools/designer/src/lib/sdk/abstractintegration.cpp b/tools/designer/src/lib/sdk/abstractintegration.cpp
index c5a60db..3924db6 100644
--- a/tools/designer/src/lib/sdk/abstractintegration.cpp
+++ b/tools/designer/src/lib/sdk/abstractintegration.cpp
@@ -42,13 +42,64 @@
#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;
+
+QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QDesignerIntegrationInterfacePrivatePtr))
QT_BEGIN_NAMESPACE
+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 9b2b856..acac711 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 eca6615..1fbfccb 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 1e63d81..f2a2b2a 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;