From: Tobias Koenig Date: Fri, 2 Nov 2012 11:13:35 +0000 (+0100) Subject: Split declarativeobjects_p.h/cpp into separated files X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=d3e1061dbf5d1378d17f2a7dc48a051336383981;p=web%2Fkonrad%2FDeclarativeWidgets.git Split declarativeobjects_p.h/cpp into separated files Moved files around to have a cleaner separation between library and application. Use GPL+KDAB copyright statement in all files. --- diff --git a/README b/README new file mode 100644 index 0000000..460d822 --- /dev/null +++ b/README @@ -0,0 +1 @@ +If you wish to use this software in ways incompatible with the GPL, please contact sales@kdab.com, and we'll work something out. diff --git a/declarativeobjects.cpp b/declarativeobjects.cpp deleted file mode 100644 index 73dff26..0000000 --- a/declarativeobjects.cpp +++ /dev/null @@ -1,1907 +0,0 @@ -#include "declarativeobjects_p.h" - -#include "qmetaobjectbuilder_p.h" - -#include - -#define CUSTOM_METAOBJECT(ClassName, ProxyObjectType) \ -QMetaObject ClassName::staticMetaObject;\ -bool ClassName::metaObjectInitialized = ClassName::initializeMetaObject(); \ -bool ClassName::initializeMetaObject() \ -{ \ - QMetaObjectBuilder builder; \ - const QMetaObject *mo = &ProxyObjectType::staticMetaObject; \ - builder.addMetaObject(mo); \ - builder.addMetaObject(&AbstractDeclarativeObject::staticMetaObject); \ - builder.setSuperClass(ProxyObjectType::staticMetaObject.superClass()); \ - builder.setClassName(""#ClassName); \ - ClassName::staticMetaObject = *builder.toMetaObject(); \ - return true; \ -} \ -const QMetaObject &ClassName::getStaticMetaObject() \ -{ \ - return ClassName::staticMetaObject; \ -} \ -const QMetaObject* ClassName::metaObject() const \ -{ \ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; \ -} \ -void* ClassName::qt_metacast(const char*) \ -{ \ - return 0; \ -} \ -int ClassName::qt_metacall(QMetaObject::Call call, int id, void **argv) \ -{ \ - if (call == QMetaObject::ReadProperty || call == QMetaObject::WriteProperty) { \ - if (id >= ProxyObjectType::staticMetaObject.propertyCount()) { \ - id = AbstractDeclarativeObject::qt_metacall(call, id - ProxyObjectType::staticMetaObject.propertyCount() + 1, argv); \ - id += ProxyObjectType::staticMetaObject.propertyCount() - 1; \ - } else { \ - id = m_proxiedObject->qt_metacall(call, id, argv); \ - } \ - if (id < 0) \ - return 0; \ - } else if (call == QMetaObject::InvokeMetaMethod) {\ - if (ClassName::staticMetaObject.method(id).methodType() == QMetaMethod::Signal) \ - QMetaObject::activate(this, id, argv); \ - else \ - id = m_proxiedObject->qt_metacall(call, id, argv); \ - id -= 1; \ - } \ - return id; \ -} - -// AbstractDeclarativeObject -AbstractDeclarativeObject::AbstractDeclarativeObject(QObject *parent) - : QObject(parent) -{ -} - -AbstractDeclarativeObject::~AbstractDeclarativeObject() -{ -} - -QDeclarativeListProperty AbstractDeclarativeObject::data() -{ - return QDeclarativeListProperty(this, 0, AbstractDeclarativeObject::data_append, - AbstractDeclarativeObject::data_count, - AbstractDeclarativeObject::data_at, - AbstractDeclarativeObject::data_clear); -} - -void AbstractDeclarativeObject::dataAppend(QObject *) -{ -} - -int AbstractDeclarativeObject::dataCount() const -{ - return 0; -} - -QObject* AbstractDeclarativeObject::dataAt(int) const -{ - return 0; -} - -void AbstractDeclarativeObject::dataClear() -{ -} - -static void connectAllSignals(QObject *sender, QObject *receiver, const QSet &blacklist = QSet()) -{ - for (int i = 0; i < sender->metaObject()->methodCount(); ++i) { - const QMetaMethod method = sender->metaObject()->method(i); - if (method.methodType() == QMetaMethod::Signal) { - if (blacklist.contains(method.signature())) - continue; - - const QByteArray signature = "2" + QByteArray(method.signature()); - QObject::connect(sender, signature.data(), receiver, signature.data()); - } - } -} - -void AbstractDeclarativeObject::data_append(QDeclarativeListProperty *property, QObject *object) -{ - if (!object) - return; - - AbstractDeclarativeObject *that = dynamic_cast(property->object); - if (that) - that->dataAppend(object); - else - qWarning("cast went wrong in data_append"); -} - -int AbstractDeclarativeObject::data_count(QDeclarativeListProperty *property) -{ - AbstractDeclarativeObject *that = dynamic_cast(property->object); - if (that) - return that->dataCount(); - else { - qWarning("cast went wrong in data_count"); - return 0; - } -} - -QObject* AbstractDeclarativeObject::data_at(QDeclarativeListProperty *property, int index) -{ - AbstractDeclarativeObject *that = dynamic_cast(property->object); - if (that) - return that->dataAt(index); - else { - qWarning("cast went wrong in data_at"); - return 0; - } -} - -void AbstractDeclarativeObject::data_clear(QDeclarativeListProperty *property) -{ - AbstractDeclarativeObject *that = dynamic_cast(property->object); - if (that) - that->dataClear(); - else - qWarning("cast went wrong in data_clear"); -} - -//// Objects //// - -// DeclarativeAction -DeclarativeAction::DeclarativeAction(QObject *parent) : DeclarativeObjectProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeAction, QAction) - -// DeclarativeActionItem -DeclarativeActionItem::DeclarativeActionItem(QObject *parent) : DeclarativeObjectProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeActionItem, ActionItem) - -// DeclarativeButtonGroup -DeclarativeButtonGroup::DeclarativeButtonGroup(QObject *parent) : DeclarativeObjectProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeButtonGroup, ButtonGroup) - -// DeclarativeSeparator -DeclarativeSeparator::DeclarativeSeparator(QObject *parent) : DeclarativeObjectProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeSeparator, QAction) - -//// Layouts //// -class DeclarativeBoxLayoutAttached::Private -{ - public: - Private(QWidget *w, QLayout *l) : stretch(0), alignment(0), widget(w), layout(l) {} - - int stretch; - Qt::Alignment alignment; - - QPointer widget; - QPointer layout; - QPointer parentLayout; -}; - -DeclarativeBoxLayoutAttached::DeclarativeBoxLayoutAttached(QWidget *widget, QObject *parent) - : QObject(parent), d(new Private(widget, 0)) -{ -} - -DeclarativeBoxLayoutAttached::DeclarativeBoxLayoutAttached(QLayout *layout, QObject *parent) - : QObject(parent), d(new Private(0, layout)) -{ -} - -DeclarativeBoxLayoutAttached::~DeclarativeBoxLayoutAttached() -{ - delete d; -} - -void DeclarativeBoxLayoutAttached::setParentLayout(QBoxLayout *parentLayout) -{ - d->parentLayout = parentLayout; -} - -void DeclarativeBoxLayoutAttached::setStretch(int stretch) -{ - if (stretch == d->stretch) - return; - - d->stretch = stretch; - emit stretchChanged(stretch); -} - -int DeclarativeBoxLayoutAttached::stretch() const -{ - return d->stretch; -} - -void DeclarativeBoxLayoutAttached::setAlignment(Qt::Alignment alignment) -{ - if (alignment == d->alignment) - return; - - d->alignment = alignment; - emit alignmentChanged(alignment); - - if (d->parentLayout) { - if (d->widget) - d->parentLayout->setAlignment(d->widget, d->alignment); - - if (d->layout) - d->parentLayout->setAlignment(d->layout, d->alignment); - } -} - -Qt::Alignment DeclarativeBoxLayoutAttached::alignment() const -{ - return d->alignment; -} - -class DeclarativeFormLayoutAttached::Private -{ - public: - QString label; -}; - -DeclarativeFormLayoutAttached::DeclarativeFormLayoutAttached(QObject *parent) - : QObject(parent), d(new Private) -{ -} - -DeclarativeFormLayoutAttached::~DeclarativeFormLayoutAttached() -{ - delete d; -} - -void DeclarativeFormLayoutAttached::setLabel(const QString &label) -{ - if (label == d->label) - return; - - d->label = label; - emit labelChanged(label); -} - -class DeclarativeGridLayoutAttached::Private -{ - public: - Private(QWidget *w, QLayout *l) - : row(0), column(0), rowSpan(1), columnSpan(1), alignment(0), - widget(w), layout(l) - {} - - int row; - int column; - int rowSpan; - int columnSpan; - Qt::Alignment alignment; - - QPointer widget; - QPointer layout; - QPointer parentLayout; -}; - -DeclarativeGridLayoutAttached::DeclarativeGridLayoutAttached(QWidget *widget, QObject *parent) - : QObject(parent), d(new Private(widget, 0)) -{ -} - -DeclarativeGridLayoutAttached::DeclarativeGridLayoutAttached(QLayout *layout, QObject *parent) - : QObject(parent), d(new Private(0, layout)) -{ -} - -DeclarativeGridLayoutAttached::~DeclarativeGridLayoutAttached() -{ - delete d; -} - -void DeclarativeGridLayoutAttached::setParentLayout(QGridLayout *parentLayout) -{ - d->parentLayout = parentLayout; -} - -void DeclarativeGridLayoutAttached::setRow(int row) -{ - if (row == d->row) - return; - - d->row = row; - emit rowChanged(row); -} - -int DeclarativeGridLayoutAttached::row() const -{ - return d->row; -} - -void DeclarativeGridLayoutAttached::setColumn(int column) -{ - if (column == d->column) - return; - - d->column = column; - emit columnChanged(column); -} - -int DeclarativeGridLayoutAttached::column() const -{ - return d->column; -} - -void DeclarativeGridLayoutAttached::setRowSpan(int rowSpan) -{ - if (rowSpan == d->rowSpan) - return; - - d->rowSpan = rowSpan; - emit rowSpanChanged(rowSpan); -} - -int DeclarativeGridLayoutAttached::rowSpan() const -{ - return d->rowSpan; -} - -void DeclarativeGridLayoutAttached::setColumnSpan(int columnSpan) -{ - if (columnSpan == d->columnSpan) - return; - - d->columnSpan = columnSpan; - emit columnSpanChanged(columnSpan); -} - -int DeclarativeGridLayoutAttached::columnSpan() const -{ - return d->columnSpan; -} - -void DeclarativeGridLayoutAttached::setAlignment(Qt::Alignment alignment) -{ - if (alignment == d->alignment) - return; - - d->alignment = alignment; - emit alignmentChanged(alignment); - - if (d->parentLayout) { - if (d->widget) - d->parentLayout->setAlignment(d->widget, d->alignment); - - if (d->layout) - d->parentLayout->setAlignment(d->layout, d->alignment); - } -} - -Qt::Alignment DeclarativeGridLayoutAttached::alignment() const -{ - return d->alignment; -} - -QString DeclarativeFormLayoutAttached::label() const -{ - return d->label; -} - -// DeclarativeFormLayout -DeclarativeFormLayout::DeclarativeFormLayout(QObject *parent) : DeclarativeLayoutProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -DeclarativeFormLayoutAttached *DeclarativeFormLayout::qmlAttachedProperties(QObject *parent) -{ - return new DeclarativeFormLayoutAttached(parent); -} - -void DeclarativeFormLayout::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); - DeclarativeFormLayoutAttached *properties = qobject_cast(attachedProperties); - if (properties) { - if (!properties->label().isEmpty()) { - m_proxiedObject->addRow(properties->label(), widget); - m_children.append(declarativeObject); - return; - } - } - - m_proxiedObject->addRow(widget); - m_children.append(declarativeObject); -} - -void DeclarativeFormLayout::addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) -{ - QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); - DeclarativeFormLayoutAttached *properties = qobject_cast(attachedProperties); - if (properties) { - if (!properties->label().isEmpty()) { - m_proxiedObject->addRow(properties->label(), layout); - m_children.append(declarativeObject); - return; - } - } - m_proxiedObject->addRow(layout); - m_children.append(declarativeObject); -} - -CUSTOM_METAOBJECT(DeclarativeFormLayout, QFormLayout) - -// DeclarativeGridLayout -DeclarativeGridLayout::DeclarativeGridLayout(QObject *parent) : DeclarativeLayoutProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -DeclarativeGridLayoutAttached *DeclarativeGridLayout::qmlAttachedProperties(QObject *parent) -{ - AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); - if (declarativeObject) { - QWidget *widget = qobject_cast(declarativeObject->object()); - if (widget) - return new DeclarativeGridLayoutAttached(widget, parent); - - QLayout *layout = qobject_cast(declarativeObject->object()); - if (layout) - return new DeclarativeGridLayoutAttached(layout, parent); - } - - qmlInfo(parent) << "Can only attach GridLayout to widgets and layouts"; - return 0; -} - -void DeclarativeGridLayout::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - int row = 0; - int column = 0; - int rowSpan = 1; - int columnSpan = 1; - Qt::Alignment alignment = 0; - - QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); - DeclarativeGridLayoutAttached *properties = qobject_cast(attachedProperties); - if (properties) { - row = properties->row(); - column = properties->column(); - rowSpan = properties->rowSpan(); - columnSpan = properties->columnSpan(); - alignment = properties->alignment(); - - properties->setParentLayout(m_proxiedObject); - } - - m_proxiedObject->addWidget(widget, row, column, rowSpan, columnSpan, alignment); - m_children.append(declarativeObject); -} - -void DeclarativeGridLayout::addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) -{ - int row = 0; - int column = 0; - int rowSpan = 1; - int columnSpan = 1; - Qt::Alignment alignment = 0; - - QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); - DeclarativeGridLayoutAttached *properties = qobject_cast(attachedProperties); - if (properties) { - row = properties->row(); - column = properties->column(); - rowSpan = properties->rowSpan(); - columnSpan = properties->columnSpan(); - alignment = properties->alignment(); - - properties->setParentLayout(m_proxiedObject); - } - - m_proxiedObject->addLayout(layout, row, column, rowSpan, columnSpan, alignment); - m_children.append(declarativeObject); -} - -CUSTOM_METAOBJECT(DeclarativeGridLayout, QGridLayout) - -// DeclarativeHBoxLayout -DeclarativeHBoxLayout::DeclarativeHBoxLayout(QObject *parent) : DeclarativeLayoutProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -DeclarativeBoxLayoutAttached *DeclarativeHBoxLayout::qmlAttachedProperties(QObject *parent) -{ - AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); - if (declarativeObject) { - QWidget *widget = qobject_cast(declarativeObject->object()); - if (widget) - return new DeclarativeBoxLayoutAttached(widget, parent); - - QLayout *layout = qobject_cast(declarativeObject->object()); - if (layout) - return new DeclarativeBoxLayoutAttached(layout, parent); - } - - qmlInfo(parent) << "Can only attach HBoxLayout to widgets and layouts"; - return 0; -} - -void DeclarativeHBoxLayout::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - int stretch = 0; - Qt::Alignment alignment = 0; - - QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); - DeclarativeBoxLayoutAttached *properties = qobject_cast(attachedProperties); - if (properties) { - stretch = properties->stretch(); - alignment = properties->alignment(); - - properties->setParentLayout(m_proxiedObject); - } - - m_proxiedObject->addWidget(widget, stretch, alignment); - m_children.append(declarativeObject); -} - -void DeclarativeHBoxLayout::addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) -{ - int stretch = 0; - Qt::Alignment alignment = 0; - - QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); - DeclarativeBoxLayoutAttached *properties = qobject_cast(attachedProperties); - if (properties) { - stretch = properties->stretch(); - alignment = properties->alignment(); - - properties->setParentLayout(m_proxiedObject); - } - - m_proxiedObject->addLayout(layout, stretch); - m_proxiedObject->setAlignment(layout, alignment); - m_children.append(declarativeObject); -} - -CUSTOM_METAOBJECT(DeclarativeHBoxLayout, QHBoxLayout) - -// DeclarativeStackedLayout -DeclarativeStackedLayout::DeclarativeStackedLayout(QObject *parent) : DeclarativeLayoutProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -void DeclarativeStackedLayout::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - m_proxiedObject->addWidget(widget); - m_children.append(declarativeObject); -} - -void DeclarativeStackedLayout::addLayout(QLayout*, AbstractDeclarativeObject *declarativeObject) -{ - qmlInfo(declarativeObject) << "StackedLayout does not support child layouts"; -} - -CUSTOM_METAOBJECT(DeclarativeStackedLayout, StackedLayout) - -// DeclarativeVBoxLayout -DeclarativeVBoxLayout::DeclarativeVBoxLayout(QObject *parent) : DeclarativeLayoutProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -DeclarativeBoxLayoutAttached *DeclarativeVBoxLayout::qmlAttachedProperties(QObject *parent) -{ - AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); - if (declarativeObject) { - QWidget *widget = qobject_cast(declarativeObject->object()); - if (widget) - return new DeclarativeBoxLayoutAttached(widget, parent); - - QLayout *layout = qobject_cast(declarativeObject->object()); - if (layout) - return new DeclarativeBoxLayoutAttached(layout, parent); - } - - qmlInfo(parent) << "Can only attach VBoxLayout to widgets and layouts"; - return 0; -} - -void DeclarativeVBoxLayout::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - int stretch = 0; - Qt::Alignment alignment = 0; - - QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); - DeclarativeBoxLayoutAttached *properties = qobject_cast(attachedProperties); - if (properties) { - stretch = properties->stretch(); - alignment = properties->alignment(); - - properties->setParentLayout(m_proxiedObject); - } - - m_proxiedObject->addWidget(widget, stretch, alignment); - m_children.append(declarativeObject); -} - -void DeclarativeVBoxLayout::addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) -{ - int stretch = 0; - Qt::Alignment alignment = 0; - - QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); - DeclarativeBoxLayoutAttached *properties = qobject_cast(attachedProperties); - if (properties) { - stretch = properties->stretch(); - alignment = properties->alignment(); - - properties->setParentLayout(m_proxiedObject); - } - - m_proxiedObject->addLayout(layout, stretch); - m_proxiedObject->setAlignment(layout, alignment); - m_children.append(declarativeObject); -} - -CUSTOM_METAOBJECT(DeclarativeVBoxLayout, QVBoxLayout) - -//// Widgets //// - -// DeclarativeCalendarWidget -DeclarativeCalendarWidget::DeclarativeCalendarWidget(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeCalendarWidget, QCalendarWidget) - -// DeclarativeCheckBox -DeclarativeCheckBox::DeclarativeCheckBox(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeCheckBox, QCheckBox) - -// DeclarativeColorDialog -class DeclarativeColorDialogAttached::Private -{ - public: - Private() : options(0) {} - - public: - QPointer dialogParent; - QString title; - QColorDialog::ColorDialogOptions options; -}; - -DeclarativeColorDialogAttached::DeclarativeColorDialogAttached(QObject *parent) - : QObject(parent), d(new Private) -{ -} - -DeclarativeColorDialogAttached::~DeclarativeColorDialogAttached() -{ - delete d; -} - -void DeclarativeColorDialogAttached::setDialogParent(QObject *parent) -{ - if (parent == d->dialogParent) - return; - - d->dialogParent = parent; - emit dialogParentChanged(parent); -} - -QObject *DeclarativeColorDialogAttached::dialogParent() const -{ - return d->dialogParent; -} - -void DeclarativeColorDialogAttached::setTitle(const QString &title) -{ - if (title == d->title) - return; - - d->title = title; - emit titleChanged(title); -} - -QString DeclarativeColorDialogAttached::title() const -{ - return d->title; -} - -QColor DeclarativeColorDialogAttached::getColor(const QColor &initialColor) -{ - QWidget *parent = bestParentWindow(d->dialogParent); - if (!d->title.isEmpty() || d->options != 0) - return QColorDialog::getColor(initialColor, parent, d->title, d->options); - else - return QColorDialog::getColor(initialColor, parent); -} - -QWidget *DeclarativeColorDialogAttached::bestParentWindow(QObject *parent) const -{ - if (!parent) - parent = this->parent(); - - // if parent is a Declarative Object, search the proxied hierarchy - AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); - if (declarativeObject) - parent = declarativeObject->object(); - - while (parent) { - QWidget *widget = qobject_cast(parent); - if (widget) - return widget->topLevelWidget(); - - parent = parent->parent(); - } - - return 0; -} - -DeclarativeColorDialog::DeclarativeColorDialog(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -DeclarativeColorDialogAttached *DeclarativeColorDialog::qmlAttachedProperties(QObject *parent) -{ - return new DeclarativeColorDialogAttached(parent); -} - -CUSTOM_METAOBJECT(DeclarativeColorDialog, QColorDialog) - -// DeclarativeColumnView -DeclarativeColumnView::DeclarativeColumnView(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeColumnView, ColumnView) - -// DeclarativeCommandLinkButton -DeclarativeCommandLinkButton::DeclarativeCommandLinkButton(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeCommandLinkButton, QCommandLinkButton) - -// DeclarativeDateEdit -DeclarativeDateEdit::DeclarativeDateEdit(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeDateEdit, QDateEdit) - -// DeclarativeDateTimeEdit -DeclarativeDateTimeEdit::DeclarativeDateTimeEdit(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeDateTimeEdit, QDateTimeEdit) - -// DeclarativeDial -DeclarativeDial::DeclarativeDial(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeDial, QDial) - -// DeclarativeDialog -DeclarativeDialog::DeclarativeDialog(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeDialog, QDialog) - -// DeclarativeDialogButtonBox -DeclarativeDialogButtonBox::DeclarativeDialogButtonBox(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeDialogButtonBox, QDialogButtonBox) - -// DeclarativeDoubleSpinBox -DeclarativeDoubleSpinBox::DeclarativeDoubleSpinBox(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeDoubleSpinBox, QDoubleSpinBox) - -// DeclarativeFileDialog -class DeclarativeFileDialogAttached::Private -{ - public: - QPointer dialogParent; - QString caption; - QString dir; - QStringList nameFilters; - QString selectedFilter; -}; - -DeclarativeFileDialogAttached::DeclarativeFileDialogAttached(QObject *parent) - : QObject(parent), d(new Private) -{ -} - -DeclarativeFileDialogAttached::~DeclarativeFileDialogAttached() -{ - delete d; -} - -void DeclarativeFileDialogAttached::setDialogParent(QObject *parent) -{ - if (parent == d->dialogParent) - return; - - d->dialogParent = parent; - emit dialogParentChanged(parent); -} - -QObject *DeclarativeFileDialogAttached::dialogParent() const -{ - return d->dialogParent; -} - -void DeclarativeFileDialogAttached::setCaption(const QString &caption) -{ - if (caption == d->caption) - return; - - d->caption = caption; - emit captionChanged(caption); -} - -QString DeclarativeFileDialogAttached::caption() const -{ - return d->caption; -} - -void DeclarativeFileDialogAttached::setDir(const QString &dir) -{ - if (dir == d->dir) - return; - - d->dir = dir; - emit dirChanged(dir); -} - -QString DeclarativeFileDialogAttached::dir() const -{ - return d->dir; -} - -void DeclarativeFileDialogAttached::setNameFilters(const QStringList &nameFilters) -{ - if (nameFilters == d->nameFilters) - return; - - d->nameFilters = nameFilters; - emit nameFiltersChanged(nameFilters); -} - -QStringList DeclarativeFileDialogAttached::nameFilters() const -{ - return d->nameFilters; -} - -QString DeclarativeFileDialogAttached::selectedFilter() const -{ - return d->selectedFilter; -} - -QString DeclarativeFileDialogAttached::getExistingDirectory() -{ - return QFileDialog::getExistingDirectory(bestParentWindow(d->dialogParent), d->caption, d->dir, QFileDialog::ShowDirsOnly); -} - -QString DeclarativeFileDialogAttached::getOpenFileName() -{ - QString selectedFilter; - const QString retVal = QFileDialog::getOpenFileName(bestParentWindow(d->dialogParent), d->caption, d->dir, - d->nameFilters.join(";;"), &selectedFilter, 0); - setSelectedFilter(selectedFilter); - return retVal; -} - -QStringList DeclarativeFileDialogAttached::getOpenFileNames() -{ - QString selectedFilter; - const QStringList retVal = QFileDialog::getOpenFileNames(bestParentWindow(d->dialogParent), d->caption, d->dir, - d->nameFilters.join(";;"), &selectedFilter, 0); - setSelectedFilter(selectedFilter); - return retVal; -} - -QString DeclarativeFileDialogAttached::getSaveFileName() -{ - QString selectedFilter; - const QString retVal = QFileDialog::getSaveFileName(bestParentWindow(d->dialogParent), d->caption, d->dir, - d->nameFilters.join(";;"), &selectedFilter, 0); - setSelectedFilter(selectedFilter); - return retVal; -} - -QWidget *DeclarativeFileDialogAttached::bestParentWindow(QObject *parent) const -{ - if (!parent) - parent = this->parent(); - - // if parent is a Declarative Object, search the proxied hierarchy - AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); - if (declarativeObject) - parent = declarativeObject->object(); - - while (parent) { - QWidget *widget = qobject_cast(parent); - if (widget) - return widget->topLevelWidget(); - - parent = parent->parent(); - } - - return 0; -} - -void DeclarativeFileDialogAttached::setSelectedFilter(const QString &filter) -{ - if (filter == d->selectedFilter) - return; - - d->selectedFilter = filter; - emit selectedFilterChanged(filter); -} - -DeclarativeFileDialog::DeclarativeFileDialog(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -DeclarativeFileDialogAttached *DeclarativeFileDialog::qmlAttachedProperties(QObject *parent) -{ - return new DeclarativeFileDialogAttached(parent); -} - -CUSTOM_METAOBJECT(DeclarativeFileDialog, FileDialog) - -// DeclarativeFontDialog -DeclarativeFontDialog::DeclarativeFontDialog(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeFontDialog, QFontDialog) - -// DeclarativeFrame -DeclarativeFrame::DeclarativeFrame(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeFrame, QFrame) - -// DeclarativeGroupBox -DeclarativeGroupBox::DeclarativeGroupBox(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeGroupBox, QGroupBox) - -// DeclarativeInputDialog -class DeclarativeInputDialogAttached::Private -{ - public: - Private() : dialogAccepted(false), - value(0), min(-2147483647), max(2147483647), decimals(1), step(1), - currentItem(0), itemsEditable(true), - echoMode(QLineEdit::Normal) - {} - - public: - QPointer dialogParent; - QString title; - QString label; - bool dialogAccepted; - - QVariant value; - QVariant min; - QVariant max; - int decimals; - int step; - - int currentItem; - bool itemsEditable; - - QLineEdit::EchoMode echoMode; - QString text; -}; - -DeclarativeInputDialogAttached::DeclarativeInputDialogAttached(QObject *parent) - : QObject(parent), d(new Private) -{ -} - -DeclarativeInputDialogAttached::~DeclarativeInputDialogAttached() -{ - delete d; -} - -void DeclarativeInputDialogAttached::setDialogParent(QObject *parent) -{ - if (parent == d->dialogParent) - return; - - d->dialogParent = parent; - emit dialogParentChanged(parent); -} - -QObject *DeclarativeInputDialogAttached::dialogParent() const -{ - return d->dialogParent; -} - -void DeclarativeInputDialogAttached::setTitle(const QString &title) -{ - if (title == d->title) - return; - - d->title = title; - emit titleChanged(title); -} - -QString DeclarativeInputDialogAttached::title() const -{ - return d->title; -} - -void DeclarativeInputDialogAttached::setLabel(const QString &label) -{ - if (label == d->label) - return; - - d->label = label; - emit labelChanged(label); -} - -QString DeclarativeInputDialogAttached::label() const -{ - return d->label; -} - -bool DeclarativeInputDialogAttached::dialogAccepted() const -{ - return d->dialogAccepted; -} - -void DeclarativeInputDialogAttached::setValue(const QVariant &value) -{ - if (value == d->value) - return; - - d->value = value; - emit valueChanged(value); -} - -QVariant DeclarativeInputDialogAttached::value() const -{ - return d->value; -} - -void DeclarativeInputDialogAttached::setMin(const QVariant &min) -{ - if (min == d->min) - return; - - d->min = min; - emit minChanged(min); -} - -QVariant DeclarativeInputDialogAttached::min() const -{ - return d->min; -} - -void DeclarativeInputDialogAttached::setMax(const QVariant &max) -{ - if (max == d->max) - return; - - d->max = max; - emit maxChanged(max); -} - -QVariant DeclarativeInputDialogAttached::max() const -{ - return d->max; -} - -void DeclarativeInputDialogAttached::setDecimals(int decimals) -{ - if (decimals == d->decimals) - return; - - d->decimals = decimals; - emit decimalsChanged(decimals); -} - -int DeclarativeInputDialogAttached::decimals() const -{ - return d->decimals; -} - -void DeclarativeInputDialogAttached::setStep(int step) -{ - if (step == d->step) - return; - - d->step = step; - emit stepChanged(step); -} - -int DeclarativeInputDialogAttached::step() const -{ - return d->step; -} - -void DeclarativeInputDialogAttached::setCurrentItem(int current) -{ - if (current == d->currentItem) - return; - - d->currentItem = current; - emit currentItemChanged(current); -} - -int DeclarativeInputDialogAttached::currentItem() const -{ - return d->currentItem; -} - -void DeclarativeInputDialogAttached::setItemsEditable(bool editable) -{ - if (editable == d->itemsEditable) - return; - - d->itemsEditable = editable; - emit itemsEditableChanged(editable); -} - -bool DeclarativeInputDialogAttached::itemsEditable() const -{ - return d->itemsEditable; -} - -void DeclarativeInputDialogAttached::setEchoMode(QLineEdit::EchoMode echoMode) -{ - if (echoMode == d->echoMode) - return; - - d->echoMode = echoMode; - emit echoModeChanged(echoMode); -} - -QLineEdit::EchoMode DeclarativeInputDialogAttached::echoMode() const -{ - return d->echoMode; -} - -void DeclarativeInputDialogAttached::setText(const QString &text) -{ - if (text == d->text) - return; - - d->text = text; - emit textChanged(text); -} - -QString DeclarativeInputDialogAttached::text() const -{ - return d->text; -} - -double DeclarativeInputDialogAttached::getDouble() -{ - QWidget *parent = bestParentWindow(d->dialogParent); - bool ok = false; - const double value = d->value.canConvert() ? d->value.value() : 0.0; - const double min = d->min.canConvert() ? d->min.value() : -2147483647; - const double max = d->max.canConvert() ? d->max.value() : 2147483647; - - const double retVal = QInputDialog::getDouble(parent, d->title, d->label, value, min, max, d->decimals, &ok); - - setDialogAccepted(ok); - return retVal; -} - -int DeclarativeInputDialogAttached::getInt() -{ - QWidget *parent = bestParentWindow(d->dialogParent); - bool ok = false; - const int value = d->value.canConvert() ? d->value.value() : 0; - const int min = d->min.canConvert() ? d->min.value() : -2147483647; - const int max = d->max.canConvert() ? d->max.value() : 2147483647; - - const int retVal = QInputDialog::getInt(parent, d->title, d->label, value, min, max, d->step, &ok); - - setDialogAccepted(ok); - return retVal; -} - -QString DeclarativeInputDialogAttached::getItem(const QStringList &items) -{ - QWidget *parent = bestParentWindow(d->dialogParent); - bool ok = false; - - const QString retVal = QInputDialog::getItem(parent, d->title, d->label, items, d->currentItem, d->itemsEditable, &ok); - - setDialogAccepted(ok); - return retVal; -} - -QString DeclarativeInputDialogAttached::getText() -{ - QWidget *parent = bestParentWindow(d->dialogParent); - bool ok = false; - - const QString retVal = QInputDialog::getText(parent, d->title, d->label, d->echoMode, d->text, &ok); - - setDialogAccepted(ok); - return retVal; -} - -void DeclarativeInputDialogAttached::setDialogAccepted(bool accepted) -{ - if (accepted == d->dialogAccepted) - return; - - d->dialogAccepted = accepted; - emit dialogAcceptedChanged(accepted); -} - -QWidget *DeclarativeInputDialogAttached::bestParentWindow(QObject *parent) const -{ - if (!parent) - parent = this->parent(); - - // if parent is a Declarative Object, search the proxied hierarchy - AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); - if (declarativeObject) - parent = declarativeObject->object(); - - while (parent) { - QWidget *widget = qobject_cast(parent); - if (widget) - return widget->topLevelWidget(); - - parent = parent->parent(); - } - - return 0; -} - -DeclarativeInputDialog::DeclarativeInputDialog(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -DeclarativeInputDialogAttached *DeclarativeInputDialog::qmlAttachedProperties(QObject *parent) -{ - return new DeclarativeInputDialogAttached(parent); -} - -CUSTOM_METAOBJECT(DeclarativeInputDialog, InputDialog) - -// DeclarativeLabel -DeclarativeLabel::DeclarativeLabel(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeLabel, QLabel) - -// DeclarativeLCDNumber -DeclarativeLCDNumber::DeclarativeLCDNumber(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeLCDNumber, QLCDNumber) - -// DeclarativeLineEdit -DeclarativeLineEdit::DeclarativeLineEdit(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeLineEdit, QLineEdit) - -// DeclarativeListView -DeclarativeListView::DeclarativeListView(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeListView, ListView) - -// DeclarativeMainWindow -DeclarativeMainWindow::DeclarativeMainWindow(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -void DeclarativeMainWindow::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - QMenuBar *menuBar = qobject_cast(widget); - QToolBar *toolBar = qobject_cast(widget); - QStatusBar *statusBar = qobject_cast(widget); - QDialog *dialog = qobject_cast(widget); - - if (menuBar) { - m_proxiedObject->setMenuBar(menuBar); - } else if (toolBar) { - m_proxiedObject->addToolBar(toolBar); - } else if (statusBar) { - m_proxiedObject->setStatusBar(statusBar); - } else if (dialog) { - // We allow to place dialogs on the mainwindow - dialog->setParent(m_proxiedObject, dialog->windowFlags()); - } else if (widget) { - if (m_proxiedObject->centralWidget()) { - qmlInfo(declarativeObject) << "The QMainWindow contains a central widget already"; - return; - } - - m_proxiedObject->setCentralWidget(widget); - } - - m_children.append(declarativeObject); -} - -void DeclarativeMainWindow::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) -{ - Q_UNUSED(layout); - Q_UNUSED(declarativeObject); - qmlInfo(this) << "Can not set a QLayout to a QMainWindow"; -} - -CUSTOM_METAOBJECT(DeclarativeMainWindow, QMainWindow) - -// DeclarativeMenu -DeclarativeMenu::DeclarativeMenu(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -void DeclarativeMenu::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - QMenu *menu = qobject_cast(widget); - if (!menu) { - qmlInfo(declarativeObject) << "The QMenu can only contain QMenu, QAction or Separator"; - return; - } - - m_proxiedObject->addMenu(menu); - - m_children.append(declarativeObject); -} - -void DeclarativeMenu::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) -{ - Q_UNUSED(layout); - Q_UNUSED(declarativeObject); - qmlInfo(this) << "Can not set a QLayout to a QMenu"; -} - -void DeclarativeMenu::addAction(QAction *action, AbstractDeclarativeObject *declarativeObject) -{ - DeclarativeSeparator *separator = dynamic_cast(declarativeObject); - - if (separator) { - m_proxiedObject->addSeparator(); - } else { - m_proxiedObject->addAction(action); - } - - m_children.append(declarativeObject); -} - -CUSTOM_METAOBJECT(DeclarativeMenu, QMenu) - -// DeclarativeMenuBar -DeclarativeMenuBar::DeclarativeMenuBar(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -void DeclarativeMenuBar::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - QMenu *menu = qobject_cast(widget); - if (!menu) { - qmlInfo(declarativeObject) << "The QMenuBar can only contain QMenus"; - return; - } - - m_proxiedObject->addMenu(menu); - - m_children.append(declarativeObject); -} - -void DeclarativeMenuBar::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) -{ - Q_UNUSED(layout); - Q_UNUSED(declarativeObject); - qmlInfo(this) << "Can not set a QLayout to a QMenuBar"; -} - -void DeclarativeMenuBar::addAction(QAction *action, AbstractDeclarativeObject *declarativeObject) -{ - Q_UNUSED(action) - - DeclarativeSeparator *separator = dynamic_cast(declarativeObject); - - if (separator) { - m_proxiedObject->addSeparator(); - } - - m_children.append(declarativeObject); -} - -CUSTOM_METAOBJECT(DeclarativeMenuBar, QMenuBar) - -// DeclarativeMessageBox -DeclarativeMessageBoxAttached::DeclarativeMessageBoxAttached(QObject *parent) : QObject(parent) -{ -} - -void DeclarativeMessageBoxAttached::about(QObject *parent, const QString &title, const QString &text) -{ - QMessageBox::about(bestParentWindow(parent), title, text); -} - -void DeclarativeMessageBoxAttached::aboutQt(QObject *parent, const QString &title) -{ - QMessageBox::aboutQt(bestParentWindow(parent), title); -} - -int DeclarativeMessageBoxAttached::critical(QObject *parent, const QString &title, const QString &text, int buttons, int defaultButton) -{ - return QMessageBox::critical(bestParentWindow(parent), title, text, static_cast(buttons), static_cast(defaultButton)); -} - -int DeclarativeMessageBoxAttached::information(QObject *parent, const QString &title, const QString &text, int buttons, int defaultButton) -{ - return QMessageBox::information(bestParentWindow(parent), title, text, static_cast(buttons), static_cast(defaultButton)); -} - -int DeclarativeMessageBoxAttached::question(QObject *parent, const QString &title, const QString &text, int buttons, int defaultButton) -{ - return QMessageBox::question(bestParentWindow(parent), title, text, static_cast(buttons), static_cast(defaultButton)); -} - -int DeclarativeMessageBoxAttached::warning(QObject *parent, const QString &title, const QString &text, int buttons, int defaultButton) -{ - return QMessageBox::warning(bestParentWindow(parent), title, text, static_cast(buttons), static_cast(defaultButton)); -} - -QWidget *DeclarativeMessageBoxAttached::bestParentWindow(QObject *parent) const -{ - if (!parent) - parent = this->parent(); - - // if parent is a Declarative Object, search the proxied hierarchy - AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); - if (declarativeObject) - parent = declarativeObject->object(); - - while (parent) { - QWidget *widget = qobject_cast(parent); - if (widget) - return widget->topLevelWidget(); - - parent = parent->parent(); - } - - return 0; -} - -DeclarativeMessageBox::DeclarativeMessageBox(QObject *parent) : DeclarativeObjectProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -DeclarativeMessageBoxAttached *DeclarativeMessageBox::qmlAttachedProperties(QObject *parent) -{ - return new DeclarativeMessageBoxAttached(parent); -} - -CUSTOM_METAOBJECT(DeclarativeMessageBox, QMessageBox) - -// DeclarativePlainTextEdit -DeclarativePlainTextEdit::DeclarativePlainTextEdit(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativePlainTextEdit, QPlainTextEdit) - -// DeclarativeProgressBar -DeclarativeProgressBar::DeclarativeProgressBar(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeProgressBar, QProgressBar) - -// DeclarativePushButton -DeclarativePushButton::DeclarativePushButton(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this, QSet() << "clicked()"); -} - -CUSTOM_METAOBJECT(DeclarativePushButton, QPushButton) - -// DeclarativeRadioButton -DeclarativeRadioButton::DeclarativeRadioButton(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeRadioButton, QRadioButton) - -// DeclarativeScrollArea -DeclarativeScrollArea::DeclarativeScrollArea(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -void DeclarativeScrollArea::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - if (m_proxiedObject->widget()) { - qmlInfo(declarativeObject) << "Can not add multiple Widgets to ScrollArea"; - } else { - m_proxiedObject->setWidget(widget); - } - - m_children.append(declarativeObject); -} - -void DeclarativeScrollArea::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) -{ - Q_UNUSED(layout); - Q_UNUSED(declarativeObject); - qmlInfo(this) << "Can not add Layout to ScrollArea"; -} - -CUSTOM_METAOBJECT(DeclarativeScrollArea, QScrollArea) - -// DeclarativeScrollBar -DeclarativeScrollBar::DeclarativeScrollBar(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeScrollBar, QScrollBar) - -// DeclarativeSlider -DeclarativeSlider::DeclarativeSlider(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeSlider, QSlider) - -// DeclarativeSpinBox -DeclarativeSpinBox::DeclarativeSpinBox(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeSpinBox, QSpinBox) - -// DeclarativeStackedWidget -DeclarativeStackedWidget::DeclarativeStackedWidget(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -void DeclarativeStackedWidget::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - m_proxiedObject->addWidget(widget); - m_children.append(declarativeObject); -} - -void DeclarativeStackedWidget::setLayout(QLayout*, AbstractDeclarativeObject *declarativeObject) -{ - qmlInfo(declarativeObject) << "StackedWidget does not support child layouts"; -} - -CUSTOM_METAOBJECT(DeclarativeStackedWidget, QStackedWidget) - -// DeclarativeStatusBar -class DeclarativeStatusBarAttached::Private -{ - public: - int stretch; -}; - -DeclarativeStatusBarAttached::DeclarativeStatusBarAttached(QObject *parent) - : QObject(parent), d(new DeclarativeStatusBarAttached::Private) -{ - d->stretch = 0; -} - -DeclarativeStatusBarAttached::~DeclarativeStatusBarAttached() -{ - delete d; -} - -void DeclarativeStatusBarAttached::setStretch(int stretch) -{ - if (d->stretch == stretch) - return; - - d->stretch = stretch; - emit stretchChanged(); -} - -int DeclarativeStatusBarAttached::stretch() const -{ - return d->stretch; -} - -DeclarativeStatusBar::DeclarativeStatusBar(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -void DeclarativeStatusBar::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - // TODO: error when layout is set - - m_children.append(declarativeObject); - - QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); - DeclarativeStatusBarAttached *attached = qobject_cast(attachedProperties); - - int stretch = 0; - if (attached) { - stretch = attached->stretch(); - } - - m_proxiedObject->addPermanentWidget(widget, stretch); -} - -void DeclarativeStatusBar::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) -{ - Q_UNUSED(layout); - Q_UNUSED(declarativeObject); - qmlInfo(this) << "Can not add QLayout to QStatusBar"; -} - -DeclarativeStatusBarAttached *DeclarativeStatusBar::qmlAttachedProperties(QObject *object) -{ - return new DeclarativeStatusBarAttached(object); -} - -CUSTOM_METAOBJECT(DeclarativeStatusBar, QStatusBar) - -// DeclarativeTableView -DeclarativeTableView::DeclarativeTableView(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeTableView, TableView) - -// DeclarativeTabWidget -class DeclarativeTabWidgetAttached::Private -{ - public: - QString label; - QIcon icon; - QPointer tabWidget; - int index; -}; - -DeclarativeTabWidgetAttached::DeclarativeTabWidgetAttached(QObject *parent) - : QObject(parent), d(new DeclarativeTabWidgetAttached::Private) -{ -} - -DeclarativeTabWidgetAttached::~DeclarativeTabWidgetAttached() -{ - delete d; -} - -void DeclarativeTabWidgetAttached::setLabel(const QString &label) -{ - if (label == d->label) - return; - - d->label = label; - - if (d->tabWidget) - d->tabWidget->setTabText(d->index, d->label); - - emit labelChanged(label); -} - -QString DeclarativeTabWidgetAttached::label() const -{ - return d->label; -} - -void DeclarativeTabWidgetAttached::setIcon(const QIcon &icon) -{ - d->icon = icon; - - if (d->tabWidget) - d->tabWidget->setTabIcon(d->index, d->icon); - - emit iconChanged(icon); -} - -QIcon DeclarativeTabWidgetAttached::icon() const -{ - return d->icon; -} - -void DeclarativeTabWidgetAttached::setAssociation(QTabWidget *widget, int index) -{ - d->tabWidget = widget; - d->index = index; -} - -DeclarativeTabWidget::DeclarativeTabWidget(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -void DeclarativeTabWidget::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - // TODO: error when layout is set - - m_children.append(declarativeObject); - - QString label; - QIcon icon; - - QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); - DeclarativeTabWidgetAttached *tabHeader = qobject_cast(attachedProperties); - if (tabHeader) { - label = tabHeader->label(); - icon = tabHeader->icon(); - } - - const int index = m_proxiedObject->addTab(widget, icon, label); - if (tabHeader) - tabHeader->setAssociation(m_proxiedObject, index); -} - -void DeclarativeTabWidget::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) -{ - Q_UNUSED(layout); - Q_UNUSED(declarativeObject); - qmlInfo(this) << "Can not add QLayout to QTabWidget"; -} - -DeclarativeTabWidgetAttached *DeclarativeTabWidget::qmlAttachedProperties(QObject *object) -{ - return new DeclarativeTabWidgetAttached(object); -} - -CUSTOM_METAOBJECT(DeclarativeTabWidget, QTabWidget) - -// DeclarativeTextBrowser -DeclarativeTextBrowser::DeclarativeTextBrowser(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeTextBrowser, QTextBrowser) - -// DeclarativeTextEdit -DeclarativeTextEdit::DeclarativeTextEdit(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeTextEdit, TextEdit) - -// DeclarativeTimeEdit -DeclarativeTimeEdit::DeclarativeTimeEdit(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeTimeEdit, QTimeEdit) - -// DeclarativeToolBar -DeclarativeToolBar::DeclarativeToolBar(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -void DeclarativeToolBar::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) -{ - m_proxiedObject->addWidget(widget); - - m_children.append(declarativeObject); -} - -void DeclarativeToolBar::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) -{ - Q_UNUSED(layout); - Q_UNUSED(declarativeObject); - qmlInfo(this) << "Can not set a QLayout to a QToolBar"; -} - -void DeclarativeToolBar::addAction(QAction *action, AbstractDeclarativeObject *declarativeObject) -{ - DeclarativeSeparator *separator = dynamic_cast(declarativeObject); - - if (separator) { - m_proxiedObject->addSeparator(); - } else { - m_proxiedObject->addAction(action); - } - - m_children.append(declarativeObject); -} - -CUSTOM_METAOBJECT(DeclarativeToolBar, QToolBar) - -// DeclarativeToolButton -DeclarativeToolButton::DeclarativeToolButton(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeToolButton, QToolButton) - -// DeclarativeTreeView -DeclarativeTreeView::DeclarativeTreeView(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeTreeView, TreeView) - -// DeclarativeWebView -DeclarativeWebView::DeclarativeWebView(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeWebView, QWebView) - -// DeclarativeWidget -DeclarativeWidget::DeclarativeWidget(QObject *parent) : DeclarativeWidgetProxy(parent) -{ - connectAllSignals(m_proxiedObject, this); -} - -CUSTOM_METAOBJECT(DeclarativeWidget, QWidget) - diff --git a/declarativeobjects_p.h b/declarativeobjects_p.h deleted file mode 100644 index 0db7851..0000000 --- a/declarativeobjects_p.h +++ /dev/null @@ -1,1135 +0,0 @@ -#ifndef DECLARATIVEOBJECTS_H -#define DECLARATIVEOBJECTS_H - -#include "objectadaptors_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "objectadaptors_p.h" - -Q_DECLARE_METATYPE(QAction*) - -#define DECLARATIVE_OBJECT \ - public: \ - Q_OBJECT_CHECK \ - static QMetaObject staticMetaObject; \ - static bool metaObjectInitialized; \ - static bool initializeMetaObject(); \ - static const QMetaObject &getStaticMetaObject(); \ - virtual const QMetaObject *metaObject() const; \ - virtual void *qt_metacast(const char *); \ - virtual int qt_metacall(QMetaObject::Call, int, void **); \ - private: \ - -class AbstractDeclarativeObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QDeclarativeListProperty data READ data DESIGNABLE false) - - Q_CLASSINFO("DefaultProperty", "data") - - public: - AbstractDeclarativeObject(QObject *parent = 0); - virtual ~AbstractDeclarativeObject(); - - virtual QObject* object() const = 0; - - protected: - virtual void dataAppend(QObject *); - virtual int dataCount() const; - virtual QObject *dataAt(int) const; - virtual void dataClear(); - - private: - QDeclarativeListProperty data(); - - static void data_append(QDeclarativeListProperty *, QObject *); - static int data_count(QDeclarativeListProperty *); - static QObject *data_at(QDeclarativeListProperty *, int); - static void data_clear(QDeclarativeListProperty *); -}; - -template -class DeclarativeObjectProxy : public AbstractDeclarativeObject -{ -}; - -template -class DeclarativeObjectProxy : public AbstractDeclarativeObject -{ - public: - DeclarativeObjectProxy(QObject *parent = 0) : AbstractDeclarativeObject(parent), m_proxiedObject(new T) {} - ~DeclarativeObjectProxy() { delete m_proxiedObject; } - - virtual QObject *object() const { return m_proxiedObject.data(); } - - protected: - virtual void dataAppend(QObject *object) - { - m_children.append(object); - } - - virtual int dataCount() const { return m_children.count(); } - virtual QObject *dataAt(int index) const { return m_children.at(index); } - virtual void dataClear() - { - qDeleteAll(m_children); - m_children.clear(); - } - - protected: - QPointer m_proxiedObject; - QVector m_children; -}; - -template -class DeclarativeObjectProxy : public AbstractDeclarativeObject -{ - public: - DeclarativeObjectProxy(QObject *parent = 0) : AbstractDeclarativeObject(parent), m_proxiedObject(new T(0)) {} - ~DeclarativeObjectProxy() { delete m_proxiedObject; } - - virtual QObject *object() const { return m_proxiedObject.data(); } - - protected: - virtual void dataAppend(QObject *object) - { - m_children.append(object); - } - - virtual int dataCount() const { return m_children.count(); } - virtual QObject *dataAt(int index) const { return m_children.at(index); } - virtual void dataClear() - { - qDeleteAll(m_children); - m_children.clear(); - } - - protected: - QPointer m_proxiedObject; - QVector m_children; -}; - -class DeclarativeActionItem : public DeclarativeObjectProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeActionItem(QObject *parent = 0); -}; - -template -class DeclarativeWidgetProxy : public DeclarativeObjectProxy -{ - public: - DeclarativeWidgetProxy(QObject *parent = 0) : DeclarativeObjectProxy(parent) {} - - protected: - virtual void dataAppend(QObject *object) - { - AbstractDeclarativeObject *declarativeObject = dynamic_cast(object); - if (declarativeObject) { - QWidget *widget = qobject_cast(declarativeObject->object()); - if (widget) { - addWidget(widget, declarativeObject); - return; - } - - QLayout *layout = qobject_cast(declarativeObject->object()); - if (layout) { - // TODO: error when widget is set - - if (DeclarativeObjectProxy::m_proxiedObject->layout()) { - qmlInfo(this) << "Can not add a second Layout"; - return; - } - - setLayout(layout, declarativeObject); - return; - } - - DeclarativeActionItem *declarativeActionItem = dynamic_cast(object); - if (declarativeActionItem) { - addAction(qobject_cast(declarativeActionItem->object())->action(), declarativeObject); - return; - } - - QAction *action = qobject_cast(declarativeObject->object()); - if (action) { - addAction(action, declarativeObject); - return; - } - - addQObject(declarativeObject->object(), declarativeObject); - return; - } - - DeclarativeObjectProxy::dataAppend(object); - } - - virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) - { - Q_UNUSED(declarativeObject); - DeclarativeObjectProxy::m_children.append(declarativeObject); - widget->setParent(DeclarativeObjectProxy::m_proxiedObject, widget->windowFlags()); - } - - virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) - { - DeclarativeObjectProxy::m_children.append(declarativeObject); - DeclarativeObjectProxy::m_proxiedObject->setLayout(layout); - } - - virtual void addAction(QAction *action, AbstractDeclarativeObject *declarativeObject) - { - DeclarativeObjectProxy::m_children.append(declarativeObject); - DeclarativeObjectProxy::m_proxiedObject->addAction(action); - } - - virtual void addQObject(QObject *object, AbstractDeclarativeObject *declarativeObject) - { - object->setParent(DeclarativeObjectProxy::m_proxiedObject); - DeclarativeObjectProxy::m_children.append(declarativeObject); - } -}; - -template -class DeclarativeLayoutProxy : public DeclarativeObjectProxy -{ - public: - DeclarativeLayoutProxy(QObject *parent = 0) : DeclarativeObjectProxy(parent) {} - - protected: - virtual void dataAppend(QObject *object) - { - AbstractDeclarativeObject *declarativeObject = dynamic_cast(object); - if (declarativeObject) { - QWidget *widget = qobject_cast(declarativeObject->object()); - if (widget) { - addWidget(widget, declarativeObject); - return; - } - - QLayout *layout = qobject_cast(declarativeObject->object()); - if (layout) { - addLayout(layout, declarativeObject); - return; - } - } - - DeclarativeObjectProxy::dataAppend(object); - } - - virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) - { - DeclarativeObjectProxy::m_children.append(declarativeObject); - DeclarativeObjectProxy::m_proxiedObject->addWidget(widget); - } - - virtual void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) = 0; -}; - -//// Objects /// -class DeclarativeAction : public DeclarativeObjectProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeAction(QObject *parent = 0); -}; -Q_DECLARE_METATYPE(DeclarativeAction*) - -class DeclarativeButtonGroup : public DeclarativeObjectProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeButtonGroup(QObject *parent = 0); -}; - -class DeclarativeSeparator : public DeclarativeObjectProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeSeparator(QObject *parent = 0); -}; - -//// Layouts //// -class DeclarativeBoxLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int stretch READ stretch WRITE setStretch NOTIFY stretchChanged) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) - - public: - DeclarativeBoxLayoutAttached(QWidget *widget, QObject *parent); - DeclarativeBoxLayoutAttached(QLayout *layout, QObject *parent); - ~DeclarativeBoxLayoutAttached(); - - void setParentLayout(QBoxLayout *parentLayout); - - void setStretch(int stretch); - int stretch() const; - - void setAlignment(Qt::Alignment alignment); - Qt::Alignment alignment() const; - - Q_INVOKABLE QString foo() const { qDebug() << Q_FUNC_INFO; return "foo"; } - - Q_SIGNALS: - void stretchChanged(int stretch); - void alignmentChanged(Qt::Alignment alignment); - - private: - class Private; - Private *const d; -}; - -class DeclarativeFormLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) - - public: - DeclarativeFormLayoutAttached(QObject *parent); - ~DeclarativeFormLayoutAttached(); - - void setLabel(const QString &label); - QString label() const; - - Q_SIGNALS: - void labelChanged(const QString &label); - - private: - class Private; - Private *const d; -}; - -class DeclarativeGridLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int row READ row WRITE setRow NOTIFY rowChanged) - Q_PROPERTY(int column READ column WRITE setColumn NOTIFY columnChanged) - Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan NOTIFY rowSpanChanged) - Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan NOTIFY columnSpanChanged) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) - - public: - DeclarativeGridLayoutAttached(QWidget *widget, QObject *parent); - DeclarativeGridLayoutAttached(QLayout *layout, QObject *parent); - ~DeclarativeGridLayoutAttached(); - - void setParentLayout(QGridLayout *parentLayout); - - void setRow(int row); - int row() const; - - void setColumn(int column); - int column() const; - - void setRowSpan(int rowSpan); - int rowSpan() const; - - void setColumnSpan(int columnSpan); - int columnSpan() const; - - void setAlignment(Qt::Alignment alignment); - Qt::Alignment alignment() const; - - Q_SIGNALS: - void rowChanged(int row); - void columnChanged(int column); - void rowSpanChanged(int rowSpan); - void columnSpanChanged(int columnSpan); - void alignmentChanged(Qt::Alignment alignment); - - private: - class Private; - Private *const d; -}; - -class DeclarativeFormLayout : public DeclarativeLayoutProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeFormLayout(QObject *parent = 0); - - static DeclarativeFormLayoutAttached *qmlAttachedProperties(QObject *parent); - - protected: - void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); -}; - -QML_DECLARE_TYPEINFO(DeclarativeFormLayout, QML_HAS_ATTACHED_PROPERTIES) - -class DeclarativeGridLayout : public DeclarativeLayoutProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeGridLayout(QObject *parent = 0); - - static DeclarativeGridLayoutAttached *qmlAttachedProperties(QObject *parent); - - protected: - void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); -}; - -QML_DECLARE_TYPEINFO(DeclarativeGridLayout, QML_HAS_ATTACHED_PROPERTIES) - -class DeclarativeHBoxLayout : public DeclarativeLayoutProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeHBoxLayout(QObject *parent = 0); - - static DeclarativeBoxLayoutAttached *qmlAttachedProperties(QObject *parent); - - protected: - void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); -}; - - -QML_DECLARE_TYPEINFO(DeclarativeHBoxLayout, QML_HAS_ATTACHED_PROPERTIES) - -class DeclarativeStackedLayout : public DeclarativeLayoutProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeStackedLayout(QObject *parent = 0); - - protected: - void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); -}; - -class DeclarativeVBoxLayout : public DeclarativeLayoutProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeVBoxLayout(QObject *parent = 0); - - static DeclarativeBoxLayoutAttached *qmlAttachedProperties(QObject *parent); - - protected: - void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); -}; - -QML_DECLARE_TYPEINFO(DeclarativeVBoxLayout, QML_HAS_ATTACHED_PROPERTIES) - -//// Widgets //// -class DeclarativeCalendarWidget : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeCalendarWidget(QObject *parent = 0); -}; - -class DeclarativeCheckBox : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeCheckBox(QObject *parent = 0); -}; - -class DeclarativeColorDialogAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QObject* parent READ dialogParent WRITE setDialogParent NOTIFY dialogParentChanged) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) - // TODO option - - public: - DeclarativeColorDialogAttached(QObject *parent = 0); - ~DeclarativeColorDialogAttached(); - - void setDialogParent(QObject *parent); - QObject *dialogParent() const; - - void setTitle(const QString &title); - QString title() const; - - Q_INVOKABLE QColor getColor(const QColor &initialColor); - - Q_SIGNALS: - void dialogParentChanged(QObject *parent); - void titleChanged(const QString &title); - - private: - QWidget *bestParentWindow(QObject *parent) const; - - class Private; - Private *const d; -}; - -class DeclarativeColorDialog : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeColorDialog(QObject *parent = 0); - - static DeclarativeColorDialogAttached *qmlAttachedProperties(QObject *parent); -}; - -QML_DECLARE_TYPEINFO(DeclarativeColorDialog, QML_HAS_ATTACHED_PROPERTIES) - -class DeclarativeColumnView : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeColumnView(QObject *parent = 0); -}; - -class DeclarativeCommandLinkButton : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeCommandLinkButton(QObject *parent = 0); -}; - -class DeclarativeDateEdit : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeDateEdit(QObject *parent = 0); -}; - -class DeclarativeDateTimeEdit : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeDateTimeEdit(QObject *parent = 0); -}; - -class DeclarativeDial : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeDial(QObject *parent = 0); -}; - -class DeclarativeDialog : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeDialog(QObject *parent = 0); -}; - -class DeclarativeDialogButtonBox : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeDialogButtonBox(QObject *parent = 0); -}; - -class DeclarativeDoubleSpinBox : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeDoubleSpinBox(QObject *parent = 0); -}; - -class DeclarativeFileDialogAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QObject* parent READ dialogParent WRITE setDialogParent NOTIFY dialogParentChanged) - Q_PROPERTY(QString caption READ caption WRITE setCaption NOTIFY captionChanged) - Q_PROPERTY(QString dir READ dir WRITE setDir NOTIFY dirChanged) - Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY nameFiltersChanged) - // TODO dialog option - Q_PROPERTY(QString selectedFilter READ selectedFilter NOTIFY selectedFilterChanged) - - public: - DeclarativeFileDialogAttached(QObject *parent = 0); - ~DeclarativeFileDialogAttached(); - - void setDialogParent(QObject *parent); - QObject *dialogParent() const; - - void setCaption(const QString &caption); - QString caption() const; - - void setDir(const QString &dir); - QString dir() const; - - void setNameFilters(const QStringList &nameFilters); - QStringList nameFilters() const; - - QString selectedFilter() const; - - Q_INVOKABLE QString getExistingDirectory(); - - Q_INVOKABLE QString getOpenFileName(); - - Q_INVOKABLE QStringList getOpenFileNames(); - - Q_INVOKABLE QString getSaveFileName(); - - Q_SIGNALS: - void dialogParentChanged(QObject *parent); - void captionChanged(const QString &caption); - void dirChanged(const QString &dir); - void nameFiltersChanged(const QStringList &filters); - void selectedFilterChanged(const QString &filter); - - private: - QWidget *bestParentWindow(QObject *parent) const; - void setSelectedFilter(const QString &filter); - - class Private; - Private *const d; -}; - -class DeclarativeFileDialog : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeFileDialog(QObject *parent = 0); - - static DeclarativeFileDialogAttached *qmlAttachedProperties(QObject *parent); -}; - -QML_DECLARE_TYPEINFO(DeclarativeFileDialog, QML_HAS_ATTACHED_PROPERTIES) - -class DeclarativeFontDialog : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeFontDialog(QObject *parent = 0); -}; - -class DeclarativeFrame : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeFrame(QObject *parent = 0); -}; - -class DeclarativeGroupBox : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeGroupBox(QObject *parent = 0); -}; - -class DeclarativeInputDialogAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QObject* parent READ dialogParent WRITE setDialogParent NOTIFY dialogParentChanged) - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) - Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) - Q_PROPERTY(bool ok READ dialogAccepted NOTIFY dialogAcceptedChanged) - - Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) - Q_PROPERTY(QVariant min READ min WRITE setMin NOTIFY minChanged) - Q_PROPERTY(QVariant max READ max WRITE setMax NOTIFY maxChanged) - Q_PROPERTY(int decimals READ decimals WRITE setDecimals NOTIFY decimalsChanged) - Q_PROPERTY(int step READ step WRITE setStep NOTIFY stepChanged) - - Q_PROPERTY(int current READ currentItem WRITE setCurrentItem NOTIFY currentItemChanged) - Q_PROPERTY(bool editable READ itemsEditable WRITE setItemsEditable NOTIFY itemsEditableChanged) - - Q_PROPERTY(QLineEdit::EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged) - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - - public: - DeclarativeInputDialogAttached(QObject *parent = 0); - ~DeclarativeInputDialogAttached(); - - void setDialogParent(QObject *parent); - QObject *dialogParent() const; - - void setTitle(const QString &title); - QString title() const; - - void setLabel(const QString &label); - QString label() const; - - bool dialogAccepted() const; - - void setValue(const QVariant &value); - QVariant value() const; - - void setMin(const QVariant &min); - QVariant min() const; - - void setMax(const QVariant &max); - QVariant max() const; - - void setDecimals(int decimals); - int decimals() const; - - void setStep(int step); - int step() const; - - void setCurrentItem(int current); - int currentItem() const; - - void setItemsEditable(bool editable); - bool itemsEditable() const; - - void setEchoMode(QLineEdit::EchoMode echoMode); - QLineEdit::EchoMode echoMode() const; - - void setText(const QString &text); - QString text() const; - - Q_INVOKABLE double getDouble(); - - Q_INVOKABLE int getInt(); - - Q_INVOKABLE QString getItem(const QStringList &items); - - Q_INVOKABLE QString getText(); - - Q_SIGNALS: - void dialogParentChanged(QObject *parent); - void titleChanged(const QString &title); - void labelChanged(const QString &label); - void dialogAcceptedChanged(bool accepted); - - void valueChanged(const QVariant &value); - void minChanged(const QVariant &min); - void maxChanged(const QVariant &max); - void decimalsChanged(int decimals); - void stepChanged(int step); - - void currentItemChanged(int current); - void itemsEditableChanged(bool editable); - - void echoModeChanged(QLineEdit::EchoMode echoMode); - void textChanged(const QString &text); - - private: - void setDialogAccepted(bool accepted); - QWidget *bestParentWindow(QObject *parent) const; - - class Private; - Private *const d; -}; - -class DeclarativeInputDialog : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeInputDialog(QObject *parent = 0); - - static DeclarativeInputDialogAttached *qmlAttachedProperties(QObject *parent); -}; - -QML_DECLARE_TYPEINFO(DeclarativeInputDialog, QML_HAS_ATTACHED_PROPERTIES) - -class DeclarativeLabel : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeLabel(QObject *parent = 0); -}; - -class DeclarativeLCDNumber : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeLCDNumber(QObject *parent = 0); -}; - -class DeclarativeLineEdit : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeLineEdit(QObject *parent = 0); -}; - -class DeclarativeListView : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeListView(QObject *parent = 0); -}; - -class DeclarativeMainWindow : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeMainWindow(QObject *parent = 0); - - protected: - virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); -}; - -class DeclarativeMenu : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeMenu(QObject *parent = 0); - - protected: - virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); - virtual void addAction(QAction *action, AbstractDeclarativeObject *declarativeObject); -}; - -class DeclarativeMenuBar : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeMenuBar(QObject *parent = 0); - - protected: - virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); - virtual void addAction(QAction *action, AbstractDeclarativeObject *declarativeObject); -}; - -class DeclarativeMessageBoxAttached : public QObject -{ - Q_OBJECT - - public: - DeclarativeMessageBoxAttached(QObject *parent = 0); - - Q_INVOKABLE void about(QObject *parent, const QString &title, const QString &text); - Q_INVOKABLE void aboutQt(QObject *parent, const QString &title); - Q_INVOKABLE int critical(QObject *parent, const QString &title, const QString &text, - int buttons = QMessageBox::Ok, int defaultButton = QMessageBox::NoButton); - Q_INVOKABLE int information(QObject *parent, const QString &title, const QString &text, - int buttons = QMessageBox::Ok, int defaultButton = QMessageBox::NoButton); - Q_INVOKABLE int question(QObject *parent, const QString &title, const QString &text, - int buttons = QMessageBox::Ok, int defaultButton = QMessageBox::NoButton); - Q_INVOKABLE int warning(QObject *parent, const QString &title, const QString &text, - int buttons = QMessageBox::Ok, int defaultButton = QMessageBox::NoButton); - - private: - QWidget *bestParentWindow(QObject *parent) const; -}; - -class DeclarativeMessageBox : public DeclarativeObjectProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeMessageBox(QObject *parent = 0); - - static DeclarativeMessageBoxAttached *qmlAttachedProperties(QObject *parent); -}; - -QML_DECLARE_TYPEINFO(DeclarativeMessageBox, QML_HAS_ATTACHED_PROPERTIES) - -class DeclarativePlainTextEdit : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativePlainTextEdit(QObject *parent = 0); -}; - -class DeclarativeProgressBar : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeProgressBar(QObject *parent = 0); -}; - -class DeclarativePushButton : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativePushButton(QObject *parent = 0); -}; - -class DeclarativeRadioButton : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeRadioButton(QObject *parent = 0); -}; - -class DeclarativeScrollArea : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeScrollArea(QObject *parent = 0); - - protected: - virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); -}; - -class DeclarativeScrollBar : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeScrollBar(QObject *parent = 0); -}; - -class DeclarativeSlider : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeSlider(QObject *parent = 0); -}; - -class DeclarativeSpinBox : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeSpinBox(QObject *parent = 0); -}; - -class DeclarativeStackedWidget : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeStackedWidget(QObject *parent = 0); - - protected: - virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); -}; - -// attached property for DeclarativeStatusBar -class DeclarativeStatusBarAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int stretch READ stretch WRITE setStretch NOTIFY stretchChanged) - - public: - DeclarativeStatusBarAttached(QObject *parent = 0); - ~DeclarativeStatusBarAttached(); - - void setStretch(int stretch); - int stretch() const; - - Q_SIGNALS: - void stretchChanged(); - - private: - class Private; - Private *const d; -}; - -class DeclarativeStatusBar : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeStatusBar(QObject *parent = 0); - - static DeclarativeStatusBarAttached *qmlAttachedProperties(QObject *object); - - protected: - virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); -}; - -QML_DECLARE_TYPEINFO(DeclarativeStatusBar, QML_HAS_ATTACHED_PROPERTIES) - -class DeclarativeTableView : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeTableView(QObject *parent = 0); -}; - -// attached property for DeclarativeTabWidget -class DeclarativeTabWidgetAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) - Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged) - - public: - DeclarativeTabWidgetAttached(QObject *parent = 0); - ~DeclarativeTabWidgetAttached(); - - void setLabel(const QString &label); - QString label() const; - - void setIcon(const QIcon &icon); - QIcon icon() const; - - void setAssociation(QTabWidget *widget, int index); - - Q_SIGNALS: - void labelChanged(const QString &label); - void iconChanged(const QIcon &icon); - - private: - class Private; - Private *const d; -}; - -class DeclarativeTabWidget : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeTabWidget(QObject *parent = 0); - - static DeclarativeTabWidgetAttached *qmlAttachedProperties(QObject *object); - - protected: - virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); -}; - -QML_DECLARE_TYPEINFO(DeclarativeTabWidget, QML_HAS_ATTACHED_PROPERTIES) - -class DeclarativeTextBrowser : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeTextBrowser(QObject *parent = 0); -}; - -class DeclarativeTextEdit : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeTextEdit(QObject *parent = 0); -}; - -class DeclarativeTimeEdit : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeTimeEdit(QObject *parent = 0); -}; - -class DeclarativeToolBar : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeToolBar(QObject *parent = 0); - - protected: - virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); - virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); - virtual void addAction(QAction *action, AbstractDeclarativeObject *declarativeObject); -}; - -class DeclarativeToolButton : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeToolButton(QObject *parent = 0); -}; - -class DeclarativeTreeView : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeTreeView(QObject *parent = 0); -}; - -class DeclarativeWebView : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeWebView(QObject *parent = 0); -}; - -class DeclarativeWidget : public DeclarativeWidgetProxy -{ - DECLARATIVE_OBJECT - - public: - DeclarativeWidget(QObject *parent = 0); -}; - -#endif diff --git a/declarativewidgetdocument.h b/declarativewidgetdocument.h deleted file mode 100644 index e156df6..0000000 --- a/declarativewidgetdocument.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef DECLARATIVEWIDGETDOCUMENT_H -#define DECLARATIVEWIDGETDOCUMENT_H - -#include -#include - -class QDeclarativeEngine; - -class DeclarativeWidgetDocument : public QObject -{ - Q_OBJECT - - public: - DeclarativeWidgetDocument(const QUrl &url, QObject *parent = 0); - ~DeclarativeWidgetDocument(); - - void setContextProperty(const QString &name, const QVariant &value); - void setContextProperty(const QString &name, QObject *object); - - QDeclarativeEngine* engine() const; - - template - T* create() - { - QWidget *widget = createWidget(); - if (!widget) - return 0; - - return qobject_cast(widget); - } - - private: - QWidget* createWidget(); - - class Private; - Private* const d; -}; - -#endif diff --git a/declarativewidgets.pro b/declarativewidgets.pro index bc9ed0d..6d67f2f 100644 --- a/declarativewidgets.pro +++ b/declarativewidgets.pro @@ -5,30 +5,147 @@ TEMPLATE = app TARGET = DEPENDPATH += . -INCLUDEPATH += . +INCLUDEPATH += . lib/ # Input +LIB_HEADERS = \ + lib/abstractdeclarativeobject_p.h \ + lib/declarativeactionitem_p.h \ + lib/declarativeaction_p.h \ + lib/declarativeboxlayout_p.h \ + lib/declarativebuttongroup_p.h \ + lib/declarativecalendarwidget_p.h \ + lib/declarativecheckbox_p.h \ + lib/declarativecolordialog_p.h \ + lib/declarativecolumnview_p.h \ + lib/declarativecommandlinkbutton_p.h \ + lib/declarativedateedit_p.h \ + lib/declarativedatetimeedit_p.h \ + lib/declarativedialogbuttonbox_p.h \ + lib/declarativedialog_p.h \ + lib/declarativedial_p.h \ + lib/declarativedoublespinbox_p.h \ + lib/declarativefiledialog_p.h \ + lib/declarativefontdialog_p.h \ + lib/declarativeformlayout_p.h \ + lib/declarativeframe_p.h \ + lib/declarativegridlayout_p.h \ + lib/declarativegroupbox_p.h \ + lib/declarativehboxlayout_p.h \ + lib/declarativeinputdialog_p.h \ + lib/declarativelabel_p.h \ + lib/declarativelayoutproxy_p.h \ + lib/declarativelcdnumber_p.h \ + lib/declarativelineedit_p.h \ + lib/declarativelistview_p.h \ + lib/declarativemainwindow_p.h \ + lib/declarativemenubar_p.h \ + lib/declarativemenu_p.h \ + lib/declarativemessagebox_p.h \ + lib/declarativeobjectproxy_p.h \ + lib/declarativeplaintextedit_p.h \ + lib/declarativeprogressbar_p.h \ + lib/declarativepushbutton_p.h \ + lib/declarativeradiobutton_p.h \ + lib/declarativescrollarea_p.h \ + lib/declarativescrollbar_p.h \ + lib/declarativeseparator_p.h \ + lib/declarativeslider_p.h \ + lib/declarativespinbox_p.h \ + lib/declarativestackedlayout_p.h \ + lib/declarativestackedwidget_p.h \ + lib/declarativestatusbar_p.h \ + lib/declarativetableview_p.h \ + lib/declarativetabwidget_p.h \ + lib/declarativetextbrowser_p.h \ + lib/declarativetextedit_p.h \ + lib/declarativetimeedit_p.h \ + lib/declarativetoolbar_p.h \ + lib/declarativetoolbutton_p.h \ + lib/declarativetreeview_p.h \ + lib/declarativevboxlayout_p.h \ + lib/declarativewebview_p.h \ + lib/declarativewidget_p.h \ + lib/declarativewidgetproxy_p.h \ + lib/declarativewidgetsdocument.h \ + lib/objectadaptors_p.h \ + lib/qmetaobjectbuilder_p.h + +LIB_SOURCES = \ + lib/abstractdeclarativeobject.cpp \ + lib/declarativeaction.cpp \ + lib/declarativeactionitem.cpp \ + lib/declarativeboxlayout.cpp \ + lib/declarativebuttongroup.cpp \ + lib/declarativecalendarwidget.cpp \ + lib/declarativecheckbox.cpp \ + lib/declarativecolordialog.cpp \ + lib/declarativecolumnview.cpp \ + lib/declarativecommandlinkbutton.cpp \ + lib/declarativedateedit.cpp \ + lib/declarativedatetimeedit.cpp \ + lib/declarativedial.cpp \ + lib/declarativedialogbuttonbox.cpp \ + lib/declarativedialog.cpp \ + lib/declarativedoublespinbox.cpp \ + lib/declarativefiledialog.cpp \ + lib/declarativefontdialog.cpp \ + lib/declarativeformlayout.cpp \ + lib/declarativeframe.cpp \ + lib/declarativegridlayout.cpp \ + lib/declarativegroupbox.cpp \ + lib/declarativehboxlayout.cpp \ + lib/declarativeinputdialog.cpp \ + lib/declarativelabel.cpp \ + lib/declarativelcdnumber.cpp \ + lib/declarativelineedit.cpp \ + lib/declarativelistview.cpp \ + lib/declarativemainwindow.cpp \ + lib/declarativemenubar.cpp \ + lib/declarativemenu.cpp \ + lib/declarativemessagebox.cpp \ + lib/declarativeplaintextedit.cpp \ + lib/declarativeprogressbar.cpp \ + lib/declarativepushbutton.cpp \ + lib/declarativeradiobutton.cpp \ + lib/declarativescrollarea.cpp \ + lib/declarativescrollbar.cpp \ + lib/declarativeseparator.cpp \ + lib/declarativeslider.cpp \ + lib/declarativespinbox.cpp \ + lib/declarativestackedlayout.cpp \ + lib/declarativestackedwidget.cpp \ + lib/declarativestatusbar.cpp \ + lib/declarativetableview.cpp \ + lib/declarativetabwidget.cpp \ + lib/declarativetextbrowser.cpp \ + lib/declarativetextedit.cpp \ + lib/declarativetimeedit.cpp \ + lib/declarativetoolbar.cpp \ + lib/declarativetoolbutton.cpp \ + lib/declarativetreeview.cpp \ + lib/declarativevboxlayout.cpp \ + lib/declarativewebview.cpp \ + lib/declarativewidget.cpp \ + lib/declarativewidgetsdocument.cpp \ + lib/objectadaptors.cpp \ + lib/qmetaobjectbuilder.cpp + HEADERS += \ - declarativeobjects_p.h \ - declarativewidgetdocument.h \ - objectadaptors_p.h \ - qmetaobjectbuilder_p.h + $$LIB_HEADERS SOURCES += \ - declarativeobjects.cpp \ - declarativewidgetdocument.cpp \ - main.cpp \ - objectadaptors.cpp \ - qmetaobjectbuilder.cpp + $$LIB_SOURCES \ + main.cpp QT += declarative webkit OTHER_FILES += \ - animation.qml \ - browser.qml \ - dialogs.qml \ - editor.qml \ - gallery.qml \ - layouts.qml \ - test.qml \ - messagebox.qml + examples/animation.qml \ + examples/browser.qml \ + examples/dialogs.qml \ + examples/editor.qml \ + examples/gallery.qml \ + examples/layouts.qml \ + examples/test.qml \ + examples/messagebox.qml diff --git a/animation.qml b/examples/animation.qml similarity index 100% rename from animation.qml rename to examples/animation.qml diff --git a/browser.qml b/examples/browser.qml similarity index 100% rename from browser.qml rename to examples/browser.qml diff --git a/dialogs.qml b/examples/dialogs.qml similarity index 100% rename from dialogs.qml rename to examples/dialogs.qml diff --git a/editor.qml b/examples/editor.qml similarity index 100% rename from editor.qml rename to examples/editor.qml diff --git a/filedialog.qml b/examples/filedialog.qml similarity index 100% rename from filedialog.qml rename to examples/filedialog.qml diff --git a/gallery.qml b/examples/gallery.qml similarity index 100% rename from gallery.qml rename to examples/gallery.qml diff --git a/layouts.qml b/examples/layouts.qml similarity index 100% rename from layouts.qml rename to examples/layouts.qml diff --git a/messagebox.qml b/examples/messagebox.qml similarity index 100% rename from messagebox.qml rename to examples/messagebox.qml diff --git a/test.qml b/examples/test.qml similarity index 100% rename from test.qml rename to examples/test.qml diff --git a/lib/abstractdeclarativeobject.cpp b/lib/abstractdeclarativeobject.cpp new file mode 100644 index 0000000..abae271 --- /dev/null +++ b/lib/abstractdeclarativeobject.cpp @@ -0,0 +1,116 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "abstractdeclarativeobject_p.h" + +#include + +AbstractDeclarativeObject::AbstractDeclarativeObject(QObject *parent) + : QObject(parent) +{ +} + +AbstractDeclarativeObject::~AbstractDeclarativeObject() +{ +} + +QDeclarativeListProperty AbstractDeclarativeObject::data() +{ + return QDeclarativeListProperty(this, 0, AbstractDeclarativeObject::data_append, + AbstractDeclarativeObject::data_count, + AbstractDeclarativeObject::data_at, + AbstractDeclarativeObject::data_clear); +} + +void AbstractDeclarativeObject::dataAppend(QObject *) +{ +} + +int AbstractDeclarativeObject::dataCount() const +{ + return 0; +} + +QObject* AbstractDeclarativeObject::dataAt(int) const +{ + return 0; +} + +void AbstractDeclarativeObject::dataClear() +{ +} + +void AbstractDeclarativeObject::connectAllSignals(QObject *sender, QObject *receiver, const QSet &blacklist) const +{ + for (int i = 0; i < sender->metaObject()->methodCount(); ++i) { + const QMetaMethod method = sender->metaObject()->method(i); + if (method.methodType() == QMetaMethod::Signal) { + if (blacklist.contains(method.signature())) + continue; + + const QByteArray signature = "2" + QByteArray(method.signature()); + QObject::connect(sender, signature.data(), receiver, signature.data()); + } + } +} + +void AbstractDeclarativeObject::data_append(QDeclarativeListProperty *property, QObject *object) +{ + if (!object) + return; + + AbstractDeclarativeObject *that = dynamic_cast(property->object); + if (that) + that->dataAppend(object); + else + qWarning("cast went wrong in data_append"); +} + +int AbstractDeclarativeObject::data_count(QDeclarativeListProperty *property) +{ + AbstractDeclarativeObject *that = dynamic_cast(property->object); + if (that) + return that->dataCount(); + else { + qWarning("cast went wrong in data_count"); + return 0; + } +} + +QObject* AbstractDeclarativeObject::data_at(QDeclarativeListProperty *property, int index) +{ + AbstractDeclarativeObject *that = dynamic_cast(property->object); + if (that) + return that->dataAt(index); + else { + qWarning("cast went wrong in data_at"); + return 0; + } +} + +void AbstractDeclarativeObject::data_clear(QDeclarativeListProperty *property) +{ + AbstractDeclarativeObject *that = dynamic_cast(property->object); + if (that) + that->dataClear(); + else + qWarning("cast went wrong in data_clear"); +} + diff --git a/lib/abstractdeclarativeobject_p.h b/lib/abstractdeclarativeobject_p.h new file mode 100644 index 0000000..c2672a6 --- /dev/null +++ b/lib/abstractdeclarativeobject_p.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef ABSTRACTDECLARATIVEOBJECT_P_H +#define ABSTRACTDECLARATIVEOBJECT_P_H + +#include +#include +#include + +class AbstractDeclarativeObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QDeclarativeListProperty data READ data DESIGNABLE false) + + Q_CLASSINFO("DefaultProperty", "data") + + public: + AbstractDeclarativeObject(QObject *parent = 0); + virtual ~AbstractDeclarativeObject(); + + virtual QObject* object() const = 0; + + protected: + virtual void dataAppend(QObject *); + virtual int dataCount() const; + virtual QObject *dataAt(int) const; + virtual void dataClear(); + + void connectAllSignals(QObject *sender, QObject *receiver, const QSet &blacklist = QSet()) const; + + private: + QDeclarativeListProperty data(); + + static void data_append(QDeclarativeListProperty *, QObject *); + static int data_count(QDeclarativeListProperty *); + static QObject *data_at(QDeclarativeListProperty *, int); + static void data_clear(QDeclarativeListProperty *); +}; + +#endif diff --git a/lib/declarativeaction.cpp b/lib/declarativeaction.cpp new file mode 100644 index 0000000..cc117ca --- /dev/null +++ b/lib/declarativeaction.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativeaction_p.h" + +DeclarativeAction::DeclarativeAction(QObject *parent) + : DeclarativeObjectProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeAction, QAction) diff --git a/lib/declarativeaction_p.h b/lib/declarativeaction_p.h new file mode 100644 index 0000000..d77c577 --- /dev/null +++ b/lib/declarativeaction_p.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEACTION_P_H +#define DECLARATIVEACTION_P_H + +#include "declarativeobjectproxy_p.h" + +#include + +class DeclarativeAction : public DeclarativeObjectProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeAction(QObject *parent = 0); +}; +Q_DECLARE_METATYPE(DeclarativeAction*) + +#endif diff --git a/lib/declarativeactionitem.cpp b/lib/declarativeactionitem.cpp new file mode 100644 index 0000000..70a8817 --- /dev/null +++ b/lib/declarativeactionitem.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativeactionitem_p.h" + +DeclarativeActionItem::DeclarativeActionItem(QObject *parent) + : DeclarativeObjectProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeActionItem, ActionItem) diff --git a/lib/declarativeactionitem_p.h b/lib/declarativeactionitem_p.h new file mode 100644 index 0000000..6bbee17 --- /dev/null +++ b/lib/declarativeactionitem_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEACTIONITEM_P_H +#define DECLARATIVEACTIONITEM_P_H + +#include "declarativeobjectproxy_p.h" + +#include "objectadaptors_p.h" + +class DeclarativeActionItem : public DeclarativeObjectProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeActionItem(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativeboxlayout.cpp b/lib/declarativeboxlayout.cpp new file mode 100644 index 0000000..7300c44 --- /dev/null +++ b/lib/declarativeboxlayout.cpp @@ -0,0 +1,94 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativeboxlayout_p.h" + +#include +#include + +class DeclarativeBoxLayoutAttached::Private +{ + public: + Private(QWidget *w, QLayout *l) : stretch(0), alignment(0), widget(w), layout(l) {} + + int stretch; + Qt::Alignment alignment; + + QPointer widget; + QPointer layout; + QPointer parentLayout; +}; + +DeclarativeBoxLayoutAttached::DeclarativeBoxLayoutAttached(QWidget *widget, QObject *parent) + : QObject(parent), d(new Private(widget, 0)) +{ +} + +DeclarativeBoxLayoutAttached::DeclarativeBoxLayoutAttached(QLayout *layout, QObject *parent) + : QObject(parent), d(new Private(0, layout)) +{ +} + +DeclarativeBoxLayoutAttached::~DeclarativeBoxLayoutAttached() +{ + delete d; +} + +void DeclarativeBoxLayoutAttached::setParentLayout(QBoxLayout *parentLayout) +{ + d->parentLayout = parentLayout; +} + +void DeclarativeBoxLayoutAttached::setStretch(int stretch) +{ + if (stretch == d->stretch) + return; + + d->stretch = stretch; + emit stretchChanged(stretch); +} + +int DeclarativeBoxLayoutAttached::stretch() const +{ + return d->stretch; +} + +void DeclarativeBoxLayoutAttached::setAlignment(Qt::Alignment alignment) +{ + if (alignment == d->alignment) + return; + + d->alignment = alignment; + emit alignmentChanged(alignment); + + if (d->parentLayout) { + if (d->widget) + d->parentLayout->setAlignment(d->widget, d->alignment); + + if (d->layout) + d->parentLayout->setAlignment(d->layout, d->alignment); + } +} + +Qt::Alignment DeclarativeBoxLayoutAttached::alignment() const +{ + return d->alignment; +} + diff --git a/lib/declarativeboxlayout_p.h b/lib/declarativeboxlayout_p.h new file mode 100644 index 0000000..9f14059 --- /dev/null +++ b/lib/declarativeboxlayout_p.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEBOXLAYOUT_P_H +#define DECLARATIVEBOXLAYOUT_P_H + +#include + +class DeclarativeBoxLayoutAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int stretch READ stretch WRITE setStretch NOTIFY stretchChanged) + Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) + + public: + DeclarativeBoxLayoutAttached(QWidget *widget, QObject *parent); + DeclarativeBoxLayoutAttached(QLayout *layout, QObject *parent); + ~DeclarativeBoxLayoutAttached(); + + void setParentLayout(QBoxLayout *parentLayout); + + void setStretch(int stretch); + int stretch() const; + + void setAlignment(Qt::Alignment alignment); + Qt::Alignment alignment() const; + + Q_SIGNALS: + void stretchChanged(int stretch); + void alignmentChanged(Qt::Alignment alignment); + + private: + class Private; + Private *const d; +}; + +#endif diff --git a/lib/declarativebuttongroup.cpp b/lib/declarativebuttongroup.cpp new file mode 100644 index 0000000..981f1db --- /dev/null +++ b/lib/declarativebuttongroup.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativebuttongroup_p.h" + +DeclarativeButtonGroup::DeclarativeButtonGroup(QObject *parent) + : DeclarativeObjectProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeButtonGroup, ButtonGroup) diff --git a/lib/declarativebuttongroup_p.h b/lib/declarativebuttongroup_p.h new file mode 100644 index 0000000..964c31d --- /dev/null +++ b/lib/declarativebuttongroup_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEBUTTONGROUP_P_H +#define DECLARATIVEBUTTONGROUP_P_H + +#include "declarativeobjectproxy_p.h" + +#include "objectadaptors_p.h" + +class DeclarativeButtonGroup : public DeclarativeObjectProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeButtonGroup(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativecalendarwidget.cpp b/lib/declarativecalendarwidget.cpp new file mode 100644 index 0000000..cad4d66 --- /dev/null +++ b/lib/declarativecalendarwidget.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativecalendarwidget_p.h" + +DeclarativeCalendarWidget::DeclarativeCalendarWidget(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeCalendarWidget, QCalendarWidget) diff --git a/lib/declarativecalendarwidget_p.h b/lib/declarativecalendarwidget_p.h new file mode 100644 index 0000000..4a40931 --- /dev/null +++ b/lib/declarativecalendarwidget_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVECALENDARWIDGET_P_H +#define DECLARATIVECALENDARWIDGET_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeCalendarWidget : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeCalendarWidget(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativecheckbox.cpp b/lib/declarativecheckbox.cpp new file mode 100644 index 0000000..663385b --- /dev/null +++ b/lib/declarativecheckbox.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativecheckbox_p.h" + +DeclarativeCheckBox::DeclarativeCheckBox(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeCheckBox, QCheckBox) diff --git a/lib/declarativecheckbox_p.h b/lib/declarativecheckbox_p.h new file mode 100644 index 0000000..3880354 --- /dev/null +++ b/lib/declarativecheckbox_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVECHECKBOX_P_H +#define DECLARATIVECHECKBOX_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeCheckBox : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeCheckBox(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativecolordialog.cpp b/lib/declarativecolordialog.cpp new file mode 100644 index 0000000..84a3bd4 --- /dev/null +++ b/lib/declarativecolordialog.cpp @@ -0,0 +1,112 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativecolordialog_p.h" + +class DeclarativeColorDialogAttached::Private +{ + public: + Private() : options(0) {} + + public: + QPointer dialogParent; + QString title; + QColorDialog::ColorDialogOptions options; +}; + +DeclarativeColorDialogAttached::DeclarativeColorDialogAttached(QObject *parent) + : QObject(parent), d(new Private) +{ +} + +DeclarativeColorDialogAttached::~DeclarativeColorDialogAttached() +{ + delete d; +} + +void DeclarativeColorDialogAttached::setDialogParent(QObject *parent) +{ + if (parent == d->dialogParent) + return; + + d->dialogParent = parent; + emit dialogParentChanged(parent); +} + +QObject *DeclarativeColorDialogAttached::dialogParent() const +{ + return d->dialogParent; +} + +void DeclarativeColorDialogAttached::setTitle(const QString &title) +{ + if (title == d->title) + return; + + d->title = title; + emit titleChanged(title); +} + +QString DeclarativeColorDialogAttached::title() const +{ + return d->title; +} + +QColor DeclarativeColorDialogAttached::getColor(const QColor &initialColor) +{ + QWidget *parent = bestParentWindow(d->dialogParent); + if (!d->title.isEmpty() || d->options != 0) + return QColorDialog::getColor(initialColor, parent, d->title, d->options); + else + return QColorDialog::getColor(initialColor, parent); +} + +QWidget *DeclarativeColorDialogAttached::bestParentWindow(QObject *parent) const +{ + if (!parent) + parent = this->parent(); + + // if parent is a Declarative Object, search the proxied hierarchy + AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); + if (declarativeObject) + parent = declarativeObject->object(); + + while (parent) { + QWidget *widget = qobject_cast(parent); + if (widget) + return widget->topLevelWidget(); + + parent = parent->parent(); + } + + return 0; +} + +DeclarativeColorDialog::DeclarativeColorDialog(QObject *parent) : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +DeclarativeColorDialogAttached *DeclarativeColorDialog::qmlAttachedProperties(QObject *parent) +{ + return new DeclarativeColorDialogAttached(parent); +} + +CUSTOM_METAOBJECT(DeclarativeColorDialog, QColorDialog) diff --git a/lib/declarativecolordialog_p.h b/lib/declarativecolordialog_p.h new file mode 100644 index 0000000..abdd429 --- /dev/null +++ b/lib/declarativecolordialog_p.h @@ -0,0 +1,70 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVECOLORDIALOG_P_H +#define DECLARATIVECOLORDIALOG_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeColorDialogAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QObject* parent READ dialogParent WRITE setDialogParent NOTIFY dialogParentChanged) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + // TODO option + + public: + DeclarativeColorDialogAttached(QObject *parent = 0); + ~DeclarativeColorDialogAttached(); + + void setDialogParent(QObject *parent); + QObject *dialogParent() const; + + void setTitle(const QString &title); + QString title() const; + + Q_INVOKABLE QColor getColor(const QColor &initialColor); + + Q_SIGNALS: + void dialogParentChanged(QObject *parent); + void titleChanged(const QString &title); + + private: + QWidget *bestParentWindow(QObject *parent) const; + + class Private; + Private *const d; +}; + +class DeclarativeColorDialog : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeColorDialog(QObject *parent = 0); + + static DeclarativeColorDialogAttached *qmlAttachedProperties(QObject *parent); +}; + +QML_DECLARE_TYPEINFO(DeclarativeColorDialog, QML_HAS_ATTACHED_PROPERTIES) + +#endif diff --git a/lib/declarativecolumnview.cpp b/lib/declarativecolumnview.cpp new file mode 100644 index 0000000..6d3e098 --- /dev/null +++ b/lib/declarativecolumnview.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativecolumnview_p.h" + +DeclarativeColumnView::DeclarativeColumnView(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeColumnView, ColumnView) diff --git a/lib/declarativecolumnview_p.h b/lib/declarativecolumnview_p.h new file mode 100644 index 0000000..4ecf16a --- /dev/null +++ b/lib/declarativecolumnview_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVECOLUMNVIEW_P_H +#define DECLARATIVECOLUMNVIEW_P_H + +#include "declarativewidgetproxy_p.h" + +#include "objectadaptors_p.h" + +class DeclarativeColumnView : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeColumnView(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativecommandlinkbutton.cpp b/lib/declarativecommandlinkbutton.cpp new file mode 100644 index 0000000..fb89b70 --- /dev/null +++ b/lib/declarativecommandlinkbutton.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativecommandlinkbutton_p.h" + +DeclarativeCommandLinkButton::DeclarativeCommandLinkButton(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeCommandLinkButton, QCommandLinkButton) diff --git a/lib/declarativecommandlinkbutton_p.h b/lib/declarativecommandlinkbutton_p.h new file mode 100644 index 0000000..817dda7 --- /dev/null +++ b/lib/declarativecommandlinkbutton_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVECOMMANDLINKBUTTON_P_H +#define DECLARATIVECOMMANDLINKBUTTON_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeCommandLinkButton : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeCommandLinkButton(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativedateedit.cpp b/lib/declarativedateedit.cpp new file mode 100644 index 0000000..5c05b07 --- /dev/null +++ b/lib/declarativedateedit.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativedateedit_p.h" + +DeclarativeDateEdit::DeclarativeDateEdit(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeDateEdit, QDateEdit) diff --git a/lib/declarativedateedit_p.h b/lib/declarativedateedit_p.h new file mode 100644 index 0000000..2e4ab62 --- /dev/null +++ b/lib/declarativedateedit_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEDATEEDIT_P_H +#define DECLARATIVEDATEEDIT_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeDateEdit : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeDateEdit(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativedatetimeedit.cpp b/lib/declarativedatetimeedit.cpp new file mode 100644 index 0000000..3df82a0 --- /dev/null +++ b/lib/declarativedatetimeedit.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativedatetimeedit_p.h" + +DeclarativeDateTimeEdit::DeclarativeDateTimeEdit(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeDateTimeEdit, QDateTimeEdit) diff --git a/lib/declarativedatetimeedit_p.h b/lib/declarativedatetimeedit_p.h new file mode 100644 index 0000000..0cf1b31 --- /dev/null +++ b/lib/declarativedatetimeedit_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEDATETIMEEDIT_P_H +#define DECLARATIVEDATETIMEEDIT_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeDateTimeEdit : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeDateTimeEdit(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativedial.cpp b/lib/declarativedial.cpp new file mode 100644 index 0000000..8b800cf --- /dev/null +++ b/lib/declarativedial.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativedial_p.h" + +DeclarativeDial::DeclarativeDial(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeDial, QDial) diff --git a/lib/declarativedial_p.h b/lib/declarativedial_p.h new file mode 100644 index 0000000..288f768 --- /dev/null +++ b/lib/declarativedial_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEDIAL_P_H +#define DECLARATIVEDIAL_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeDial : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeDial(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativedialog.cpp b/lib/declarativedialog.cpp new file mode 100644 index 0000000..baf8b71 --- /dev/null +++ b/lib/declarativedialog.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativedialog_p.h" + +DeclarativeDialog::DeclarativeDialog(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeDialog, QDialog) diff --git a/lib/declarativedialog_p.h b/lib/declarativedialog_p.h new file mode 100644 index 0000000..bd84e8c --- /dev/null +++ b/lib/declarativedialog_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEDIALOG_P_H +#define DECLARATIVEDIALOG_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeDialog : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeDialog(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativedialogbuttonbox.cpp b/lib/declarativedialogbuttonbox.cpp new file mode 100644 index 0000000..db6f033 --- /dev/null +++ b/lib/declarativedialogbuttonbox.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativedialogbuttonbox_p.h" + +DeclarativeDialogButtonBox::DeclarativeDialogButtonBox(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeDialogButtonBox, QDialogButtonBox) diff --git a/lib/declarativedialogbuttonbox_p.h b/lib/declarativedialogbuttonbox_p.h new file mode 100644 index 0000000..f110a07 --- /dev/null +++ b/lib/declarativedialogbuttonbox_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEDIALOGBUTTONBOX_P_H +#define DECLARATIVEDIALOGBUTTONBOX_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeDialogButtonBox : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeDialogButtonBox(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativedoublespinbox.cpp b/lib/declarativedoublespinbox.cpp new file mode 100644 index 0000000..be39057 --- /dev/null +++ b/lib/declarativedoublespinbox.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativedoublespinbox_p.h" + +DeclarativeDoubleSpinBox::DeclarativeDoubleSpinBox(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeDoubleSpinBox, QDoubleSpinBox) diff --git a/lib/declarativedoublespinbox_p.h b/lib/declarativedoublespinbox_p.h new file mode 100644 index 0000000..4aaae39 --- /dev/null +++ b/lib/declarativedoublespinbox_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEDOUBLESPINBOX_P_H +#define DECLARATIVEDOUBLESPINBOX_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeDoubleSpinBox : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeDoubleSpinBox(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativefiledialog.cpp b/lib/declarativefiledialog.cpp new file mode 100644 index 0000000..93c9a62 --- /dev/null +++ b/lib/declarativefiledialog.cpp @@ -0,0 +1,178 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativefiledialog_p.h" + +class DeclarativeFileDialogAttached::Private +{ + public: + QPointer dialogParent; + QString caption; + QString dir; + QStringList nameFilters; + QString selectedFilter; +}; + +DeclarativeFileDialogAttached::DeclarativeFileDialogAttached(QObject *parent) + : QObject(parent), d(new Private) +{ +} + +DeclarativeFileDialogAttached::~DeclarativeFileDialogAttached() +{ + delete d; +} + +void DeclarativeFileDialogAttached::setDialogParent(QObject *parent) +{ + if (parent == d->dialogParent) + return; + + d->dialogParent = parent; + emit dialogParentChanged(parent); +} + +QObject *DeclarativeFileDialogAttached::dialogParent() const +{ + return d->dialogParent; +} + +void DeclarativeFileDialogAttached::setCaption(const QString &caption) +{ + if (caption == d->caption) + return; + + d->caption = caption; + emit captionChanged(caption); +} + +QString DeclarativeFileDialogAttached::caption() const +{ + return d->caption; +} + +void DeclarativeFileDialogAttached::setDir(const QString &dir) +{ + if (dir == d->dir) + return; + + d->dir = dir; + emit dirChanged(dir); +} + +QString DeclarativeFileDialogAttached::dir() const +{ + return d->dir; +} + +void DeclarativeFileDialogAttached::setNameFilters(const QStringList &nameFilters) +{ + if (nameFilters == d->nameFilters) + return; + + d->nameFilters = nameFilters; + emit nameFiltersChanged(nameFilters); +} + +QStringList DeclarativeFileDialogAttached::nameFilters() const +{ + return d->nameFilters; +} + +QString DeclarativeFileDialogAttached::selectedFilter() const +{ + return d->selectedFilter; +} + +QString DeclarativeFileDialogAttached::getExistingDirectory() +{ + return QFileDialog::getExistingDirectory(bestParentWindow(d->dialogParent), d->caption, d->dir, QFileDialog::ShowDirsOnly); +} + +QString DeclarativeFileDialogAttached::getOpenFileName() +{ + QString selectedFilter; + const QString retVal = QFileDialog::getOpenFileName(bestParentWindow(d->dialogParent), d->caption, d->dir, + d->nameFilters.join(";;"), &selectedFilter, 0); + setSelectedFilter(selectedFilter); + return retVal; +} + +QStringList DeclarativeFileDialogAttached::getOpenFileNames() +{ + QString selectedFilter; + const QStringList retVal = QFileDialog::getOpenFileNames(bestParentWindow(d->dialogParent), d->caption, d->dir, + d->nameFilters.join(";;"), &selectedFilter, 0); + setSelectedFilter(selectedFilter); + return retVal; +} + +QString DeclarativeFileDialogAttached::getSaveFileName() +{ + QString selectedFilter; + const QString retVal = QFileDialog::getSaveFileName(bestParentWindow(d->dialogParent), d->caption, d->dir, + d->nameFilters.join(";;"), &selectedFilter, 0); + setSelectedFilter(selectedFilter); + return retVal; +} + +QWidget *DeclarativeFileDialogAttached::bestParentWindow(QObject *parent) const +{ + if (!parent) + parent = this->parent(); + + // if parent is a Declarative Object, search the proxied hierarchy + AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); + if (declarativeObject) + parent = declarativeObject->object(); + + while (parent) { + QWidget *widget = qobject_cast(parent); + if (widget) + return widget->topLevelWidget(); + + parent = parent->parent(); + } + + return 0; +} + +void DeclarativeFileDialogAttached::setSelectedFilter(const QString &filter) +{ + if (filter == d->selectedFilter) + return; + + d->selectedFilter = filter; + emit selectedFilterChanged(filter); +} + + +DeclarativeFileDialog::DeclarativeFileDialog(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +DeclarativeFileDialogAttached *DeclarativeFileDialog::qmlAttachedProperties(QObject *parent) +{ + return new DeclarativeFileDialogAttached(parent); +} + +CUSTOM_METAOBJECT(DeclarativeFileDialog, FileDialog) diff --git a/lib/declarativefiledialog_p.h b/lib/declarativefiledialog_p.h new file mode 100644 index 0000000..69fa604 --- /dev/null +++ b/lib/declarativefiledialog_p.h @@ -0,0 +1,91 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEFILEDIALOG_P_H +#define DECLARATIVEFILEDIALOG_P_H + +#include "declarativewidgetproxy_p.h" + +#include "objectadaptors_p.h" + +class DeclarativeFileDialogAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QObject* parent READ dialogParent WRITE setDialogParent NOTIFY dialogParentChanged) + Q_PROPERTY(QString caption READ caption WRITE setCaption NOTIFY captionChanged) + Q_PROPERTY(QString dir READ dir WRITE setDir NOTIFY dirChanged) + Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY nameFiltersChanged) + // TODO dialog option + Q_PROPERTY(QString selectedFilter READ selectedFilter NOTIFY selectedFilterChanged) + + public: + DeclarativeFileDialogAttached(QObject *parent = 0); + ~DeclarativeFileDialogAttached(); + + void setDialogParent(QObject *parent); + QObject *dialogParent() const; + + void setCaption(const QString &caption); + QString caption() const; + + void setDir(const QString &dir); + QString dir() const; + + void setNameFilters(const QStringList &nameFilters); + QStringList nameFilters() const; + + QString selectedFilter() const; + + Q_INVOKABLE QString getExistingDirectory(); + + Q_INVOKABLE QString getOpenFileName(); + + Q_INVOKABLE QStringList getOpenFileNames(); + + Q_INVOKABLE QString getSaveFileName(); + + Q_SIGNALS: + void dialogParentChanged(QObject *parent); + void captionChanged(const QString &caption); + void dirChanged(const QString &dir); + void nameFiltersChanged(const QStringList &filters); + void selectedFilterChanged(const QString &filter); + + private: + QWidget *bestParentWindow(QObject *parent) const; + void setSelectedFilter(const QString &filter); + + class Private; + Private *const d; +}; + +class DeclarativeFileDialog : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeFileDialog(QObject *parent = 0); + + static DeclarativeFileDialogAttached *qmlAttachedProperties(QObject *parent); +}; + +QML_DECLARE_TYPEINFO(DeclarativeFileDialog, QML_HAS_ATTACHED_PROPERTIES) + +#endif diff --git a/lib/declarativefontdialog.cpp b/lib/declarativefontdialog.cpp new file mode 100644 index 0000000..c7e433d --- /dev/null +++ b/lib/declarativefontdialog.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativefontdialog_p.h" + +DeclarativeFontDialog::DeclarativeFontDialog(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeFontDialog, QFontDialog) diff --git a/lib/declarativefontdialog_p.h b/lib/declarativefontdialog_p.h new file mode 100644 index 0000000..354e6e1 --- /dev/null +++ b/lib/declarativefontdialog_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEFONTDIALOG_P_H +#define DECLARATIVEFONTDIALOG_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeFontDialog : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeFontDialog(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativeformlayout.cpp b/lib/declarativeformlayout.cpp new file mode 100644 index 0000000..02c31d7 --- /dev/null +++ b/lib/declarativeformlayout.cpp @@ -0,0 +1,95 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativeformlayout_p.h" + +class DeclarativeFormLayoutAttached::Private +{ + public: + QString label; +}; + +DeclarativeFormLayoutAttached::DeclarativeFormLayoutAttached(QObject *parent) + : QObject(parent), d(new Private) +{ +} + +DeclarativeFormLayoutAttached::~DeclarativeFormLayoutAttached() +{ + delete d; +} + +void DeclarativeFormLayoutAttached::setLabel(const QString &label) +{ + if (label == d->label) + return; + + d->label = label; + emit labelChanged(label); +} + +QString DeclarativeFormLayoutAttached::label() const +{ + return d->label; +} + +// DeclarativeFormLayout +DeclarativeFormLayout::DeclarativeFormLayout(QObject *parent) : DeclarativeLayoutProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +DeclarativeFormLayoutAttached *DeclarativeFormLayout::qmlAttachedProperties(QObject *parent) +{ + return new DeclarativeFormLayoutAttached(parent); +} + +void DeclarativeFormLayout::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); + DeclarativeFormLayoutAttached *properties = qobject_cast(attachedProperties); + if (properties) { + if (!properties->label().isEmpty()) { + m_proxiedObject->addRow(properties->label(), widget); + m_children.append(declarativeObject); + return; + } + } + + m_proxiedObject->addRow(widget); + m_children.append(declarativeObject); +} + +void DeclarativeFormLayout::addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) +{ + QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); + DeclarativeFormLayoutAttached *properties = qobject_cast(attachedProperties); + if (properties) { + if (!properties->label().isEmpty()) { + m_proxiedObject->addRow(properties->label(), layout); + m_children.append(declarativeObject); + return; + } + } + m_proxiedObject->addRow(layout); + m_children.append(declarativeObject); +} + +CUSTOM_METAOBJECT(DeclarativeFormLayout, QFormLayout) diff --git a/lib/declarativeformlayout_p.h b/lib/declarativeformlayout_p.h new file mode 100644 index 0000000..1cbe86f --- /dev/null +++ b/lib/declarativeformlayout_p.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEFORMLAYOUT_P_H +#define DECLARATIVEFORMLAYOUT_P_H + +#include "declarativelayoutproxy_p.h" + +#include + +class DeclarativeFormLayoutAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) + + public: + DeclarativeFormLayoutAttached(QObject *parent); + ~DeclarativeFormLayoutAttached(); + + void setLabel(const QString &label); + QString label() const; + + Q_SIGNALS: + void labelChanged(const QString &label); + + private: + class Private; + Private *const d; +}; + +class DeclarativeFormLayout : public DeclarativeLayoutProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeFormLayout(QObject *parent = 0); + + static DeclarativeFormLayoutAttached *qmlAttachedProperties(QObject *parent); + + protected: + void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); +}; + +QML_DECLARE_TYPEINFO(DeclarativeFormLayout, QML_HAS_ATTACHED_PROPERTIES) + +#endif diff --git a/lib/declarativeframe.cpp b/lib/declarativeframe.cpp new file mode 100644 index 0000000..8b8418e --- /dev/null +++ b/lib/declarativeframe.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativeframe_p.h" + +DeclarativeFrame::DeclarativeFrame(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeFrame, QFrame) diff --git a/lib/declarativeframe_p.h b/lib/declarativeframe_p.h new file mode 100644 index 0000000..c96252c --- /dev/null +++ b/lib/declarativeframe_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEFRAME_P_H +#define DECLARATIVEFRAME_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeFrame : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeFrame(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativegridlayout.cpp b/lib/declarativegridlayout.cpp new file mode 100644 index 0000000..dab5a44 --- /dev/null +++ b/lib/declarativegridlayout.cpp @@ -0,0 +1,212 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativegridlayout_p.h" + +class DeclarativeGridLayoutAttached::Private +{ + public: + Private(QWidget *w, QLayout *l) + : row(0), column(0), rowSpan(1), columnSpan(1), alignment(0), + widget(w), layout(l) + {} + + int row; + int column; + int rowSpan; + int columnSpan; + Qt::Alignment alignment; + + QPointer widget; + QPointer layout; + QPointer parentLayout; +}; + +DeclarativeGridLayoutAttached::DeclarativeGridLayoutAttached(QWidget *widget, QObject *parent) + : QObject(parent), d(new Private(widget, 0)) +{ +} + +DeclarativeGridLayoutAttached::DeclarativeGridLayoutAttached(QLayout *layout, QObject *parent) + : QObject(parent), d(new Private(0, layout)) +{ +} + +DeclarativeGridLayoutAttached::~DeclarativeGridLayoutAttached() +{ + delete d; +} + +void DeclarativeGridLayoutAttached::setParentLayout(QGridLayout *parentLayout) +{ + d->parentLayout = parentLayout; +} + +void DeclarativeGridLayoutAttached::setRow(int row) +{ + if (row == d->row) + return; + + d->row = row; + emit rowChanged(row); +} + +int DeclarativeGridLayoutAttached::row() const +{ + return d->row; +} + +void DeclarativeGridLayoutAttached::setColumn(int column) +{ + if (column == d->column) + return; + + d->column = column; + emit columnChanged(column); +} + +int DeclarativeGridLayoutAttached::column() const +{ + return d->column; +} + +void DeclarativeGridLayoutAttached::setRowSpan(int rowSpan) +{ + if (rowSpan == d->rowSpan) + return; + + d->rowSpan = rowSpan; + emit rowSpanChanged(rowSpan); +} + +int DeclarativeGridLayoutAttached::rowSpan() const +{ + return d->rowSpan; +} + +void DeclarativeGridLayoutAttached::setColumnSpan(int columnSpan) +{ + if (columnSpan == d->columnSpan) + return; + + d->columnSpan = columnSpan; + emit columnSpanChanged(columnSpan); +} + +int DeclarativeGridLayoutAttached::columnSpan() const +{ + return d->columnSpan; +} + +void DeclarativeGridLayoutAttached::setAlignment(Qt::Alignment alignment) +{ + if (alignment == d->alignment) + return; + + d->alignment = alignment; + emit alignmentChanged(alignment); + + if (d->parentLayout) { + if (d->widget) + d->parentLayout->setAlignment(d->widget, d->alignment); + + if (d->layout) + d->parentLayout->setAlignment(d->layout, d->alignment); + } +} + +Qt::Alignment DeclarativeGridLayoutAttached::alignment() const +{ + return d->alignment; +} + +// DeclarativeGridLayout +DeclarativeGridLayout::DeclarativeGridLayout(QObject *parent) : DeclarativeLayoutProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +DeclarativeGridLayoutAttached *DeclarativeGridLayout::qmlAttachedProperties(QObject *parent) +{ + AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); + if (declarativeObject) { + QWidget *widget = qobject_cast(declarativeObject->object()); + if (widget) + return new DeclarativeGridLayoutAttached(widget, parent); + + QLayout *layout = qobject_cast(declarativeObject->object()); + if (layout) + return new DeclarativeGridLayoutAttached(layout, parent); + } + + qmlInfo(parent) << "Can only attach GridLayout to widgets and layouts"; + return 0; +} + +void DeclarativeGridLayout::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + int row = 0; + int column = 0; + int rowSpan = 1; + int columnSpan = 1; + Qt::Alignment alignment = 0; + + QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); + DeclarativeGridLayoutAttached *properties = qobject_cast(attachedProperties); + if (properties) { + row = properties->row(); + column = properties->column(); + rowSpan = properties->rowSpan(); + columnSpan = properties->columnSpan(); + alignment = properties->alignment(); + + properties->setParentLayout(m_proxiedObject); + } + + m_proxiedObject->addWidget(widget, row, column, rowSpan, columnSpan, alignment); + m_children.append(declarativeObject); +} + +void DeclarativeGridLayout::addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) +{ + int row = 0; + int column = 0; + int rowSpan = 1; + int columnSpan = 1; + Qt::Alignment alignment = 0; + + QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); + DeclarativeGridLayoutAttached *properties = qobject_cast(attachedProperties); + if (properties) { + row = properties->row(); + column = properties->column(); + rowSpan = properties->rowSpan(); + columnSpan = properties->columnSpan(); + alignment = properties->alignment(); + + properties->setParentLayout(m_proxiedObject); + } + + m_proxiedObject->addLayout(layout, row, column, rowSpan, columnSpan, alignment); + m_children.append(declarativeObject); +} + +CUSTOM_METAOBJECT(DeclarativeGridLayout, QGridLayout) + diff --git a/lib/declarativegridlayout_p.h b/lib/declarativegridlayout_p.h new file mode 100644 index 0000000..89e3fec --- /dev/null +++ b/lib/declarativegridlayout_p.h @@ -0,0 +1,88 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEGRIDLAYOUT_P_H +#define DECLARATIVEGRIDLAYOUT_P_H + +#include "declarativelayoutproxy_p.h" + +#include + +class DeclarativeGridLayoutAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int row READ row WRITE setRow NOTIFY rowChanged) + Q_PROPERTY(int column READ column WRITE setColumn NOTIFY columnChanged) + Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan NOTIFY rowSpanChanged) + Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan NOTIFY columnSpanChanged) + Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) + + public: + DeclarativeGridLayoutAttached(QWidget *widget, QObject *parent); + DeclarativeGridLayoutAttached(QLayout *layout, QObject *parent); + ~DeclarativeGridLayoutAttached(); + + void setParentLayout(QGridLayout *parentLayout); + + void setRow(int row); + int row() const; + + void setColumn(int column); + int column() const; + + void setRowSpan(int rowSpan); + int rowSpan() const; + + void setColumnSpan(int columnSpan); + int columnSpan() const; + + void setAlignment(Qt::Alignment alignment); + Qt::Alignment alignment() const; + + Q_SIGNALS: + void rowChanged(int row); + void columnChanged(int column); + void rowSpanChanged(int rowSpan); + void columnSpanChanged(int columnSpan); + void alignmentChanged(Qt::Alignment alignment); + + private: + class Private; + Private *const d; +}; + +class DeclarativeGridLayout : public DeclarativeLayoutProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeGridLayout(QObject *parent = 0); + + static DeclarativeGridLayoutAttached *qmlAttachedProperties(QObject *parent); + + protected: + void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); +}; + +QML_DECLARE_TYPEINFO(DeclarativeGridLayout, QML_HAS_ATTACHED_PROPERTIES) + +#endif diff --git a/lib/declarativegroupbox.cpp b/lib/declarativegroupbox.cpp new file mode 100644 index 0000000..959da9c --- /dev/null +++ b/lib/declarativegroupbox.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativegroupbox_p.h" + +DeclarativeGroupBox::DeclarativeGroupBox(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeGroupBox, QGroupBox) diff --git a/lib/declarativegroupbox_p.h b/lib/declarativegroupbox_p.h new file mode 100644 index 0000000..e0316d0 --- /dev/null +++ b/lib/declarativegroupbox_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEGROUPBOX_P_H +#define DECLARATIVEGROUPBOX_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeGroupBox : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeGroupBox(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativehboxlayout.cpp b/lib/declarativehboxlayout.cpp new file mode 100644 index 0000000..d177152 --- /dev/null +++ b/lib/declarativehboxlayout.cpp @@ -0,0 +1,83 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativehboxlayout_p.h" + +DeclarativeHBoxLayout::DeclarativeHBoxLayout(QObject *parent) + : DeclarativeLayoutProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +DeclarativeBoxLayoutAttached *DeclarativeHBoxLayout::qmlAttachedProperties(QObject *parent) +{ + AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); + if (declarativeObject) { + QWidget *widget = qobject_cast(declarativeObject->object()); + if (widget) + return new DeclarativeBoxLayoutAttached(widget, parent); + + QLayout *layout = qobject_cast(declarativeObject->object()); + if (layout) + return new DeclarativeBoxLayoutAttached(layout, parent); + } + + qmlInfo(parent) << "Can only attach HBoxLayout to widgets and layouts"; + return 0; +} + +void DeclarativeHBoxLayout::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + int stretch = 0; + Qt::Alignment alignment = 0; + + QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); + DeclarativeBoxLayoutAttached *properties = qobject_cast(attachedProperties); + if (properties) { + stretch = properties->stretch(); + alignment = properties->alignment(); + + properties->setParentLayout(m_proxiedObject); + } + + m_proxiedObject->addWidget(widget, stretch, alignment); + m_children.append(declarativeObject); +} + +void DeclarativeHBoxLayout::addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) +{ + int stretch = 0; + Qt::Alignment alignment = 0; + + QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); + DeclarativeBoxLayoutAttached *properties = qobject_cast(attachedProperties); + if (properties) { + stretch = properties->stretch(); + alignment = properties->alignment(); + + properties->setParentLayout(m_proxiedObject); + } + + m_proxiedObject->addLayout(layout, stretch); + m_proxiedObject->setAlignment(layout, alignment); + m_children.append(declarativeObject); +} + +CUSTOM_METAOBJECT(DeclarativeHBoxLayout, QHBoxLayout) diff --git a/lib/declarativehboxlayout_p.h b/lib/declarativehboxlayout_p.h new file mode 100644 index 0000000..f0bb378 --- /dev/null +++ b/lib/declarativehboxlayout_p.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEHBOXLAYOUT_P_H +#define DECLARATIVEHBOXLAYOUT_P_H + +#include "declarativeboxlayout_p.h" +#include "declarativelayoutproxy_p.h" + +#include + +class DeclarativeHBoxLayout : public DeclarativeLayoutProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeHBoxLayout(QObject *parent = 0); + + static DeclarativeBoxLayoutAttached *qmlAttachedProperties(QObject *parent); + + protected: + void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); +}; + +QML_DECLARE_TYPEINFO(DeclarativeHBoxLayout, QML_HAS_ATTACHED_PROPERTIES) + +#endif diff --git a/lib/declarativeinputdialog.cpp b/lib/declarativeinputdialog.cpp new file mode 100644 index 0000000..d23aacd --- /dev/null +++ b/lib/declarativeinputdialog.cpp @@ -0,0 +1,324 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativeinputdialog_p.h" + +class DeclarativeInputDialogAttached::Private +{ + public: + Private() : dialogAccepted(false), + value(0), min(-2147483647), max(2147483647), decimals(1), step(1), + currentItem(0), itemsEditable(true), + echoMode(QLineEdit::Normal) + {} + + public: + QPointer dialogParent; + QString title; + QString label; + bool dialogAccepted; + + QVariant value; + QVariant min; + QVariant max; + int decimals; + int step; + + int currentItem; + bool itemsEditable; + + QLineEdit::EchoMode echoMode; + QString text; +}; + +DeclarativeInputDialogAttached::DeclarativeInputDialogAttached(QObject *parent) + : QObject(parent), d(new Private) +{ +} + +DeclarativeInputDialogAttached::~DeclarativeInputDialogAttached() +{ + delete d; +} + +void DeclarativeInputDialogAttached::setDialogParent(QObject *parent) +{ + if (parent == d->dialogParent) + return; + + d->dialogParent = parent; + emit dialogParentChanged(parent); +} + +QObject *DeclarativeInputDialogAttached::dialogParent() const +{ + return d->dialogParent; +} + +void DeclarativeInputDialogAttached::setTitle(const QString &title) +{ + if (title == d->title) + return; + + d->title = title; + emit titleChanged(title); +} + +QString DeclarativeInputDialogAttached::title() const +{ + return d->title; +} + +void DeclarativeInputDialogAttached::setLabel(const QString &label) +{ + if (label == d->label) + return; + + d->label = label; + emit labelChanged(label); +} + +QString DeclarativeInputDialogAttached::label() const +{ + return d->label; +} + +bool DeclarativeInputDialogAttached::dialogAccepted() const +{ + return d->dialogAccepted; +} + +void DeclarativeInputDialogAttached::setValue(const QVariant &value) +{ + if (value == d->value) + return; + + d->value = value; + emit valueChanged(value); +} + +QVariant DeclarativeInputDialogAttached::value() const +{ + return d->value; +} + +void DeclarativeInputDialogAttached::setMin(const QVariant &min) +{ + if (min == d->min) + return; + + d->min = min; + emit minChanged(min); +} + +QVariant DeclarativeInputDialogAttached::min() const +{ + return d->min; +} + +void DeclarativeInputDialogAttached::setMax(const QVariant &max) +{ + if (max == d->max) + return; + + d->max = max; + emit maxChanged(max); +} + +QVariant DeclarativeInputDialogAttached::max() const +{ + return d->max; +} + +void DeclarativeInputDialogAttached::setDecimals(int decimals) +{ + if (decimals == d->decimals) + return; + + d->decimals = decimals; + emit decimalsChanged(decimals); +} + +int DeclarativeInputDialogAttached::decimals() const +{ + return d->decimals; +} + +void DeclarativeInputDialogAttached::setStep(int step) +{ + if (step == d->step) + return; + + d->step = step; + emit stepChanged(step); +} + +int DeclarativeInputDialogAttached::step() const +{ + return d->step; +} + +void DeclarativeInputDialogAttached::setCurrentItem(int current) +{ + if (current == d->currentItem) + return; + + d->currentItem = current; + emit currentItemChanged(current); +} + +int DeclarativeInputDialogAttached::currentItem() const +{ + return d->currentItem; +} + +void DeclarativeInputDialogAttached::setItemsEditable(bool editable) +{ + if (editable == d->itemsEditable) + return; + + d->itemsEditable = editable; + emit itemsEditableChanged(editable); +} + +bool DeclarativeInputDialogAttached::itemsEditable() const +{ + return d->itemsEditable; +} + +void DeclarativeInputDialogAttached::setEchoMode(QLineEdit::EchoMode echoMode) +{ + if (echoMode == d->echoMode) + return; + + d->echoMode = echoMode; + emit echoModeChanged(echoMode); +} + +QLineEdit::EchoMode DeclarativeInputDialogAttached::echoMode() const +{ + return d->echoMode; +} + +void DeclarativeInputDialogAttached::setText(const QString &text) +{ + if (text == d->text) + return; + + d->text = text; + emit textChanged(text); +} + +QString DeclarativeInputDialogAttached::text() const +{ + return d->text; +} + +double DeclarativeInputDialogAttached::getDouble() +{ + QWidget *parent = bestParentWindow(d->dialogParent); + bool ok = false; + const double value = d->value.canConvert() ? d->value.value() : 0.0; + const double min = d->min.canConvert() ? d->min.value() : -2147483647; + const double max = d->max.canConvert() ? d->max.value() : 2147483647; + + const double retVal = QInputDialog::getDouble(parent, d->title, d->label, value, min, max, d->decimals, &ok); + + setDialogAccepted(ok); + return retVal; +} + +int DeclarativeInputDialogAttached::getInt() +{ + QWidget *parent = bestParentWindow(d->dialogParent); + bool ok = false; + const int value = d->value.canConvert() ? d->value.value() : 0; + const int min = d->min.canConvert() ? d->min.value() : -2147483647; + const int max = d->max.canConvert() ? d->max.value() : 2147483647; + + const int retVal = QInputDialog::getInt(parent, d->title, d->label, value, min, max, d->step, &ok); + + setDialogAccepted(ok); + return retVal; +} + +QString DeclarativeInputDialogAttached::getItem(const QStringList &items) +{ + QWidget *parent = bestParentWindow(d->dialogParent); + bool ok = false; + + const QString retVal = QInputDialog::getItem(parent, d->title, d->label, items, d->currentItem, d->itemsEditable, &ok); + + setDialogAccepted(ok); + return retVal; +} + +QString DeclarativeInputDialogAttached::getText() +{ + QWidget *parent = bestParentWindow(d->dialogParent); + bool ok = false; + + const QString retVal = QInputDialog::getText(parent, d->title, d->label, d->echoMode, d->text, &ok); + + setDialogAccepted(ok); + return retVal; +} + +void DeclarativeInputDialogAttached::setDialogAccepted(bool accepted) +{ + if (accepted == d->dialogAccepted) + return; + + d->dialogAccepted = accepted; + emit dialogAcceptedChanged(accepted); +} + +QWidget *DeclarativeInputDialogAttached::bestParentWindow(QObject *parent) const +{ + if (!parent) + parent = this->parent(); + + // if parent is a Declarative Object, search the proxied hierarchy + AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); + if (declarativeObject) + parent = declarativeObject->object(); + + while (parent) { + QWidget *widget = qobject_cast(parent); + if (widget) + return widget->topLevelWidget(); + + parent = parent->parent(); + } + + return 0; +} + +DeclarativeInputDialog::DeclarativeInputDialog(QObject *parent) : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +DeclarativeInputDialogAttached *DeclarativeInputDialog::qmlAttachedProperties(QObject *parent) +{ + return new DeclarativeInputDialogAttached(parent); +} + +CUSTOM_METAOBJECT(DeclarativeInputDialog, InputDialog) diff --git a/lib/declarativeinputdialog_p.h b/lib/declarativeinputdialog_p.h new file mode 100644 index 0000000..d2705d4 --- /dev/null +++ b/lib/declarativeinputdialog_p.h @@ -0,0 +1,136 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEINPUTDIALOG_P_H +#define DECLARATIVEINPUTDIALOG_P_H + +#include "declarativewidgetproxy_p.h" + +#include "objectadaptors_p.h" + +class DeclarativeInputDialogAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QObject* parent READ dialogParent WRITE setDialogParent NOTIFY dialogParentChanged) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) + Q_PROPERTY(bool ok READ dialogAccepted NOTIFY dialogAcceptedChanged) + + Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) + Q_PROPERTY(QVariant min READ min WRITE setMin NOTIFY minChanged) + Q_PROPERTY(QVariant max READ max WRITE setMax NOTIFY maxChanged) + Q_PROPERTY(int decimals READ decimals WRITE setDecimals NOTIFY decimalsChanged) + Q_PROPERTY(int step READ step WRITE setStep NOTIFY stepChanged) + + Q_PROPERTY(int current READ currentItem WRITE setCurrentItem NOTIFY currentItemChanged) + Q_PROPERTY(bool editable READ itemsEditable WRITE setItemsEditable NOTIFY itemsEditableChanged) + + Q_PROPERTY(QLineEdit::EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged) + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) + + public: + DeclarativeInputDialogAttached(QObject *parent = 0); + ~DeclarativeInputDialogAttached(); + + void setDialogParent(QObject *parent); + QObject *dialogParent() const; + + void setTitle(const QString &title); + QString title() const; + + void setLabel(const QString &label); + QString label() const; + + bool dialogAccepted() const; + + void setValue(const QVariant &value); + QVariant value() const; + + void setMin(const QVariant &min); + QVariant min() const; + + void setMax(const QVariant &max); + QVariant max() const; + + void setDecimals(int decimals); + int decimals() const; + + void setStep(int step); + int step() const; + + void setCurrentItem(int current); + int currentItem() const; + + void setItemsEditable(bool editable); + bool itemsEditable() const; + + void setEchoMode(QLineEdit::EchoMode echoMode); + QLineEdit::EchoMode echoMode() const; + + void setText(const QString &text); + QString text() const; + + Q_INVOKABLE double getDouble(); + + Q_INVOKABLE int getInt(); + + Q_INVOKABLE QString getItem(const QStringList &items); + + Q_INVOKABLE QString getText(); + + Q_SIGNALS: + void dialogParentChanged(QObject *parent); + void titleChanged(const QString &title); + void labelChanged(const QString &label); + void dialogAcceptedChanged(bool accepted); + + void valueChanged(const QVariant &value); + void minChanged(const QVariant &min); + void maxChanged(const QVariant &max); + void decimalsChanged(int decimals); + void stepChanged(int step); + + void currentItemChanged(int current); + void itemsEditableChanged(bool editable); + + void echoModeChanged(QLineEdit::EchoMode echoMode); + void textChanged(const QString &text); + + private: + void setDialogAccepted(bool accepted); + QWidget *bestParentWindow(QObject *parent) const; + + class Private; + Private *const d; +}; + +class DeclarativeInputDialog : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeInputDialog(QObject *parent = 0); + + static DeclarativeInputDialogAttached *qmlAttachedProperties(QObject *parent); +}; + +QML_DECLARE_TYPEINFO(DeclarativeInputDialog, QML_HAS_ATTACHED_PROPERTIES) + +#endif diff --git a/lib/declarativelabel.cpp b/lib/declarativelabel.cpp new file mode 100644 index 0000000..fc94f36 --- /dev/null +++ b/lib/declarativelabel.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativelabel_p.h" + +DeclarativeLabel::DeclarativeLabel(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeLabel, QLabel) diff --git a/lib/declarativelabel_p.h b/lib/declarativelabel_p.h new file mode 100644 index 0000000..7630b5d --- /dev/null +++ b/lib/declarativelabel_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVELABEL_P_H +#define DECLARATIVELABEL_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeLabel : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeLabel(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativelayoutproxy_p.h b/lib/declarativelayoutproxy_p.h new file mode 100644 index 0000000..a3fcbd4 --- /dev/null +++ b/lib/declarativelayoutproxy_p.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVELAYOUTPROXY_P_H +#define DECLARATIVELAYOUTPROXY_P_H + +#include "declarativeobjectproxy_p.h" + +#include +#include + +template +class DeclarativeLayoutProxy : public DeclarativeObjectProxy +{ + public: + DeclarativeLayoutProxy(QObject *parent = 0) : DeclarativeObjectProxy(parent) {} + + protected: + virtual void dataAppend(QObject *object) + { + AbstractDeclarativeObject *declarativeObject = dynamic_cast(object); + if (declarativeObject) { + QWidget *widget = qobject_cast(declarativeObject->object()); + if (widget) { + addWidget(widget, declarativeObject); + return; + } + + QLayout *layout = qobject_cast(declarativeObject->object()); + if (layout) { + addLayout(layout, declarativeObject); + return; + } + } + + DeclarativeObjectProxy::dataAppend(object); + } + + virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) + { + DeclarativeObjectProxy::m_children.append(declarativeObject); + DeclarativeObjectProxy::m_proxiedObject->addWidget(widget); + } + + virtual void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) = 0; +}; + +#endif diff --git a/lib/declarativelcdnumber.cpp b/lib/declarativelcdnumber.cpp new file mode 100644 index 0000000..4c8d30b --- /dev/null +++ b/lib/declarativelcdnumber.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativelcdnumber_p.h" + +DeclarativeLCDNumber::DeclarativeLCDNumber(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeLCDNumber, QLCDNumber) diff --git a/lib/declarativelcdnumber_p.h b/lib/declarativelcdnumber_p.h new file mode 100644 index 0000000..f8518a7 --- /dev/null +++ b/lib/declarativelcdnumber_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVELCDNUMBER_P_H +#define DECLARATIVELCDNUMBER_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeLCDNumber : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeLCDNumber(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativelineedit.cpp b/lib/declarativelineedit.cpp new file mode 100644 index 0000000..cd0b2d9 --- /dev/null +++ b/lib/declarativelineedit.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativelineedit_p.h" + +DeclarativeLineEdit::DeclarativeLineEdit(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeLineEdit, QLineEdit) diff --git a/lib/declarativelineedit_p.h b/lib/declarativelineedit_p.h new file mode 100644 index 0000000..d308452 --- /dev/null +++ b/lib/declarativelineedit_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVELINEEDIT_P_H +#define DECLARATIVELINEEDIT_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeLineEdit : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeLineEdit(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativelistview.cpp b/lib/declarativelistview.cpp new file mode 100644 index 0000000..4362b4e --- /dev/null +++ b/lib/declarativelistview.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativelistview_p.h" + +DeclarativeListView::DeclarativeListView(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeListView, ListView) diff --git a/lib/declarativelistview_p.h b/lib/declarativelistview_p.h new file mode 100644 index 0000000..9c236c8 --- /dev/null +++ b/lib/declarativelistview_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVELISTVIEW_P_H +#define DECLARATIVELISTVIEW_P_H + +#include "declarativewidgetproxy_p.h" + +#include "objectadaptors_p.h" + +class DeclarativeListView : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeListView(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativemainwindow.cpp b/lib/declarativemainwindow.cpp new file mode 100644 index 0000000..b3b0fa5 --- /dev/null +++ b/lib/declarativemainwindow.cpp @@ -0,0 +1,68 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativemainwindow_p.h" + +#include +#include +#include + +DeclarativeMainWindow::DeclarativeMainWindow(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +void DeclarativeMainWindow::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + QMenuBar *menuBar = qobject_cast(widget); + QToolBar *toolBar = qobject_cast(widget); + QStatusBar *statusBar = qobject_cast(widget); + QDialog *dialog = qobject_cast(widget); + + if (menuBar) { + m_proxiedObject->setMenuBar(menuBar); + } else if (toolBar) { + m_proxiedObject->addToolBar(toolBar); + } else if (statusBar) { + m_proxiedObject->setStatusBar(statusBar); + } else if (dialog) { + // We allow to place dialogs on the mainwindow + dialog->setParent(m_proxiedObject, dialog->windowFlags()); + } else if (widget) { + if (m_proxiedObject->centralWidget()) { + qmlInfo(declarativeObject) << "The QMainWindow contains a central widget already"; + return; + } + + m_proxiedObject->setCentralWidget(widget); + } + + m_children.append(declarativeObject); +} + +void DeclarativeMainWindow::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) +{ + Q_UNUSED(layout); + Q_UNUSED(declarativeObject); + qmlInfo(this) << "Can not set a QLayout to a QMainWindow"; +} + +CUSTOM_METAOBJECT(DeclarativeMainWindow, QMainWindow) diff --git a/lib/declarativemainwindow_p.h b/lib/declarativemainwindow_p.h new file mode 100644 index 0000000..c51af70 --- /dev/null +++ b/lib/declarativemainwindow_p.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEMAINWINDOW_P_H +#define DECLARATIVEMAINWINDOW_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeMainWindow : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeMainWindow(QObject *parent = 0); + + protected: + virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); +}; + +#endif diff --git a/lib/declarativemenu.cpp b/lib/declarativemenu.cpp new file mode 100644 index 0000000..965bef0 --- /dev/null +++ b/lib/declarativemenu.cpp @@ -0,0 +1,64 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativemenu_p.h" + +#include "declarativeseparator_p.h" + +DeclarativeMenu::DeclarativeMenu(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +void DeclarativeMenu::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + QMenu *menu = qobject_cast(widget); + if (!menu) { + qmlInfo(declarativeObject) << "The QMenu can only contain QMenu, QAction or Separator"; + return; + } + + m_proxiedObject->addMenu(menu); + + m_children.append(declarativeObject); +} + +void DeclarativeMenu::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) +{ + Q_UNUSED(layout); + Q_UNUSED(declarativeObject); + qmlInfo(this) << "Can not set a QLayout to a QMenu"; +} + +void DeclarativeMenu::addAction(QAction *action, AbstractDeclarativeObject *declarativeObject) +{ + DeclarativeSeparator *separator = dynamic_cast(declarativeObject); + + if (separator) { + m_proxiedObject->addSeparator(); + } else { + m_proxiedObject->addAction(action); + } + + m_children.append(declarativeObject); +} + +CUSTOM_METAOBJECT(DeclarativeMenu, QMenu) diff --git a/lib/declarativemenu_p.h b/lib/declarativemenu_p.h new file mode 100644 index 0000000..6e8d8dd --- /dev/null +++ b/lib/declarativemenu_p.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEMENU_P_H +#define DECLARATIVEMENU_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeMenu : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeMenu(QObject *parent = 0); + + protected: + virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); + virtual void addAction(QAction *action, AbstractDeclarativeObject *declarativeObject); +}; + +#endif diff --git a/lib/declarativemenubar.cpp b/lib/declarativemenubar.cpp new file mode 100644 index 0000000..acb58dc --- /dev/null +++ b/lib/declarativemenubar.cpp @@ -0,0 +1,64 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativemenubar_p.h" + +#include "declarativeseparator_p.h" + +DeclarativeMenuBar::DeclarativeMenuBar(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +void DeclarativeMenuBar::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + QMenu *menu = qobject_cast(widget); + if (!menu) { + qmlInfo(declarativeObject) << "The QMenuBar can only contain QMenus"; + return; + } + + m_proxiedObject->addMenu(menu); + + m_children.append(declarativeObject); +} + +void DeclarativeMenuBar::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) +{ + Q_UNUSED(layout); + Q_UNUSED(declarativeObject); + qmlInfo(this) << "Can not set a QLayout to a QMenuBar"; +} + +void DeclarativeMenuBar::addAction(QAction *action, AbstractDeclarativeObject *declarativeObject) +{ + Q_UNUSED(action) + + DeclarativeSeparator *separator = dynamic_cast(declarativeObject); + + if (separator) { + m_proxiedObject->addSeparator(); + } + + m_children.append(declarativeObject); +} + +CUSTOM_METAOBJECT(DeclarativeMenuBar, QMenuBar) diff --git a/lib/declarativemenubar_p.h b/lib/declarativemenubar_p.h new file mode 100644 index 0000000..5257cf0 --- /dev/null +++ b/lib/declarativemenubar_p.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEMENUBAR_P_H +#define DECLARATIVEMENUBAR_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeMenuBar : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeMenuBar(QObject *parent = 0); + + protected: + virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); + virtual void addAction(QAction *action, AbstractDeclarativeObject *declarativeObject); +}; + +#endif diff --git a/lib/declarativemessagebox.cpp b/lib/declarativemessagebox.cpp new file mode 100644 index 0000000..4eca6b2 --- /dev/null +++ b/lib/declarativemessagebox.cpp @@ -0,0 +1,89 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativemessagebox_p.h" + +DeclarativeMessageBoxAttached::DeclarativeMessageBoxAttached(QObject *parent) + : QObject(parent) +{ +} + +void DeclarativeMessageBoxAttached::about(QObject *parent, const QString &title, const QString &text) +{ + QMessageBox::about(bestParentWindow(parent), title, text); +} + +void DeclarativeMessageBoxAttached::aboutQt(QObject *parent, const QString &title) +{ + QMessageBox::aboutQt(bestParentWindow(parent), title); +} + +int DeclarativeMessageBoxAttached::critical(QObject *parent, const QString &title, const QString &text, int buttons, int defaultButton) +{ + return QMessageBox::critical(bestParentWindow(parent), title, text, static_cast(buttons), static_cast(defaultButton)); +} + +int DeclarativeMessageBoxAttached::information(QObject *parent, const QString &title, const QString &text, int buttons, int defaultButton) +{ + return QMessageBox::information(bestParentWindow(parent), title, text, static_cast(buttons), static_cast(defaultButton)); +} + +int DeclarativeMessageBoxAttached::question(QObject *parent, const QString &title, const QString &text, int buttons, int defaultButton) +{ + return QMessageBox::question(bestParentWindow(parent), title, text, static_cast(buttons), static_cast(defaultButton)); +} + +int DeclarativeMessageBoxAttached::warning(QObject *parent, const QString &title, const QString &text, int buttons, int defaultButton) +{ + return QMessageBox::warning(bestParentWindow(parent), title, text, static_cast(buttons), static_cast(defaultButton)); +} + +QWidget *DeclarativeMessageBoxAttached::bestParentWindow(QObject *parent) const +{ + if (!parent) + parent = this->parent(); + + // if parent is a Declarative Object, search the proxied hierarchy + AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); + if (declarativeObject) + parent = declarativeObject->object(); + + while (parent) { + QWidget *widget = qobject_cast(parent); + if (widget) + return widget->topLevelWidget(); + + parent = parent->parent(); + } + + return 0; +} + +DeclarativeMessageBox::DeclarativeMessageBox(QObject *parent) : DeclarativeObjectProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +DeclarativeMessageBoxAttached *DeclarativeMessageBox::qmlAttachedProperties(QObject *parent) +{ + return new DeclarativeMessageBoxAttached(parent); +} + +CUSTOM_METAOBJECT(DeclarativeMessageBox, QMessageBox) diff --git a/lib/declarativemessagebox_p.h b/lib/declarativemessagebox_p.h new file mode 100644 index 0000000..b04bb20 --- /dev/null +++ b/lib/declarativemessagebox_p.h @@ -0,0 +1,62 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEMESSAGEBOX_P_H +#define DECLARATIVEMESSAGEBOX_P_H + +#include "declarativeobjectproxy_p.h" + +#include + +class DeclarativeMessageBoxAttached : public QObject +{ + Q_OBJECT + + public: + DeclarativeMessageBoxAttached(QObject *parent = 0); + + Q_INVOKABLE void about(QObject *parent, const QString &title, const QString &text); + Q_INVOKABLE void aboutQt(QObject *parent, const QString &title); + Q_INVOKABLE int critical(QObject *parent, const QString &title, const QString &text, + int buttons = QMessageBox::Ok, int defaultButton = QMessageBox::NoButton); + Q_INVOKABLE int information(QObject *parent, const QString &title, const QString &text, + int buttons = QMessageBox::Ok, int defaultButton = QMessageBox::NoButton); + Q_INVOKABLE int question(QObject *parent, const QString &title, const QString &text, + int buttons = QMessageBox::Ok, int defaultButton = QMessageBox::NoButton); + Q_INVOKABLE int warning(QObject *parent, const QString &title, const QString &text, + int buttons = QMessageBox::Ok, int defaultButton = QMessageBox::NoButton); + + private: + QWidget *bestParentWindow(QObject *parent) const; +}; + +class DeclarativeMessageBox : public DeclarativeObjectProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeMessageBox(QObject *parent = 0); + + static DeclarativeMessageBoxAttached *qmlAttachedProperties(QObject *parent); +}; + +QML_DECLARE_TYPEINFO(DeclarativeMessageBox, QML_HAS_ATTACHED_PROPERTIES) + +#endif diff --git a/lib/declarativeobjectproxy_p.h b/lib/declarativeobjectproxy_p.h new file mode 100644 index 0000000..1b52b8b --- /dev/null +++ b/lib/declarativeobjectproxy_p.h @@ -0,0 +1,156 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEOBJECTPROXY_P_H +#define DECLARATIVEOBJECTPROXY_P_H + +#include "abstractdeclarativeobject_p.h" + +#include +#include +#include +#include + +#define DECLARATIVE_OBJECT \ + public: \ + Q_OBJECT_CHECK \ + static QMetaObject staticMetaObject; \ + static bool metaObjectInitialized; \ + static bool initializeMetaObject(); \ + static const QMetaObject &getStaticMetaObject(); \ + virtual const QMetaObject *metaObject() const; \ + virtual void *qt_metacast(const char *); \ + virtual int qt_metacall(QMetaObject::Call, int, void **); \ + private: \ + + +template +class DeclarativeObjectProxy : public AbstractDeclarativeObject +{ +}; + +template +class DeclarativeObjectProxy : public AbstractDeclarativeObject +{ + public: + DeclarativeObjectProxy(QObject *parent = 0) : AbstractDeclarativeObject(parent), m_proxiedObject(new T) {} + ~DeclarativeObjectProxy() { delete m_proxiedObject; } + + virtual QObject *object() const { return m_proxiedObject.data(); } + + protected: + virtual void dataAppend(QObject *object) + { + m_children.append(object); + } + + virtual int dataCount() const { return m_children.count(); } + virtual QObject *dataAt(int index) const { return m_children.at(index); } + virtual void dataClear() + { + qDeleteAll(m_children); + m_children.clear(); + } + + protected: + QPointer m_proxiedObject; + QVector m_children; +}; + +template +class DeclarativeObjectProxy : public AbstractDeclarativeObject +{ + public: + DeclarativeObjectProxy(QObject *parent = 0) : AbstractDeclarativeObject(parent), m_proxiedObject(new T(0)) {} + ~DeclarativeObjectProxy() { delete m_proxiedObject; } + + virtual QObject *object() const { return m_proxiedObject.data(); } + + protected: + virtual void dataAppend(QObject *object) + { + m_children.append(object); + } + + virtual int dataCount() const { return m_children.count(); } + virtual QObject *dataAt(int index) const { return m_children.at(index); } + virtual void dataClear() + { + qDeleteAll(m_children); + m_children.clear(); + } + + protected: + QPointer m_proxiedObject; + QVector m_children; +}; + +//TODO: Find a solution to make the macro public but the usage of QMetaObjectBuilder private + +#include "qmetaobjectbuilder_p.h" + +#define CUSTOM_METAOBJECT(ClassName, ProxyObjectType) \ +QMetaObject ClassName::staticMetaObject;\ +bool ClassName::metaObjectInitialized = ClassName::initializeMetaObject(); \ +bool ClassName::initializeMetaObject() \ +{ \ + QMetaObjectBuilder builder; \ + const QMetaObject *mo = &ProxyObjectType::staticMetaObject; \ + builder.addMetaObject(mo); \ + builder.addMetaObject(&AbstractDeclarativeObject::staticMetaObject); \ + builder.setSuperClass(ProxyObjectType::staticMetaObject.superClass()); \ + builder.setClassName(""#ClassName); \ + ClassName::staticMetaObject = *builder.toMetaObject(); \ + return true; \ +} \ +const QMetaObject &ClassName::getStaticMetaObject() \ +{ \ + return ClassName::staticMetaObject; \ +} \ +const QMetaObject* ClassName::metaObject() const \ +{ \ + return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; \ +} \ +void* ClassName::qt_metacast(const char*) \ +{ \ + return 0; \ +} \ +int ClassName::qt_metacall(QMetaObject::Call call, int id, void **argv) \ +{ \ + if (call == QMetaObject::ReadProperty || call == QMetaObject::WriteProperty) { \ + if (id >= ProxyObjectType::staticMetaObject.propertyCount()) { \ + id = AbstractDeclarativeObject::qt_metacall(call, id - ProxyObjectType::staticMetaObject.propertyCount() + 1, argv); \ + id += ProxyObjectType::staticMetaObject.propertyCount() - 1; \ + } else { \ + id = m_proxiedObject->qt_metacall(call, id, argv); \ + } \ + if (id < 0) \ + return 0; \ + } else if (call == QMetaObject::InvokeMetaMethod) {\ + if (ClassName::staticMetaObject.method(id).methodType() == QMetaMethod::Signal) \ + QMetaObject::activate(this, id, argv); \ + else \ + id = m_proxiedObject->qt_metacall(call, id, argv); \ + id -= 1; \ + } \ + return id; \ +} + +#endif diff --git a/lib/declarativeplaintextedit.cpp b/lib/declarativeplaintextedit.cpp new file mode 100644 index 0000000..f6cc06a --- /dev/null +++ b/lib/declarativeplaintextedit.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativeplaintextedit_p.h" + +DeclarativePlainTextEdit::DeclarativePlainTextEdit(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativePlainTextEdit, QPlainTextEdit) diff --git a/lib/declarativeplaintextedit_p.h b/lib/declarativeplaintextedit_p.h new file mode 100644 index 0000000..c9184e1 --- /dev/null +++ b/lib/declarativeplaintextedit_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEPLAINTEXTEDIT_P_H +#define DECLARATIVEPLAINTEXTEDIT_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativePlainTextEdit : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativePlainTextEdit(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativeprogressbar.cpp b/lib/declarativeprogressbar.cpp new file mode 100644 index 0000000..85afad6 --- /dev/null +++ b/lib/declarativeprogressbar.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativeprogressbar_p.h" + +DeclarativeProgressBar::DeclarativeProgressBar(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeProgressBar, QProgressBar) diff --git a/lib/declarativeprogressbar_p.h b/lib/declarativeprogressbar_p.h new file mode 100644 index 0000000..05ccb7c --- /dev/null +++ b/lib/declarativeprogressbar_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEPROGRESSBAR_P_H +#define DECLARATIVEPROGRESSBAR_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeProgressBar : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeProgressBar(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativepushbutton.cpp b/lib/declarativepushbutton.cpp new file mode 100644 index 0000000..6c68abd --- /dev/null +++ b/lib/declarativepushbutton.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativepushbutton_p.h" + +DeclarativePushButton::DeclarativePushButton(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this, QSet() << "clicked()"); +} + +CUSTOM_METAOBJECT(DeclarativePushButton, QPushButton) diff --git a/lib/declarativepushbutton_p.h b/lib/declarativepushbutton_p.h new file mode 100644 index 0000000..90fd48b --- /dev/null +++ b/lib/declarativepushbutton_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEPUSHBUTTON_P_H +#define DECLARATIVEPUSHBUTTON_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativePushButton : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativePushButton(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativeradiobutton.cpp b/lib/declarativeradiobutton.cpp new file mode 100644 index 0000000..49dd3e2 --- /dev/null +++ b/lib/declarativeradiobutton.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativeradiobutton_p.h" + +DeclarativeRadioButton::DeclarativeRadioButton(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeRadioButton, QRadioButton) diff --git a/lib/declarativeradiobutton_p.h b/lib/declarativeradiobutton_p.h new file mode 100644 index 0000000..277fd53 --- /dev/null +++ b/lib/declarativeradiobutton_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVERADIOBUTTON_P_H +#define DECLARATIVERADIOBUTTON_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeRadioButton : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeRadioButton(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativescrollarea.cpp b/lib/declarativescrollarea.cpp new file mode 100644 index 0000000..e59ad36 --- /dev/null +++ b/lib/declarativescrollarea.cpp @@ -0,0 +1,47 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativescrollarea_p.h" + +DeclarativeScrollArea::DeclarativeScrollArea(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +void DeclarativeScrollArea::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + if (m_proxiedObject->widget()) { + qmlInfo(declarativeObject) << "Can not add multiple Widgets to ScrollArea"; + } else { + m_proxiedObject->setWidget(widget); + } + + m_children.append(declarativeObject); +} + +void DeclarativeScrollArea::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) +{ + Q_UNUSED(layout); + Q_UNUSED(declarativeObject); + qmlInfo(this) << "Can not add Layout to ScrollArea"; +} + +CUSTOM_METAOBJECT(DeclarativeScrollArea, QScrollArea) diff --git a/lib/declarativescrollarea_p.h b/lib/declarativescrollarea_p.h new file mode 100644 index 0000000..55a2ca6 --- /dev/null +++ b/lib/declarativescrollarea_p.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVESCROLLAREA_P_H +#define DECLARATIVESCROLLAREA_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeScrollArea : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeScrollArea(QObject *parent = 0); + + protected: + virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); +}; + +#endif diff --git a/lib/declarativescrollbar.cpp b/lib/declarativescrollbar.cpp new file mode 100644 index 0000000..0c242b4 --- /dev/null +++ b/lib/declarativescrollbar.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativescrollbar_p.h" + +DeclarativeScrollBar::DeclarativeScrollBar(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeScrollBar, QScrollBar) diff --git a/lib/declarativescrollbar_p.h b/lib/declarativescrollbar_p.h new file mode 100644 index 0000000..058712f --- /dev/null +++ b/lib/declarativescrollbar_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVESCROLLBAR_P_H +#define DECLARATIVESCROLLBAR_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeScrollBar : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeScrollBar(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativeseparator.cpp b/lib/declarativeseparator.cpp new file mode 100644 index 0000000..0f2ce7d --- /dev/null +++ b/lib/declarativeseparator.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativeseparator_p.h" + +DeclarativeSeparator::DeclarativeSeparator(QObject *parent) + : DeclarativeObjectProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeSeparator, QAction) diff --git a/lib/declarativeseparator_p.h b/lib/declarativeseparator_p.h new file mode 100644 index 0000000..00fc703 --- /dev/null +++ b/lib/declarativeseparator_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVESEPARATOR_P_H +#define DECLARATIVESEPARATOR_P_H + +#include "declarativeobjectproxy_p.h" + +#include + +class DeclarativeSeparator : public DeclarativeObjectProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeSeparator(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativeslider.cpp b/lib/declarativeslider.cpp new file mode 100644 index 0000000..d22e39e --- /dev/null +++ b/lib/declarativeslider.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativeslider_p.h" + +DeclarativeSlider::DeclarativeSlider(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeSlider, QSlider) diff --git a/lib/declarativeslider_p.h b/lib/declarativeslider_p.h new file mode 100644 index 0000000..6a767d6 --- /dev/null +++ b/lib/declarativeslider_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVESLIDER_P_H +#define DECLARATIVESLIDER_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeSlider : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeSlider(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativespinbox.cpp b/lib/declarativespinbox.cpp new file mode 100644 index 0000000..b139d72 --- /dev/null +++ b/lib/declarativespinbox.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativespinbox_p.h" + +DeclarativeSpinBox::DeclarativeSpinBox(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeSpinBox, QSpinBox) diff --git a/lib/declarativespinbox_p.h b/lib/declarativespinbox_p.h new file mode 100644 index 0000000..259260a --- /dev/null +++ b/lib/declarativespinbox_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVESPINBOX_P_H +#define DECLARATIVESPINBOX_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeSpinBox : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeSpinBox(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativestackedlayout.cpp b/lib/declarativestackedlayout.cpp new file mode 100644 index 0000000..459a395 --- /dev/null +++ b/lib/declarativestackedlayout.cpp @@ -0,0 +1,40 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativestackedlayout_p.h" + +DeclarativeStackedLayout::DeclarativeStackedLayout(QObject *parent) + : DeclarativeLayoutProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +void DeclarativeStackedLayout::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + m_proxiedObject->addWidget(widget); + m_children.append(declarativeObject); +} + +void DeclarativeStackedLayout::addLayout(QLayout*, AbstractDeclarativeObject *declarativeObject) +{ + qmlInfo(declarativeObject) << "StackedLayout does not support child layouts"; +} + +CUSTOM_METAOBJECT(DeclarativeStackedLayout, StackedLayout) diff --git a/lib/declarativestackedlayout_p.h b/lib/declarativestackedlayout_p.h new file mode 100644 index 0000000..65a4889 --- /dev/null +++ b/lib/declarativestackedlayout_p.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVESTACKEDLAYOUT_P_H +#define DECLARATIVESTACKEDLAYOUT_P_H + +#include "declarativelayoutproxy_p.h" + +#include "objectadaptors_p.h" + +class DeclarativeStackedLayout : public DeclarativeLayoutProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeStackedLayout(QObject *parent = 0); + + protected: + void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); +}; + +#endif diff --git a/lib/declarativestackedwidget.cpp b/lib/declarativestackedwidget.cpp new file mode 100644 index 0000000..698148b --- /dev/null +++ b/lib/declarativestackedwidget.cpp @@ -0,0 +1,40 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativestackedwidget_p.h" + +DeclarativeStackedWidget::DeclarativeStackedWidget(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +void DeclarativeStackedWidget::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + m_proxiedObject->addWidget(widget); + m_children.append(declarativeObject); +} + +void DeclarativeStackedWidget::setLayout(QLayout*, AbstractDeclarativeObject *declarativeObject) +{ + qmlInfo(declarativeObject) << "StackedWidget does not support child layouts"; +} + +CUSTOM_METAOBJECT(DeclarativeStackedWidget, QStackedWidget) diff --git a/lib/declarativestackedwidget_p.h b/lib/declarativestackedwidget_p.h new file mode 100644 index 0000000..28a827f --- /dev/null +++ b/lib/declarativestackedwidget_p.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVESTACKEDWIDGET_P_H +#define DECLARATIVESTACKEDWIDGET_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeStackedWidget : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeStackedWidget(QObject *parent = 0); + + protected: + virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); +}; + +#endif diff --git a/lib/declarativestatusbar.cpp b/lib/declarativestatusbar.cpp new file mode 100644 index 0000000..48df452 --- /dev/null +++ b/lib/declarativestatusbar.cpp @@ -0,0 +1,89 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativestatusbar_p.h" + +class DeclarativeStatusBarAttached::Private +{ + public: + int stretch; +}; + +DeclarativeStatusBarAttached::DeclarativeStatusBarAttached(QObject *parent) + : QObject(parent), d(new DeclarativeStatusBarAttached::Private) +{ + d->stretch = 0; +} + +DeclarativeStatusBarAttached::~DeclarativeStatusBarAttached() +{ + delete d; +} + +void DeclarativeStatusBarAttached::setStretch(int stretch) +{ + if (d->stretch == stretch) + return; + + d->stretch = stretch; + emit stretchChanged(); +} + +int DeclarativeStatusBarAttached::stretch() const +{ + return d->stretch; +} + +DeclarativeStatusBar::DeclarativeStatusBar(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +void DeclarativeStatusBar::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + // TODO: error when layout is set + + m_children.append(declarativeObject); + + QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); + DeclarativeStatusBarAttached *attached = qobject_cast(attachedProperties); + + int stretch = 0; + if (attached) { + stretch = attached->stretch(); + } + + m_proxiedObject->addPermanentWidget(widget, stretch); +} + +void DeclarativeStatusBar::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) +{ + Q_UNUSED(layout); + Q_UNUSED(declarativeObject); + qmlInfo(this) << "Can not add QLayout to QStatusBar"; +} + +DeclarativeStatusBarAttached *DeclarativeStatusBar::qmlAttachedProperties(QObject *object) +{ + return new DeclarativeStatusBarAttached(object); +} + +CUSTOM_METAOBJECT(DeclarativeStatusBar, QStatusBar) diff --git a/lib/declarativestatusbar_p.h b/lib/declarativestatusbar_p.h new file mode 100644 index 0000000..3a1a977 --- /dev/null +++ b/lib/declarativestatusbar_p.h @@ -0,0 +1,65 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVESTATUSBAR_P_H +#define DECLARATIVESTATUSBAR_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeStatusBarAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int stretch READ stretch WRITE setStretch NOTIFY stretchChanged) + + public: + DeclarativeStatusBarAttached(QObject *parent = 0); + ~DeclarativeStatusBarAttached(); + + void setStretch(int stretch); + int stretch() const; + + Q_SIGNALS: + void stretchChanged(); + + private: + class Private; + Private *const d; +}; + +class DeclarativeStatusBar : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeStatusBar(QObject *parent = 0); + + static DeclarativeStatusBarAttached *qmlAttachedProperties(QObject *object); + + protected: + virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); +}; + +QML_DECLARE_TYPEINFO(DeclarativeStatusBar, QML_HAS_ATTACHED_PROPERTIES) + +#endif diff --git a/lib/declarativetableview.cpp b/lib/declarativetableview.cpp new file mode 100644 index 0000000..ee41509 --- /dev/null +++ b/lib/declarativetableview.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativetableview_p.h" + +DeclarativeTableView::DeclarativeTableView(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeTableView, TableView) diff --git a/lib/declarativetableview_p.h b/lib/declarativetableview_p.h new file mode 100644 index 0000000..973a62b --- /dev/null +++ b/lib/declarativetableview_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVETABLEVIEW_P_H +#define DECLARATIVETABLEVIEW_P_H + +#include "declarativewidgetproxy_p.h" + +#include "objectadaptors_p.h" + +class DeclarativeTableView : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeTableView(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativetabwidget.cpp b/lib/declarativetabwidget.cpp new file mode 100644 index 0000000..c668f9f --- /dev/null +++ b/lib/declarativetabwidget.cpp @@ -0,0 +1,120 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativetabwidget_p.h" + +class DeclarativeTabWidgetAttached::Private +{ + public: + QString label; + QIcon icon; + QPointer tabWidget; + int index; +}; + +DeclarativeTabWidgetAttached::DeclarativeTabWidgetAttached(QObject *parent) + : QObject(parent), d(new DeclarativeTabWidgetAttached::Private) +{ +} + +DeclarativeTabWidgetAttached::~DeclarativeTabWidgetAttached() +{ + delete d; +} + +void DeclarativeTabWidgetAttached::setLabel(const QString &label) +{ + if (label == d->label) + return; + + d->label = label; + + if (d->tabWidget) + d->tabWidget->setTabText(d->index, d->label); + + emit labelChanged(label); +} + +QString DeclarativeTabWidgetAttached::label() const +{ + return d->label; +} + +void DeclarativeTabWidgetAttached::setIcon(const QIcon &icon) +{ + d->icon = icon; + + if (d->tabWidget) + d->tabWidget->setTabIcon(d->index, d->icon); + + emit iconChanged(icon); +} + +QIcon DeclarativeTabWidgetAttached::icon() const +{ + return d->icon; +} + +void DeclarativeTabWidgetAttached::setAssociation(QTabWidget *widget, int index) +{ + d->tabWidget = widget; + d->index = index; +} + +DeclarativeTabWidget::DeclarativeTabWidget(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +void DeclarativeTabWidget::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + // TODO: error when layout is set + + m_children.append(declarativeObject); + + QString label; + QIcon icon; + + QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); + DeclarativeTabWidgetAttached *tabHeader = qobject_cast(attachedProperties); + if (tabHeader) { + label = tabHeader->label(); + icon = tabHeader->icon(); + } + + const int index = m_proxiedObject->addTab(widget, icon, label); + if (tabHeader) + tabHeader->setAssociation(m_proxiedObject, index); +} + +void DeclarativeTabWidget::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) +{ + Q_UNUSED(layout); + Q_UNUSED(declarativeObject); + qmlInfo(this) << "Can not add QLayout to QTabWidget"; +} + +DeclarativeTabWidgetAttached *DeclarativeTabWidget::qmlAttachedProperties(QObject *object) +{ + return new DeclarativeTabWidgetAttached(object); +} + +CUSTOM_METAOBJECT(DeclarativeTabWidget, QTabWidget) diff --git a/lib/declarativetabwidget_p.h b/lib/declarativetabwidget_p.h new file mode 100644 index 0000000..05d138a --- /dev/null +++ b/lib/declarativetabwidget_p.h @@ -0,0 +1,72 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVETABWIDGET_P_H +#define DECLARATIVETABWIDGET_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeTabWidgetAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) + Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged) + + public: + DeclarativeTabWidgetAttached(QObject *parent = 0); + ~DeclarativeTabWidgetAttached(); + + void setLabel(const QString &label); + QString label() const; + + void setIcon(const QIcon &icon); + QIcon icon() const; + + void setAssociation(QTabWidget *widget, int index); + + Q_SIGNALS: + void labelChanged(const QString &label); + void iconChanged(const QIcon &icon); + + private: + class Private; + Private *const d; +}; + +class DeclarativeTabWidget : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeTabWidget(QObject *parent = 0); + + static DeclarativeTabWidgetAttached *qmlAttachedProperties(QObject *object); + + protected: + virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); +}; + +QML_DECLARE_TYPEINFO(DeclarativeTabWidget, QML_HAS_ATTACHED_PROPERTIES) + +#endif diff --git a/lib/declarativetextbrowser.cpp b/lib/declarativetextbrowser.cpp new file mode 100644 index 0000000..973d903 --- /dev/null +++ b/lib/declarativetextbrowser.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativetextbrowser_p.h" + +DeclarativeTextBrowser::DeclarativeTextBrowser(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeTextBrowser, QTextBrowser) diff --git a/lib/declarativetextbrowser_p.h b/lib/declarativetextbrowser_p.h new file mode 100644 index 0000000..49bcdfa --- /dev/null +++ b/lib/declarativetextbrowser_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVETEXTBROWSER_P_H +#define DECLARATIVETEXTBROWSER_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeTextBrowser : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeTextBrowser(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativetextedit.cpp b/lib/declarativetextedit.cpp new file mode 100644 index 0000000..7a1584f --- /dev/null +++ b/lib/declarativetextedit.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativetextedit_p.h" + +DeclarativeTextEdit::DeclarativeTextEdit(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeTextEdit, TextEdit) diff --git a/lib/declarativetextedit_p.h b/lib/declarativetextedit_p.h new file mode 100644 index 0000000..2502bfd --- /dev/null +++ b/lib/declarativetextedit_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVETEXTEDIT_P_H +#define DECLARATIVETEXTEDIT_P_H + +#include "declarativewidgetproxy_p.h" + +#include "objectadaptors_p.h" + +class DeclarativeTextEdit : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeTextEdit(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativetimeedit.cpp b/lib/declarativetimeedit.cpp new file mode 100644 index 0000000..2be3b8a --- /dev/null +++ b/lib/declarativetimeedit.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativetimeedit_p.h" + +DeclarativeTimeEdit::DeclarativeTimeEdit(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeTimeEdit, QTimeEdit) diff --git a/lib/declarativetimeedit_p.h b/lib/declarativetimeedit_p.h new file mode 100644 index 0000000..3342a43 --- /dev/null +++ b/lib/declarativetimeedit_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVETIMEEDIT_P_H +#define DECLARATIVETIMEEDIT_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeTimeEdit : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeTimeEdit(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativetoolbar.cpp b/lib/declarativetoolbar.cpp new file mode 100644 index 0000000..3e02500 --- /dev/null +++ b/lib/declarativetoolbar.cpp @@ -0,0 +1,58 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativetoolbar_p.h" + +#include "declarativeseparator_p.h" + +DeclarativeToolBar::DeclarativeToolBar(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +void DeclarativeToolBar::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + m_proxiedObject->addWidget(widget); + + m_children.append(declarativeObject); +} + +void DeclarativeToolBar::setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) +{ + Q_UNUSED(layout); + Q_UNUSED(declarativeObject); + qmlInfo(this) << "Can not set a QLayout to a QToolBar"; +} + +void DeclarativeToolBar::addAction(QAction *action, AbstractDeclarativeObject *declarativeObject) +{ + DeclarativeSeparator *separator = dynamic_cast(declarativeObject); + + if (separator) { + m_proxiedObject->addSeparator(); + } else { + m_proxiedObject->addAction(action); + } + + m_children.append(declarativeObject); +} + +CUSTOM_METAOBJECT(DeclarativeToolBar, QToolBar) diff --git a/lib/declarativetoolbar_p.h b/lib/declarativetoolbar_p.h new file mode 100644 index 0000000..b605f1c --- /dev/null +++ b/lib/declarativetoolbar_p.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVETOOLBAR_P_H +#define DECLARATIVETOOLBAR_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeToolBar : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeToolBar(QObject *parent = 0); + + protected: + virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); + virtual void addAction(QAction *action, AbstractDeclarativeObject *declarativeObject); +}; + +#endif diff --git a/lib/declarativetoolbutton.cpp b/lib/declarativetoolbutton.cpp new file mode 100644 index 0000000..86d71c0 --- /dev/null +++ b/lib/declarativetoolbutton.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativetoolbutton_p.h" + +DeclarativeToolButton::DeclarativeToolButton(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeToolButton, QToolButton) diff --git a/lib/declarativetoolbutton_p.h b/lib/declarativetoolbutton_p.h new file mode 100644 index 0000000..0f588d8 --- /dev/null +++ b/lib/declarativetoolbutton_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVETOOLBUTTON_P_H +#define DECLARATIVETOOLBUTTON_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeToolButton : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeToolButton(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativetreeview.cpp b/lib/declarativetreeview.cpp new file mode 100644 index 0000000..f651b4b --- /dev/null +++ b/lib/declarativetreeview.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativetreeview_p.h" + +DeclarativeTreeView::DeclarativeTreeView(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeTreeView, TreeView) diff --git a/lib/declarativetreeview_p.h b/lib/declarativetreeview_p.h new file mode 100644 index 0000000..dffdcef --- /dev/null +++ b/lib/declarativetreeview_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVETREEVIEW_P_H +#define DECLARATIVETREEVIEW_P_H + +#include "declarativewidgetproxy_p.h" + +#include "objectadaptors_p.h" + +class DeclarativeTreeView : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeTreeView(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativevboxlayout.cpp b/lib/declarativevboxlayout.cpp new file mode 100644 index 0000000..e66dc39 --- /dev/null +++ b/lib/declarativevboxlayout.cpp @@ -0,0 +1,83 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativevboxlayout_p.h" + +DeclarativeVBoxLayout::DeclarativeVBoxLayout(QObject *parent) + : DeclarativeLayoutProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +DeclarativeBoxLayoutAttached *DeclarativeVBoxLayout::qmlAttachedProperties(QObject *parent) +{ + AbstractDeclarativeObject *declarativeObject = dynamic_cast(parent); + if (declarativeObject) { + QWidget *widget = qobject_cast(declarativeObject->object()); + if (widget) + return new DeclarativeBoxLayoutAttached(widget, parent); + + QLayout *layout = qobject_cast(declarativeObject->object()); + if (layout) + return new DeclarativeBoxLayoutAttached(layout, parent); + } + + qmlInfo(parent) << "Can only attach VBoxLayout to widgets and layouts"; + return 0; +} + +void DeclarativeVBoxLayout::addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) +{ + int stretch = 0; + Qt::Alignment alignment = 0; + + QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); + DeclarativeBoxLayoutAttached *properties = qobject_cast(attachedProperties); + if (properties) { + stretch = properties->stretch(); + alignment = properties->alignment(); + + properties->setParentLayout(m_proxiedObject); + } + + m_proxiedObject->addWidget(widget, stretch, alignment); + m_children.append(declarativeObject); +} + +void DeclarativeVBoxLayout::addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) +{ + int stretch = 0; + Qt::Alignment alignment = 0; + + QObject *attachedProperties = qmlAttachedPropertiesObject(declarativeObject, false); + DeclarativeBoxLayoutAttached *properties = qobject_cast(attachedProperties); + if (properties) { + stretch = properties->stretch(); + alignment = properties->alignment(); + + properties->setParentLayout(m_proxiedObject); + } + + m_proxiedObject->addLayout(layout, stretch); + m_proxiedObject->setAlignment(layout, alignment); + m_children.append(declarativeObject); +} + +CUSTOM_METAOBJECT(DeclarativeVBoxLayout, QVBoxLayout) diff --git a/lib/declarativevboxlayout_p.h b/lib/declarativevboxlayout_p.h new file mode 100644 index 0000000..037814c --- /dev/null +++ b/lib/declarativevboxlayout_p.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEVBOXLAYOUT_P_H +#define DECLARATIVEVBOXLAYOUT_P_H + +#include "declarativeboxlayout_p.h" +#include "declarativelayoutproxy_p.h" + +#include + +class DeclarativeVBoxLayout : public DeclarativeLayoutProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeVBoxLayout(QObject *parent = 0); + + static DeclarativeBoxLayoutAttached *qmlAttachedProperties(QObject *parent); + + protected: + void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject); + void addLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject); +}; + +QML_DECLARE_TYPEINFO(DeclarativeVBoxLayout, QML_HAS_ATTACHED_PROPERTIES) + +#endif diff --git a/lib/declarativewebview.cpp b/lib/declarativewebview.cpp new file mode 100644 index 0000000..47efca1 --- /dev/null +++ b/lib/declarativewebview.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativewebview_p.h" + +DeclarativeWebView::DeclarativeWebView(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeWebView, QWebView) diff --git a/lib/declarativewebview_p.h b/lib/declarativewebview_p.h new file mode 100644 index 0000000..d15eb4e --- /dev/null +++ b/lib/declarativewebview_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEWEBVIEW_P_H +#define DECLARATIVEWEBVIEW_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeWebView : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeWebView(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativewidget.cpp b/lib/declarativewidget.cpp new file mode 100644 index 0000000..d76463c --- /dev/null +++ b/lib/declarativewidget.cpp @@ -0,0 +1,29 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativewidget_p.h" + +DeclarativeWidget::DeclarativeWidget(QObject *parent) + : DeclarativeWidgetProxy(parent) +{ + connectAllSignals(m_proxiedObject, this); +} + +CUSTOM_METAOBJECT(DeclarativeWidget, QWidget) diff --git a/lib/declarativewidget_p.h b/lib/declarativewidget_p.h new file mode 100644 index 0000000..90f4c06 --- /dev/null +++ b/lib/declarativewidget_p.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEWIDGET_P_H +#define DECLARATIVEWIDGET_P_H + +#include "declarativewidgetproxy_p.h" + +#include + +class DeclarativeWidget : public DeclarativeWidgetProxy +{ + DECLARATIVE_OBJECT + + public: + DeclarativeWidget(QObject *parent = 0); +}; + +#endif diff --git a/lib/declarativewidgetproxy_p.h b/lib/declarativewidgetproxy_p.h new file mode 100644 index 0000000..d1c45d9 --- /dev/null +++ b/lib/declarativewidgetproxy_p.h @@ -0,0 +1,106 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEWIDGETPROXY_P_H +#define DECLARATIVEWIDGETPROXY_P_H + +#include "declarativeobjectproxy_p.h" + +#include "declarativeactionitem_p.h" + +#include +#include + +template +class DeclarativeWidgetProxy : public DeclarativeObjectProxy +{ + public: + DeclarativeWidgetProxy(QObject *parent = 0) : DeclarativeObjectProxy(parent) {} + + protected: + virtual void dataAppend(QObject *object) + { + AbstractDeclarativeObject *declarativeObject = dynamic_cast(object); + if (declarativeObject) { + QWidget *widget = qobject_cast(declarativeObject->object()); + if (widget) { + addWidget(widget, declarativeObject); + return; + } + + QLayout *layout = qobject_cast(declarativeObject->object()); + if (layout) { + // TODO: error when widget is set + + if (DeclarativeObjectProxy::m_proxiedObject->layout()) { + qmlInfo(this) << "Can not add a second Layout"; + return; + } + + setLayout(layout, declarativeObject); + return; + } + + DeclarativeActionItem *declarativeActionItem = dynamic_cast(object); + if (declarativeActionItem) { + addAction(qobject_cast(declarativeActionItem->object())->action(), declarativeObject); + return; + } + + QAction *action = qobject_cast(declarativeObject->object()); + if (action) { + addAction(action, declarativeObject); + return; + } + + addQObject(declarativeObject->object(), declarativeObject); + return; + } + + DeclarativeObjectProxy::dataAppend(object); + } + + virtual void addWidget(QWidget *widget, AbstractDeclarativeObject *declarativeObject) + { + Q_UNUSED(declarativeObject); + DeclarativeObjectProxy::m_children.append(declarativeObject); + widget->setParent(DeclarativeObjectProxy::m_proxiedObject, widget->windowFlags()); + } + + virtual void setLayout(QLayout *layout, AbstractDeclarativeObject *declarativeObject) + { + DeclarativeObjectProxy::m_children.append(declarativeObject); + DeclarativeObjectProxy::m_proxiedObject->setLayout(layout); + } + + virtual void addAction(QAction *action, AbstractDeclarativeObject *declarativeObject) + { + DeclarativeObjectProxy::m_children.append(declarativeObject); + DeclarativeObjectProxy::m_proxiedObject->addAction(action); + } + + virtual void addQObject(QObject *object, AbstractDeclarativeObject *declarativeObject) + { + object->setParent(DeclarativeObjectProxy::m_proxiedObject); + DeclarativeObjectProxy::m_children.append(declarativeObject); + } +}; + +#endif diff --git a/declarativewidgetdocument.cpp b/lib/declarativewidgetsdocument.cpp similarity index 61% rename from declarativewidgetdocument.cpp rename to lib/declarativewidgetsdocument.cpp index ca51bcc..b1a067b 100644 --- a/declarativewidgetdocument.cpp +++ b/lib/declarativewidgetsdocument.cpp @@ -1,6 +1,79 @@ -#include "declarativewidgetdocument.h" - -#include "declarativeobjects_p.h" +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativewidgetsdocument.h" + +// The declarative widget wrappers +#include "declarativeactionitem_p.h" +#include "declarativeaction_p.h" +#include "declarativebuttongroup_p.h" +#include "declarativecalendarwidget_p.h" +#include "declarativecheckbox_p.h" +#include "declarativecolordialog_p.h" +#include "declarativecolumnview_p.h" +#include "declarativecommandlinkbutton_p.h" +#include "declarativedateedit_p.h" +#include "declarativedatetimeedit_p.h" +#include "declarativedialogbuttonbox_p.h" +#include "declarativedialog_p.h" +#include "declarativedial_p.h" +#include "declarativedoublespinbox_p.h" +#include "declarativefiledialog_p.h" +#include "declarativefontdialog_p.h" +#include "declarativeformlayout_p.h" +#include "declarativeframe_p.h" +#include "declarativegridlayout_p.h" +#include "declarativegroupbox_p.h" +#include "declarativehboxlayout_p.h" +#include "declarativeinputdialog_p.h" +#include "declarativelabel_p.h" +#include "declarativelcdnumber_p.h" +#include "declarativelineedit_p.h" +#include "declarativelistview_p.h" +#include "declarativemainwindow_p.h" +#include "declarativemenubar_p.h" +#include "declarativemenu_p.h" +#include "declarativemessagebox_p.h" +#include "declarativeplaintextedit_p.h" +#include "declarativeprogressbar_p.h" +#include "declarativepushbutton_p.h" +#include "declarativeradiobutton_p.h" +#include "declarativescrollarea_p.h" +#include "declarativescrollbar_p.h" +#include "declarativeseparator_p.h" +#include "declarativeslider_p.h" +#include "declarativespinbox_p.h" +#include "declarativestackedlayout_p.h" +#include "declarativestackedwidget_p.h" +#include "declarativestatusbar_p.h" +#include "declarativetableview_p.h" +#include "declarativetabwidget_p.h" +#include "declarativetextbrowser_p.h" +#include "declarativetextedit_p.h" +#include "declarativetimeedit_p.h" +#include "declarativetoolbar_p.h" +#include "declarativetoolbutton_p.h" +#include "declarativetreeview_p.h" +#include "declarativevboxlayout_p.h" +#include "declarativewebview_p.h" +#include "declarativewidget_p.h" #include #include @@ -8,10 +81,10 @@ #include #include -class DeclarativeWidgetDocument::Private +class DeclarativeWidgetsDocument::Private { public: - Private(DeclarativeWidgetDocument *qq, const QUrl &url) + Private(DeclarativeWidgetsDocument *qq, const QUrl &url) : q(qq) , m_url(url) , m_engine(new QDeclarativeEngine(q)) @@ -19,13 +92,13 @@ class DeclarativeWidgetDocument::Private { } - DeclarativeWidgetDocument* q; + DeclarativeWidgetsDocument* q; QUrl m_url; QDeclarativeEngine* m_engine; QDeclarativeComponent* m_component; }; -DeclarativeWidgetDocument::DeclarativeWidgetDocument(const QUrl &url, QObject *parent) +DeclarativeWidgetsDocument::DeclarativeWidgetsDocument(const QUrl &url, QObject *parent) : QObject(parent) , d(new Private(this, url)) { @@ -108,27 +181,27 @@ DeclarativeWidgetDocument::DeclarativeWidgetDocument(const QUrl &url, QObject *p } } -DeclarativeWidgetDocument::~DeclarativeWidgetDocument() +DeclarativeWidgetsDocument::~DeclarativeWidgetsDocument() { delete d; } -void DeclarativeWidgetDocument::setContextProperty(const QString &name, const QVariant &value) +void DeclarativeWidgetsDocument::setContextProperty(const QString &name, const QVariant &value) { d->m_engine->rootContext()->setContextProperty(name, value); } -void DeclarativeWidgetDocument::setContextProperty(const QString &name, QObject *object) +void DeclarativeWidgetsDocument::setContextProperty(const QString &name, QObject *object) { d->m_engine->rootContext()->setContextProperty(name, object); } -QDeclarativeEngine* DeclarativeWidgetDocument::engine() const +QDeclarativeEngine* DeclarativeWidgetsDocument::engine() const { return d->m_engine; } -QWidget* DeclarativeWidgetDocument::createWidget() +QWidget* DeclarativeWidgetsDocument::createWidget() { QObject *object = d->m_component->create(); if (!object) { diff --git a/lib/declarativewidgetsdocument.h b/lib/declarativewidgetsdocument.h new file mode 100644 index 0000000..8e7f3ea --- /dev/null +++ b/lib/declarativewidgetsdocument.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef DECLARATIVEWIDGETSDOCUMENT_H +#define DECLARATIVEWIDGETSDOCUMENT_H + +#include +#include + +class QDeclarativeEngine; + +class DeclarativeWidgetsDocument : public QObject +{ + Q_OBJECT + + public: + DeclarativeWidgetsDocument(const QUrl &url, QObject *parent = 0); + ~DeclarativeWidgetsDocument(); + + void setContextProperty(const QString &name, const QVariant &value); + void setContextProperty(const QString &name, QObject *object); + + QDeclarativeEngine* engine() const; + + template + T* create() + { + QWidget *widget = createWidget(); + if (!widget) + return 0; + + return qobject_cast(widget); + } + + private: + QWidget* createWidget(); + + class Private; + Private* const d; +}; + +#endif diff --git a/objectadaptors.cpp b/lib/objectadaptors.cpp similarity index 85% rename from objectadaptors.cpp rename to lib/objectadaptors.cpp index 7bd564b..b654864 100644 --- a/objectadaptors.cpp +++ b/lib/objectadaptors.cpp @@ -1,7 +1,28 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include "objectadaptors_p.h" -#include "declarativeobjects_p.h" +#include "declarativeaction_p.h" +#include #include // ActionItem diff --git a/objectadaptors_p.h b/lib/objectadaptors_p.h similarity index 85% rename from objectadaptors_p.h rename to lib/objectadaptors_p.h index cc0850a..e830ae9 100644 --- a/objectadaptors_p.h +++ b/lib/objectadaptors_p.h @@ -1,3 +1,23 @@ +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #ifndef OBJECTADAPTORS_P_H #define OBJECTADAPTORS_P_H diff --git a/qmetaobjectbuilder.cpp b/lib/qmetaobjectbuilder.cpp similarity index 100% rename from qmetaobjectbuilder.cpp rename to lib/qmetaobjectbuilder.cpp diff --git a/qmetaobjectbuilder_p.h b/lib/qmetaobjectbuilder_p.h similarity index 100% rename from qmetaobjectbuilder_p.h rename to lib/qmetaobjectbuilder_p.h diff --git a/main.cpp b/main.cpp index 201c796..f8efb19 100644 --- a/main.cpp +++ b/main.cpp @@ -1,4 +1,24 @@ -#include "declarativewidgetdocument.h" +/* + Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com + Author: Kevin Krammer, krake@kdab.com + Author: Tobias Koenig, tokoe@kdab.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "declarativewidgetsdocument.h" #include #include @@ -29,7 +49,7 @@ int main(int argc, char **argv) QFileSystemModel model; model.setRootPath("/"); - DeclarativeWidgetDocument document(documentUrl); + DeclarativeWidgetsDocument document(documentUrl); QObject::connect(document.engine(), SIGNAL(quit()), &app, SLOT(quit())); document.setContextProperty("_timer", &timer);