Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/demos/arthurplugin/plugin.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the demonstration applications of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5656QT_FORWARD_DECLARE_CLASS(QDesignerFormEditorInterface)
    5757
    58 static inline QString customWidgetDomXml(const QString &className)
     58// Specify "text" to be a singleline property (no richtext)
     59static inline QString textSingleLinePropertyDeclaration(const QString &className)
     60{
     61    QString rc = QLatin1String(
     62            "<customwidgets>\n"
     63            "  <customwidget>\n"
     64            "    <class>");
     65    rc += className;
     66    rc += QLatin1String("</class>\n"
     67            "    <propertyspecifications>\n"
     68            "      <stringpropertyspecification name=\"text\" type=\"singleline\"/>\n"
     69            "    </propertyspecifications>\n"
     70            "  </customwidget>\n"
     71            "</customwidgets>\n");
     72    return rc;
     73}
     74
     75// Plain XML for a custom widget
     76static inline QString customWidgetDomXml(const QString &className,
     77                                         const QString &customSection = QString())
    5978{
    6079    QString rc = QLatin1String("<ui language=\"c++\"><widget class=\"");
     
    6483    objectName[0] = objectName.at(0).toLower();
    6584    rc += objectName;
    66     rc += QLatin1String("\"/></ui>");
     85    rc += QLatin1String("\"/>");
     86    rc += customSection;
     87    rc += QLatin1String("</ui>");
    6788    return rc;
    6889}
     
    81102
    82103protected:
    83     DemoPlugin(const QString &className);
     104    explicit DemoPlugin(const QString &className, const QString &customSection = QString());
    84105
    85106public:
     
    106127};
    107128
    108 DemoPlugin::DemoPlugin(const QString &className) :
     129DemoPlugin::DemoPlugin(const QString &className, const QString &customSection) :
    109130    m_className(className),
    110     m_domXml(customWidgetDomXml(className)),
     131    m_domXml(customWidgetDomXml(className, customSection)),
    111132    m_initialized(false)
    112133{
     
    118139
    119140public:
    120     DeformPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("PathDeformRendererEx")) { }
    121     QString includeFile() const { return "deform.h"; }
     141    explicit DeformPlugin(QObject *parent = 0);
     142    QString includeFile() const { return QLatin1String("deform.h"); }
    122143
    123144    QWidget *createWidget(QWidget *parent)
     
    127148        deform->setAnimated(false);
    128149        deform->setFontSize(20);
    129         deform->setText("Arthur Widgets Demo");
     150        deform->setText(QLatin1String("Arthur Widgets Demo"));
    130151
    131152        return deform;
     
    133154};
    134155
     156DeformPlugin::DeformPlugin(QObject *parent) :
     157    QObject(parent),
     158    DemoPlugin(QLatin1String("PathDeformRendererEx"),
     159               textSingleLinePropertyDeclaration(QLatin1String("PathDeformRendererEx")))
     160{
     161}
     162
    135163class XFormRendererEx : public XFormView
    136164{
     
    145173    Q_OBJECT
    146174public:
    147     XFormPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("XFormRendererEx")) { }
    148     QString includeFile() const { return "xform.h"; }
     175    explicit XFormPlugin(QObject *parent = 0);
     176    QString includeFile() const { return QLatin1String("xform.h"); }
    149177
    150178    QWidget *createWidget(QWidget *parent)
    151179    {
    152180        XFormRendererEx *xform = new XFormRendererEx(parent);
    153         xform->setText("Qt - Hello World!!");
    154         xform->setPixmap(QPixmap(":/trolltech/arthurplugin/bg1.jpg"));
     181        xform->setText(QLatin1String("Qt - Hello World!!"));
     182        xform->setPixmap(QPixmap(QLatin1String(":/trolltech/arthurplugin/bg1.jpg")));
    155183        return xform;
    156184    }
    157185};
    158186
     187XFormPlugin::XFormPlugin(QObject *parent) :
     188    QObject(parent),
     189    DemoPlugin(QLatin1String("XFormRendererEx"),
     190               textSingleLinePropertyDeclaration(QLatin1String("XFormRendererEx")))
     191{
     192}
    159193
    160194class GradientEditorPlugin : public QObject, public DemoPlugin
     
    162196    Q_OBJECT
    163197public:
    164     GradientEditorPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("GradientEditor")) { }
     198    explicit GradientEditorPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("GradientEditor")) { }
    165199    QString includeFile() const { return "gradients.h"; }
    166200
     
    185219public:
    186220    GradientRendererPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("GradientRendererEx")) { }
    187     QString includeFile() const { return "gradients.h"; }
     221    QString includeFile() const { return QLatin1String("gradients.h"); }
    188222
    189223    QWidget *createWidget(QWidget *parent)
     
    199233    Q_OBJECT
    200234public:
    201     PathStrokeRendererEx(QWidget *p) : PathStrokeRenderer(p) { }
     235    explicit PathStrokeRendererEx(QWidget *p) : PathStrokeRenderer(p) { }
    202236    QSize sizeHint() const { return QSize(300, 200); }
    203237};
     
    207241    Q_OBJECT
    208242public:
    209     StrokeRenderPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("PathStrokeRendererEx")) { }
    210     QString includeFile() const { return "pathstroke.h"; }
     243    explicit StrokeRenderPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("PathStrokeRendererEx")) { }
     244    QString includeFile() const { return QLatin1String("pathstroke.h"); }
    211245
    212246    QWidget *createWidget(QWidget *parent)
     
    222256    Q_OBJECT
    223257public:
    224     CompositionModePlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("CompositionRenderer")) { }
    225     QString includeFile() const { return "composition.h"; }
     258    explicit CompositionModePlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("CompositionRenderer")) { }
     259    QString includeFile() const { return QLatin1String("composition.h"); }
    226260
    227261    QWidget *createWidget(QWidget *parent)
     
    240274
    241275public:
    242     ArthurPlugins(QObject *parent = 0);
     276    explicit ArthurPlugins(QObject *parent = 0);
    243277    QList<QDesignerCustomWidgetInterface*> customWidgets() const { return m_plugins; }
    244278
Note: See TracChangeset for help on using the changeset viewer.