From a08546507fe0ce356e4183e557d9408295c80610 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 21 Feb 2012 13:31:19 +1000 Subject: Reduce QQuickTextEdit memory usage. Remove unnecessary members from QQuickTextEditPrivate and QQuickTextControlPrivate and re-order and pack to reduce padding for alignment. Change-Id: I14f5e3fc01646d02745f095c2a4b168cd675745d Reviewed-by: Yann Bodson --- src/quick/items/qquicktextcontrol.cpp | 94 ++-------------------- src/quick/items/qquicktextcontrol_p.h | 12 --- src/quick/items/qquicktextcontrol_p_p.h | 55 ++++++------- src/quick/items/qquicktextedit.cpp | 43 +++------- src/quick/items/qquicktextedit_p_p.h | 79 +++++++++--------- .../qtquick2/qquicktextedit/tst_qquicktextedit.cpp | 3 - 6 files changed, 84 insertions(+), 202 deletions(-) diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index a763626410..9a61312910 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -97,13 +97,17 @@ static QTextLine currentTextLine(const QTextCursor &cursor) } QQuickTextControlPrivate::QQuickTextControlPrivate() - : doc(0), cursorOn(false), cursorIsFocusIndicator(false), + : doc(0), + preeditCursor(0), interactionFlags(Qt::TextEditorInteraction), + cursorOn(false), + cursorIsFocusIndicator(false), mousePressed(false), - lastSelectionState(false), ignoreAutomaticScrollbarAdjustement(false), + lastSelectionState(false), + ignoreAutomaticScrollbarAdjustement(false), overwriteMode(false), acceptRichText(true), - preeditCursor(0), hideCursor(false), + hideCursor(false), hasFocus(false), isEnabled(true), hadSelectionOnMousePress(false), @@ -298,7 +302,6 @@ void QQuickTextControlPrivate::setContent(Qt::TextFormat format, const QString & doc = document; clearDocument = false; } else { - palette = QGuiApplication::palette(); doc = new QTextDocument(q); } _q_documentLayoutChanged(); @@ -631,18 +634,6 @@ QQuickTextControl::~QQuickTextControl() { } -void QQuickTextControl::setView(QObject *view) -{ - Q_D(QQuickTextControl); - d->contextObject = view; -} - -QObject *QQuickTextControl::view() const -{ - Q_D(const QQuickTextControl); - return d->contextObject; -} - QTextDocument *QQuickTextControl::document() const { Q_D(const QQuickTextControl); @@ -1418,7 +1409,7 @@ bool QQuickTextControlPrivate::sendMouseEventToInputContext(QMouseEvent *e, cons Q_UNUSED(e); - if (contextObject && isPreediting()) { + if (isPreediting()) { QTextLayout *layout = cursor.block().layout(); int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position(); @@ -1908,81 +1899,12 @@ QString QQuickTextControl::toHtml() const } #endif -QPalette QQuickTextControl::palette() const -{ - Q_D(const QQuickTextControl); - return d->palette; -} - -void QQuickTextControl::setPalette(const QPalette &pal) -{ - Q_D(QQuickTextControl); - d->palette = pal; -} - bool QQuickTextControl::cursorOn() const { Q_D(const QQuickTextControl); return d->cursorOn; } -QAbstractTextDocumentLayout::PaintContext QQuickTextControl::getPaintContext() const -{ - Q_D(const QQuickTextControl); - - QAbstractTextDocumentLayout::PaintContext ctx; - - ctx.palette = d->palette; - if (d->cursorOn && d->isEnabled) { - if (d->hideCursor) - ctx.cursorPosition = -1; - else if (d->preeditCursor != 0) - ctx.cursorPosition = - (d->preeditCursor + 2); - else - ctx.cursorPosition = d->cursor.position(); - } - - if (d->cursor.hasSelection()) { - QAbstractTextDocumentLayout::Selection selection; - selection.cursor = d->cursor; - if (0 && d->cursorIsFocusIndicator) { -#if 0 - // ### - QStyleOption opt; - opt.palette = ctx.palette; - QStyleHintReturnVariant ret; - QStyle *style = QGuiApplication::style(); - if (widget) - style = widget->style(); - style->styleHint(QStyle::SH_TextControl_FocusIndicatorTextCharFormat, &opt, widget, &ret); - selection.format = qvariant_cast(ret.variant).toCharFormat(); -#endif - } else { - QPalette::ColorGroup cg = d->hasFocus ? QPalette::Active : QPalette::Inactive; - selection.format.setBackground(ctx.palette.brush(cg, QPalette::Highlight)); - selection.format.setForeground(ctx.palette.brush(cg, QPalette::HighlightedText)); - if (fullWidthSelection) - selection.format.setProperty(QTextFormat::FullWidthSelection, true); - } - ctx.selections.append(selection); - } - - return ctx; -} - -void QQuickTextControl::drawContents(QPainter *p, const QRectF &rect) -{ - Q_D(QQuickTextControl); - p->save(); - QAbstractTextDocumentLayout::PaintContext ctx = getPaintContext(); - if (rect.isValid()) - p->setClipRect(rect, Qt::IntersectClip); - ctx.clip = rect; - - d->doc->documentLayout()->draw(p, ctx); - p->restore(); -} - int QQuickTextControl::hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const { Q_D(const QQuickTextControl); diff --git a/src/quick/items/qquicktextcontrol_p.h b/src/quick/items/qquicktextcontrol_p.h index e7beefdaa3..97ecdc4c6e 100644 --- a/src/quick/items/qquicktextcontrol_p.h +++ b/src/quick/items/qquicktextcontrol_p.h @@ -90,9 +90,6 @@ public: explicit QQuickTextControl(QTextDocument *doc, QObject *parent = 0); virtual ~QQuickTextControl(); - void setView(QObject *view); - QObject *view() const; - QTextDocument *document() const; void setTextCursor(const QTextCursor &cursor); @@ -127,9 +124,6 @@ public: qreal textWidth() const; QSizeF size() const; - void setIgnoreUnusedNavigationEvents(bool ignore); - bool ignoreUnusedNavigationEvents() const; - void moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor); bool canPaste() const; @@ -178,16 +172,10 @@ Q_SIGNALS: void linkHovered(const QString &); public: - // control properties - QPalette palette() const; - void setPalette(const QPalette &pal); - virtual void processEvent(QEvent *e, const QMatrix &matrix); void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF()); // control methods - void drawContents(QPainter *painter, const QRectF &rect = QRectF()); - void setFocus(bool focus, Qt::FocusReason = Qt::OtherFocusReason); virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const; diff --git a/src/quick/items/qquicktextcontrol_p_p.h b/src/quick/items/qquicktextcontrol_p_p.h index daf2f8ca82..44bc00221b 100644 --- a/src/quick/items/qquicktextcontrol_p_p.h +++ b/src/quick/items/qquicktextcontrol_p_p.h @@ -132,49 +132,40 @@ public: bool isPreediting() const; void commitPreedit(); - QTextDocument *doc; - bool cursorOn; - QTextCursor cursor; - bool cursorIsFocusIndicator; - QTextCharFormat lastCharFormat; - - Qt::TextInteractionFlags interactionFlags; - - QBasicTimer cursorBlinkTimer; - QBasicTimer trippleClickTimer; QPointF trippleClickPoint; + QPointF mousePressPos; - bool mousePressed; - - QPoint mousePressPos; - - QPointer contextObject; - - bool lastSelectionState; - - bool ignoreAutomaticScrollbarAdjustement; + QTextCharFormat lastCharFormat; + QTextDocument *doc; + QTextCursor cursor; QTextCursor selectedWordOnDoubleClick; QTextCursor selectedBlockOnTrippleClick; + QString tentativeCommit; + QString highlightedAnchor; // Anchor below cursor + QString anchorOnMousePress; + QString linkToCopy; - bool overwriteMode; - bool acceptRichText; + QBasicTimer cursorBlinkTimer; + QBasicTimer trippleClickTimer; int preeditCursor; - bool hideCursor; // used to hide the cursor in the preedit area - QString tentativeCommit; - - QPalette palette; - bool hasFocus; - bool isEnabled; - QString highlightedAnchor; // Anchor below cursor - QString anchorOnMousePress; - bool hadSelectionOnMousePress; + Qt::TextInteractionFlags interactionFlags; - bool wordSelectionEnabled; + bool cursorOn : 1; + bool cursorIsFocusIndicator : 1; + bool mousePressed : 1; + bool lastSelectionState : 1; + bool ignoreAutomaticScrollbarAdjustement : 1; + bool overwriteMode : 1; + bool acceptRichText : 1; + bool hideCursor : 1; // used to hide the cursor in the preedit area + bool hasFocus : 1; + bool isEnabled : 1; + bool hadSelectionOnMousePress : 1; + bool wordSelectionEnabled : 1; - QString linkToCopy; void _q_copyLink(); void _q_updateBlock(const QTextBlock &); void _q_documentLayoutChanged(); diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 6f3c32db7d..06264715a1 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -399,9 +399,6 @@ void QQuickTextEdit::setColor(const QColor &color) return; d->color = color; - QPalette pal = d->control->palette(); - pal.setColor(QPalette::Text, color); - d->control->setPalette(pal); updateDocument(); emit colorChanged(d->color); } @@ -424,9 +421,6 @@ void QQuickTextEdit::setSelectionColor(const QColor &color) return; d->selectionColor = color; - QPalette pal = d->control->palette(); - pal.setColor(QPalette::Highlight, color); - d->control->setPalette(pal); updateDocument(); emit selectionColorChanged(d->selectionColor); } @@ -449,9 +443,6 @@ void QQuickTextEdit::setSelectedTextColor(const QColor &color) return; d->selectedTextColor = color; - QPalette pal = d->control->palette(); - pal.setColor(QPalette::HighlightedText, color); - d->control->setPalette(pal); updateDocument(); emit selectedTextColorChanged(d->selectedTextColor); } @@ -1634,10 +1625,8 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData * QRectF bounds = boundingRect(); - QColor selectionColor = d->control->palette().color(QPalette::Highlight); - QColor selectedTextColor = d->control->palette().color(QPalette::HighlightedText); node->addTextDocument(bounds.topLeft(), d->document, d->color, QQuickText::Normal, QColor(), - selectionColor, selectedTextColor, selectionStart(), + d->selectionColor, d->selectedTextColor, selectionStart(), selectionEnd() - 1); // selectionEnd() returns first char after // selection @@ -1756,31 +1745,21 @@ void QQuickTextEditPrivate::init() document = new QQuickTextDocumentWithImageResources(q); control = new QQuickTextControl(document, q); - control->setView(q); control->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByKeyboard | Qt::TextEditable); control->setAcceptRichText(false); control->setCursorIsFocusIndicator(true); - // QQuickTextControl follows the default text color - // defined by the platform, declarative text - // should be black by default - QPalette pal = control->palette(); - if (pal.color(QPalette::Text) != color) { - pal.setColor(QPalette::Text, color); - control->setPalette(pal); - } - - QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateDocument())); - QObject::connect(control, SIGNAL(updateCursorRequest()), q, SLOT(updateCursor())); - QObject::connect(control, SIGNAL(textChanged()), q, SLOT(q_textChanged())); - QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged())); - QObject::connect(control, SIGNAL(selectionChanged()), q, SLOT(updateSelectionMarkers())); - QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers())); - QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged())); - QObject::connect(control, SIGNAL(cursorRectangleChanged()), q, SLOT(moveCursorDelegate())); - QObject::connect(control, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString))); + FAST_CONNECT(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateDocument())); + FAST_CONNECT(control, SIGNAL(updateCursorRequest()), q, SLOT(updateCursor())); + FAST_CONNECT(control, SIGNAL(textChanged()), q, SLOT(q_textChanged())); + FAST_CONNECT(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged())); + FAST_CONNECT(control, SIGNAL(selectionChanged()), q, SLOT(updateSelectionMarkers())); + FAST_CONNECT(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers())); + FAST_CONNECT(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged())); + FAST_CONNECT(control, SIGNAL(cursorRectangleChanged()), q, SLOT(moveCursorDelegate())); + FAST_CONNECT(control, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString))); #ifndef QT_NO_CLIPBOARD - QObject::connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged())); + FAST_CONNECT(QGuiApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged())); #endif FAST_CONNECT(document, SIGNAL(undoAvailable(bool)), q, SIGNAL(canUndoChanged())); FAST_CONNECT(document, SIGNAL(redoAvailable(bool)), q, SIGNAL(canRedoChanged())); diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h index d69e24f6bc..1497c207ee 100644 --- a/src/quick/items/qquicktextedit_p_p.h +++ b/src/quick/items/qquicktextedit_p_p.h @@ -68,15 +68,17 @@ class QQuickTextEditPrivate : public QQuickImplicitSizeItemPrivate public: QQuickTextEditPrivate() - : color("black"), hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop), - documentDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true), - persistentSelection(false), requireImplicitWidth(false), selectByMouse(false), canPaste(false), - canPasteValid(false), hAlignImplicit(true), rightToLeftText(false), - textCached(false), - textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0), - format(QQuickTextEdit::PlainText), document(0), wrapMode(QQuickTextEdit::NoWrap), - mouseSelectionMode(QQuickTextEdit::SelectCharacters), - lineCount(0), yoff(0), inputMethodHints(Qt::ImhNone), updateType(UpdatePaintNode) + : color(QRgb(0xFF000000)), selectionColor(QRgb(0xFF000080)), selectedTextColor(QRgb(0xFFFFFFFF)) + , textMargin(0.0), font(sourceFont), cursorComponent(0), cursor(0), document(0), control(0) + , lastSelectionStart(0), lastSelectionEnd(0), lineCount(0), yoff(0) + , hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop) + , format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap) + , mouseSelectionMode(QQuickTextEdit::SelectCharacters), inputMethodHints(Qt::ImhNone) + , updateType(UpdatePaintNode) + , documentDirty(true), dirty(false), richText(false), cursorVisible(false) + , focusOnPress(true), persistentSelection(false), requireImplicitWidth(false) + , selectByMouse(false), canPaste(false), canPasteValid(false), hAlignImplicit(true) + , rightToLeftText(false), textCached(false) { } @@ -92,17 +94,42 @@ public: void mirrorChange(); qreal getImplicitWidth() const; + QColor color; + QColor selectionColor; + QColor selectedTextColor; + + QSize contentSize; + + qreal textMargin; + QString text; QUrl baseUrl; - QFont font; QFont sourceFont; - QColor color; - QColor selectionColor; - QColor selectedTextColor; - QString style; - QColor styleColor; + QFont font; + + QDeclarativeComponent* cursorComponent; + QQuickItem* cursor; + QQuickTextDocumentWithImageResources *document; + QQuickTextControl *control; + + int lastSelectionStart; + int lastSelectionEnd; + int lineCount; + int yoff; + + enum UpdateType { + UpdateNone, + UpdateOnlyPreprocess, + UpdatePaintNode + }; + QQuickTextEdit::HAlignment hAlign; QQuickTextEdit::VAlignment vAlign; + QQuickTextEdit::TextFormat format; + QQuickTextEdit::WrapMode wrapMode; + QQuickTextEdit::SelectionMode mouseSelectionMode; + Qt::InputMethodHints inputMethodHints; + UpdateType updateType; bool documentDirty : 1; bool dirty : 1; @@ -117,28 +144,6 @@ public: bool hAlignImplicit:1; bool rightToLeftText:1; bool textCached:1; - - qreal textMargin; - int lastSelectionStart; - int lastSelectionEnd; - QDeclarativeComponent* cursorComponent; - QQuickItem* cursor; - QQuickTextEdit::TextFormat format; - QQuickTextDocumentWithImageResources *document; - QQuickTextControl *control; - QQuickTextEdit::WrapMode wrapMode; - QQuickTextEdit::SelectionMode mouseSelectionMode; - int lineCount; - int yoff; - QSize contentSize; - Qt::InputMethodHints inputMethodHints; - - enum UpdateType { - UpdateNone, - UpdateOnlyPreprocess, - UpdatePaintNode - }; - UpdateType updateType; }; QT_END_NAMESPACE diff --git a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp index 41c8546688..62b85b8d24 100644 --- a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp @@ -903,10 +903,7 @@ void tst_qquicktextedit::color() QVERIFY(textEditObject); QVERIFY(textEditPrivate); QVERIFY(textEditPrivate->control); - - QPalette pal = textEditPrivate->control->palette(); QCOMPARE(textEditPrivate->color, QColor("black")); - QCOMPARE(textEditPrivate->color, pal.color(QPalette::Text)); } //test normal for (int i = 0; i < colorStrings.size(); i++) -- cgit v1.2.3 From 12f0663dbda6ae56d3307493ca34212f601dd3aa Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 21 Feb 2012 14:11:04 +1000 Subject: Fix font size calculation in headings in StyledText. Calculate the font size correctly even when the size is specified in pixels and update this size when the font changes. Also make sure that the text layout's font is set before parsing. Task-number: QTBUG-24458 Change-Id: Ida7723f6e4f4b9fd3a6878076f4beaf5bda8f7f7 Reviewed-by: Andrew den Exter --- src/quick/items/qquicktext.cpp | 15 ++- src/quick/items/qquicktext_p_p.h | 1 + src/quick/util/qdeclarativestyledtext.cpp | 43 ++++--- src/quick/util/qdeclarativestyledtext_p.h | 6 +- .../tst_qdeclarativestyledtext.cpp | 130 +++++++++++---------- .../qtquick2/qquicktext/data/pixelFontSizes.qml | 21 ++++ .../qtquick2/qquicktext/data/pointFontSizes.qml | 21 ++++ tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 72 ++++++++++++ 8 files changed, 228 insertions(+), 81 deletions(-) create mode 100644 tests/auto/qtquick2/qquicktext/data/pixelFontSizes.qml create mode 100644 tests/auto/qtquick2/qquicktext/data/pointFontSizes.qml diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 6f8aa383cd..44735c1895 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -85,7 +85,7 @@ QQuickTextPrivate::QQuickTextPrivate() , maximumLineCountValid(false), updateOnComponentComplete(true), richText(false) , styledText(false), singleline(false), internalWidthUpdate(false), requireImplicitWidth(false) , truncated(false), hAlignImplicit(true), rightToLeftText(false) - , layoutTextElided(false), textHasChanged(true), needToUpdateLayout(false) + , layoutTextElided(false), textHasChanged(true), needToUpdateLayout(false), formatModifiesFontSize(false) { } @@ -298,7 +298,11 @@ void QQuickTextPrivate::updateLayout() if (!richText) { if (textHasChanged) { if (styledText && !text.isEmpty()) { - QDeclarativeStyledText::parse(text, layout, imgTags, q->baseUrl(), qmlContext(q), !maximumLineCountValid); + layout.setFont(font); + // needs temporary bool because formatModifiesFontSize is in a bit-field + bool fontSizeModified = false; + QDeclarativeStyledText::parse(text, layout, imgTags, q->baseUrl(), qmlContext(q), !maximumLineCountValid, &fontSizeModified); + formatModifiesFontSize = fontSizeModified; } else { layout.clearAdditionalFormats(); multilengthEos = text.indexOf(QLatin1Char('\x9c')); @@ -1252,8 +1256,13 @@ void QQuickText::setFont(const QFont &font) d->font.setPointSizeF(size/2.0); } - if (oldFont != d->font) + if (oldFont != d->font) { + // if the format changes the size of the text + // with headings or tag, we need to re-parse + if (d->formatModifiesFontSize) + d->textHasChanged = true; d->updateLayout(); + } emit fontChanged(d->sourceFont); } diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h index 555f41ff94..e060cc1cd2 100644 --- a/src/quick/items/qquicktext_p_p.h +++ b/src/quick/items/qquicktext_p_p.h @@ -148,6 +148,7 @@ public: bool layoutTextElided:1; bool textHasChanged:1; bool needToUpdateLayout:1; + bool formatModifiesFontSize:1; static const QChar elideChar; diff --git a/src/quick/util/qdeclarativestyledtext.cpp b/src/quick/util/qdeclarativestyledtext.cpp index 164e33cec1..ddb8cadd2a 100644 --- a/src/quick/util/qdeclarativestyledtext.cpp +++ b/src/quick/util/qdeclarativestyledtext.cpp @@ -69,6 +69,8 @@ QT_BEGIN_NAMESPACE +Q_GUI_EXPORT int qt_defaultDpi(); + class QDeclarativeStyledTextPrivate { public: @@ -85,9 +87,10 @@ public: QList &imgTags, const QUrl &baseUrl, QDeclarativeContext *context, - bool preloadImages) + bool preloadImages, + bool *fontSizeModified) : text(t), layout(l), imgTags(&imgTags), baseFont(layout.font()), baseUrl(baseUrl), hasNewLine(false), nbImages(0), updateImagePositions(false) - , preFormat(false), prependSpace(false), hasSpace(true), preloadImages(preloadImages), context(context) + , preFormat(false), prependSpace(false), hasSpace(true), preloadImages(preloadImages), fontSizeModified(fontSizeModified), context(context) { } @@ -103,7 +106,7 @@ public: void parseImageAttributes(const QChar *&ch, const QString &textIn, QString &textOut); QPair parseAttribute(const QChar *&ch, const QString &textIn); QStringRef parseValue(const QChar *&ch, const QString &textIn); - + void setFontSize(int size, QTextCharFormat &format); inline void skipSpace(const QChar *&ch) { while (ch->isSpace() && !ch->isNull()) @@ -126,6 +129,7 @@ public: bool prependSpace; bool hasSpace; bool preloadImages; + bool *fontSizeModified; QDeclarativeContext *context; static const QChar lessThan; @@ -160,8 +164,9 @@ QDeclarativeStyledText::QDeclarativeStyledText(const QString &string, QTextLayou QList &imgTags, const QUrl &baseUrl, QDeclarativeContext *context, - bool preloadImages) - : d(new QDeclarativeStyledTextPrivate(string, layout, imgTags, baseUrl, context, preloadImages)) + bool preloadImages, + bool *fontSizeModified) + : d(new QDeclarativeStyledTextPrivate(string, layout, imgTags, baseUrl, context, preloadImages, fontSizeModified)) { } @@ -174,11 +179,12 @@ void QDeclarativeStyledText::parse(const QString &string, QTextLayout &layout, QList &imgTags, const QUrl &baseUrl, QDeclarativeContext *context, - bool preloadImages) + bool preloadImages, + bool *fontSizeModified) { if (string.isEmpty()) return; - QDeclarativeStyledText styledText(string, layout, imgTags, baseUrl, context, preloadImages); + QDeclarativeStyledText styledText(string, layout, imgTags, baseUrl, context, preloadImages, fontSizeModified); styledText.d->parse(); } @@ -298,6 +304,20 @@ void QDeclarativeStyledTextPrivate::appendText(const QString &textIn, int start, hasNewLine = false; } +// +// Calculates and sets the correct font size in points +// depending on the size multiplier and base font. +// +void QDeclarativeStyledTextPrivate::setFontSize(int size, QTextCharFormat &format) +{ + static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 }; + if (baseFont.pointSizeF() != -1) + format.setFontPointSize(baseFont.pointSize() * scaling[size - 1]); + else + format.setFontPointSize(baseFont.pixelSize() * qreal(72.) / qreal(qt_defaultDpi()) * scaling[size - 1]); + *fontSizeModified = true; +} + bool QDeclarativeStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format) { skipSpace(ch); @@ -353,12 +373,11 @@ bool QDeclarativeStyledTextPrivate::parseTag(const QChar *&ch, const QString &te } else if (char0 == QLatin1Char('h') && tagLength == 2) { int level = tag.at(1).digitValue(); if (level >= 1 && level <= 6) { - static const qreal scaling[] = { 2.0, 1.5, 1.2, 1.0, 0.8, 0.7 }; if (!hasNewLine) textOut.append(QChar::LineSeparator); hasSpace = true; prependSpace = false; - format.setFontPointSize(baseFont.pointSize() * scaling[level - 1]); + setFontSize(7 - level, format); format.setFontWeight(QFont::Bold); return true; } @@ -550,10 +569,8 @@ bool QDeclarativeStyledTextPrivate::parseFontAttributes(const QChar *&ch, const int size = attr.second.toString().toInt(); if (attr.second.at(0) == QLatin1Char('-') || attr.second.at(0) == QLatin1Char('+')) size += 3; - if (size >= 1 && size <= 7) { - static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 }; - format.setFontPointSize(baseFont.pointSize() * scaling[size-1]); - } + if (size >= 1 && size <= 7) + setFontSize(size, format); } } while (!ch->isNull() && !attr.first.isEmpty()); diff --git a/src/quick/util/qdeclarativestyledtext_p.h b/src/quick/util/qdeclarativestyledtext_p.h index aa6ae3f869..4487a9e98a 100644 --- a/src/quick/util/qdeclarativestyledtext_p.h +++ b/src/quick/util/qdeclarativestyledtext_p.h @@ -85,14 +85,16 @@ public: QList &imgTags, const QUrl &baseUrl, QDeclarativeContext *context, - bool preloadImages); + bool preloadImages, + bool *fontSizeModified); private: QDeclarativeStyledText(const QString &string, QTextLayout &layout, QList &imgTags, const QUrl &baseUrl, QDeclarativeContext *context, - bool preloadImages); + bool preloadImages, + bool *fontSizeModified); ~QDeclarativeStyledText(); QDeclarativeStyledTextPrivate *d; diff --git a/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp b/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp index fd0d1abd29..ca3855c32a 100644 --- a/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp +++ b/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp @@ -88,68 +88,69 @@ void tst_qdeclarativestyledtext::textOutput_data() QTest::addColumn("input"); QTest::addColumn("output"); QTest::addColumn("formats"); - - QTest::newRow("bold") << "bold" << "bold" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("italic") << "italic" << "italic" << (FormatList() << Format(Format::Italic, 0, 6)); - QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)); - QTest::newRow("strong") << "strong" << "strong" << (FormatList() << Format(Format::Bold, 0, 6)); - QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)); - QTest::newRow("missing >") << "text") << "text") << "text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("missing ") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("nested") << "text italic bold" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5)); - QTest::newRow("bad nest") << "text italic" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6)); - QTest::newRow("font color") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)); - QTest::newRow("font color: single quote") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)); - QTest::newRow("font size") << "text" << "text" << (FormatList() << Format(0, 0, 4)); - QTest::newRow("font empty") << "text" << "text" << FormatList(); - QTest::newRow("font bad 1") << "text" << "text" << FormatList(); - QTest::newRow("font bad 2") << "text" << "" << FormatList(); - QTest::newRow("extra close") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("extra space") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)); - QTest::newRow("entities") << "<b>this & that</b>" << "this & that" << FormatList(); - QTest::newRow("newline") << "text
more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("paragraph") << "text

more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("paragraph closed") << "text

more text

more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("paragraph closed bold") << "text

more text

more text
" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24)); - QTest::newRow("self-closing newline") << "text
more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("empty") << "" << "" << FormatList(); - QTest::newRow("unknown tag") << "underline not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9)); - QTest::newRow("ordered list") << "
  1. one
  2. two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList(); - QTest::newRow("ordered list closed") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list alpha") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list upper alpha") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list roman") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list upper roman") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("ordered list bad") << "
    1. one
    2. two
    " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list") << "
    • one
    • two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList(); - QTest::newRow("unordered list closed") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list disc") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list square") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("unordered list bad") << "
      • one
      • two
      " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList(); - QTest::newRow("header close") << "

      head

      more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h0") << "head" << "head" << FormatList(); - QTest::newRow("h1") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h2") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h3") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h4") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h5") << "

      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h6") << "
      head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("h7") << "head" << "head" << FormatList(); - QTest::newRow("pre") << "normal
      pre text
      normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9)); - QTest::newRow("pre lb") << "normal
      pre\n text
      normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10)); - QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList(); - QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList(); - QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList(); - QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList(); - QTest::newRow("space after newline") << "text
      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("space after paragraph") << "text

      more text

      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList(); - QTest::newRow("space in header") << "

      head

      " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5)); - QTest::newRow("space before bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4)); - QTest::newRow("space leading bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5)); - QTest::newRow("space trailing bold") << "this is bold " << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5)); - QTest::newRow("img") << "ab" << "a b" << FormatList(); + QTest::addColumn("modifiesFontSize"); + + QTest::newRow("bold") << "bold" << "bold" << (FormatList() << Format(Format::Bold, 0, 4)) << false; + QTest::newRow("italic") << "italic" << "italic" << (FormatList() << Format(Format::Italic, 0, 6)) << false; + QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false; + QTest::newRow("strong") << "strong" << "strong" << (FormatList() << Format(Format::Bold, 0, 6)) << false; + QTest::newRow("underline") << "underline" << "underline" << (FormatList() << Format(Format::Underline, 0, 9)) << false; + QTest::newRow("missing >") << "text") << "text") << "text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false; + QTest::newRow("missing ") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false; + QTest::newRow("nested") << "text italic bold" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5)) << false; + QTest::newRow("bad nest") << "text italic" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6)) << false; + QTest::newRow("font color") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)) << false; + QTest::newRow("font color: single quote") << "red text" << "red text" << (FormatList() << Format(0, 0, 8)) << false; + QTest::newRow("font size") << "text" << "text" << (FormatList() << Format(0, 0, 4)) << true; + QTest::newRow("font empty") << "text" << "text" << FormatList() << false; + QTest::newRow("font bad 1") << "text" << "text" << FormatList() << false; + QTest::newRow("font bad 2") << "text" << "" << FormatList() << false; + QTest::newRow("extra close") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false; + QTest::newRow("extra space") << "text" << "text" << (FormatList() << Format(Format::Bold, 0, 4)) << false; + QTest::newRow("entities") << "<b>this & that</b>" << "this & that" << FormatList() << false; + QTest::newRow("newline") << "text
      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("paragraph") << "text

      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("paragraph closed") << "text

      more text

      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("paragraph closed bold") << "text

      more text

      more text
      " << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24)) << false; + QTest::newRow("self-closing newline") << "text
      more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("empty") << "" << "" << FormatList() << false; + QTest::newRow("unknown tag") << "underline not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9)) << false; + QTest::newRow("ordered list") << "
      1. one
      2. two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList() << false; + QTest::newRow("ordered list closed") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("ordered list alpha") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("ordered list upper alpha") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("ordered list roman") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("ordered list upper roman") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("ordered list bad") << "
        1. one
        2. two
        " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("unordered list") << "
        • one
        • two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList() << false; + QTest::newRow("unordered list closed") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("unordered list disc") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("unordered list square") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("unordered list bad") << "
          • one
          • two
          " << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList() << false; + QTest::newRow("header close") << "

          head

          more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h0") << "head" << "head" << FormatList() << false; + QTest::newRow("h1") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h2") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h3") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h4") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h5") << "

          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h6") << "
          head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("h7") << "head" << "head" << FormatList() << false; + QTest::newRow("pre") << "normal
          pre text
          normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9)) << false; + QTest::newRow("pre lb") << "normal
          pre\n text
          normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10)) << false; + QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList() << false; + QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList() << false; + QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList() << false; + QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList() << false; + QTest::newRow("space after newline") << "text
          more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("space after paragraph") << "text

          more text

          more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList() << false; + QTest::newRow("space in header") << "

          head

          " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5)) << true; + QTest::newRow("space before bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4)) << false; + QTest::newRow("space leading bold") << "this is bold" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5)) << false; + QTest::newRow("space trailing bold") << "this is bold " << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5)) << false; + QTest::newRow("img") << "ab" << "a b" << FormatList() << false; } void tst_qdeclarativestyledtext::textOutput() @@ -157,10 +158,12 @@ void tst_qdeclarativestyledtext::textOutput() QFETCH(QString, input); QFETCH(QString, output); QFETCH(FormatList, formats); + QFETCH(bool, modifiesFontSize); QTextLayout layout; QList imgTags; - QDeclarativeStyledText::parse(input, layout, imgTags, QUrl(), 0, false); + bool fontSizeModified = false; + QDeclarativeStyledText::parse(input, layout, imgTags, QUrl(), 0, false, &fontSizeModified); QCOMPARE(layout.text(), output); @@ -177,6 +180,7 @@ void tst_qdeclarativestyledtext::textOutput() QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic)); QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline)); } + QCOMPARE(fontSizeModified, modifiesFontSize); } diff --git a/tests/auto/qtquick2/qquicktext/data/pixelFontSizes.qml b/tests/auto/qtquick2/qquicktext/data/pixelFontSizes.qml new file mode 100644 index 0000000000..e3d81b682e --- /dev/null +++ b/tests/auto/qtquick2/qquicktext/data/pixelFontSizes.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 200 + + property variant pixelSize: 6 + + Text { + objectName: "text" + font.pixelSize: parent.pixelSize + text: "This is
          a font
          size test." + } + + Text { + x: 200 + objectName: "textWithTag" + font.pixelSize: parent.pixelSize + text: "This is

          a font

          size test." + } +} diff --git a/tests/auto/qtquick2/qquicktext/data/pointFontSizes.qml b/tests/auto/qtquick2/qquicktext/data/pointFontSizes.qml new file mode 100644 index 0000000000..6feb8fecf8 --- /dev/null +++ b/tests/auto/qtquick2/qquicktext/data/pointFontSizes.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 200 + + property variant pointSize: 6 + + Text { + objectName: "text" + font.pointSize: parent.pointSize + text: "This is
          a font
          size test." + } + + Text { + x: 200 + objectName: "textWithTag" + font.pointSize: parent.pointSize + text: "This is

          a font

          size test." + } +} diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index d1c0f765d0..86d502f07e 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -122,6 +122,8 @@ private slots: void fontSizeModeMultiline(); void multilengthStrings_data(); void multilengthStrings(); + void fontFormatSizes_data(); + void fontFormatSizes(); private: QStringList standard; @@ -2427,6 +2429,76 @@ void tst_qquicktext::multilengthStrings() QCOMPARE(myText->truncated(), true); } +void tst_qquicktext::fontFormatSizes_data() +{ + QTest::addColumn("text"); + QTest::addColumn("textWithTag"); + QTest::addColumn("fontIsBigger"); + + QTest::newRow("fs1") << "Hello world!" << "Hello world!" << false; + QTest::newRow("fs2") << "Hello world!" << "Hello world!" << false; + QTest::newRow("fs3") << "Hello world!" << "Hello world!" << false; + QTest::newRow("fs4") << "Hello world!" << "Hello world!" << true; + QTest::newRow("fs5") << "Hello world!" << "Hello world!" << true; + QTest::newRow("fs6") << "Hello world!" << "Hello world!" << true; + QTest::newRow("fs7") << "Hello world!" << "Hello world!" << true; + QTest::newRow("h1") << "This is
          a font
          size test." << "This is

          a font

          size test." << true; + QTest::newRow("h2") << "This is
          a font
          size test." << "This is

          a font

          size test." << true; + QTest::newRow("h3") << "This is
          a font
          size test." << "This is

          a font

          size test." << true; + QTest::newRow("h4") << "This is
          a font
          size test." << "This is

          a font

          size test." << true; + QTest::newRow("h5") << "This is
          a font
          size test." << "This is
          a font
          size test." << false; + QTest::newRow("h6") << "This is
          a font
          size test." << "This is
          a font
          size test." << false; +} + +void tst_qquicktext::fontFormatSizes() +{ + QFETCH(QString, text); + QFETCH(QString, textWithTag); + QFETCH(bool, fontIsBigger); + + QQuickView *view = new QQuickView; + { + view->setSource(testFileUrl("pointFontSizes.qml")); + view->show(); + + QQuickText *qtext = view->rootObject()->findChild("text"); + QQuickText *qtextWithTag = view->rootObject()->findChild("textWithTag"); + QVERIFY(qtext != 0); + QVERIFY(qtextWithTag != 0); + + qtext->setText(text); + qtextWithTag->setText(textWithTag); + + for (int size = 6; size < 100; size += 4) { + view->rootObject()->setProperty("pointSize", size); + if (fontIsBigger) + QVERIFY(qtext->height() <= qtextWithTag->height()); + else + QVERIFY(qtext->height() >= qtextWithTag->height()); + } + } + + { + view->setSource(testFileUrl("pixelFontSizes.qml")); + QQuickText *qtext = view->rootObject()->findChild("text"); + QQuickText *qtextWithTag = view->rootObject()->findChild("textWithTag"); + QVERIFY(qtext != 0); + QVERIFY(qtextWithTag != 0); + + qtext->setText(text); + qtextWithTag->setText(textWithTag); + + for (int size = 6; size < 100; size += 4) { + view->rootObject()->setProperty("pixelSize", size); + if (fontIsBigger) + QVERIFY(qtext->height() <= qtextWithTag->height()); + else + QVERIFY(qtext->height() >= qtextWithTag->height()); + } + } + delete view; +} + QTEST_MAIN(tst_qquicktext) #include "tst_qquicktext.moc" -- cgit v1.2.3 From 66ce5181816ae4e2361d062e8d41f599233b7905 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 23 Feb 2012 11:08:58 +1000 Subject: Small doc fixes. Change-Id: I54ed2d0387b85ac853d94cfe716a1f6016986e2a Reviewed-by: Glenn Watson --- src/quick/scenegraph/coreapi/qsgnode.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp index 88afac7ecc..618538642e 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.cpp +++ b/src/quick/scenegraph/coreapi/qsgnode.cpp @@ -777,9 +777,9 @@ QSGClipNode::~QSGClipNode() Sets whether this clip node has a rectangular clip to \a rectHint. This is an optimization hint which means that the renderer can - use scissoring instead of stencil, which is significnatly faster. + use scissoring instead of stencil, which is significantly faster. - When this hint is and it is applicable, the clip region will be + When this hint is set and it is applicable, the clip region will be generated from clipRect() rather than geometry(). */ @@ -791,7 +791,7 @@ void QSGClipNode::setIsRectangular(bool rectHint) /*! - \fn void QSGClipNode::clipRect() const + \fn QRectF QSGClipNode::clipRect() const Returns the clip rect of this node. */ -- cgit v1.2.3 From c5f65d859720c9345f995136301f6809bbb82867 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 23 Feb 2012 11:58:23 +1000 Subject: QML locale.firstDayOfWeek returns 7 for Sunday To match JS Date object, Sunday should be 0. Change-Id: I662c0b1fcbf921fa1c4bb58f900366dd088b343b Reviewed-by: Glenn Watson --- src/declarative/qml/qdeclarativelocale.cpp | 5 ++- .../qdeclarativelocale/tst_qdeclarativelocale.cpp | 38 +++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qdeclarativelocale.cpp b/src/declarative/qml/qdeclarativelocale.cpp index 39d0f6c378..103378a9c0 100644 --- a/src/declarative/qml/qdeclarativelocale.cpp +++ b/src/declarative/qml/qdeclarativelocale.cpp @@ -524,7 +524,10 @@ v8::Handle QDeclarativeNumberExtension::fromLocaleString(const v8::Ar static v8::Handle locale_get_firstDayOfWeek(v8::Local, const v8::AccessorInfo &info) { GET_LOCALE_DATA_RESOURCE(info.This()); - return v8::Integer::New(r->locale.firstDayOfWeek()); + int fdow = int(r->locale.firstDayOfWeek()); + if (fdow == 7) + fdow = 0; // Qt::Sunday = 7, but Sunday is 0 in JS Date + return v8::Integer::New(fdow); } static v8::Handle locale_get_measurementSystem(v8::Local, const v8::AccessorInfo &info) diff --git a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp b/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp index bf5c8c7af4..7d86ad9148 100644 --- a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp +++ b/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp @@ -68,6 +68,8 @@ private slots: void dayName(); void standaloneDayName_data(); void standaloneDayName(); + void firstDayOfWeek_data(); + void firstDayOfWeek(); void weekDays_data(); void weekDays(); void uiLanguages_data(); @@ -154,7 +156,6 @@ void tst_qdeclarativelocale::addPropertyData(const QString &l) LOCALE_PROP(QString,negativeSign), LOCALE_PROP(QString,positiveSign), LOCALE_PROP(QString,exponential), - LOCALE_PROP(int,firstDayOfWeek), LOCALE_PROP(int,measurementSystem), LOCALE_PROP(int,textDirection), { 0, QVariant() } @@ -426,6 +427,41 @@ void tst_qdeclarativelocale::standaloneDayName() delete obj; } +void tst_qdeclarativelocale::firstDayOfWeek_data() +{ + QTest::addColumn("locale"); + + QTest::newRow("en_US") << "en_US"; + QTest::newRow("de_DE") << "de_DE"; + QTest::newRow("ar_SA") << "ar_SA"; + QTest::newRow("hi_IN") << "hi_IN"; + QTest::newRow("zh_CN") << "zh_CN"; + QTest::newRow("th_TH") << "th_TH"; +} + +void tst_qdeclarativelocale::firstDayOfWeek() +{ + QFETCH(QString, locale); + + QDeclarativeComponent c(&engine, testFileUrl("properties.qml")); + + QObject *obj = c.create(); + QVERIFY(obj); + + QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection, + Q_ARG(QVariant, QVariant(locale))); + + QVariant val = obj->property("firstDayOfWeek"); + QVERIFY(val.type() == QVariant::Int); + + int day = int(QLocale(locale).firstDayOfWeek()); + if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday) + day = 0; + QCOMPARE(day, val.toInt()); + + delete obj; +} + void tst_qdeclarativelocale::weekDays_data() { QTest::addColumn("locale"); -- cgit v1.2.3 From 924a9620d528da85dc19df7573d33ba4132e5a3a Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Fri, 17 Feb 2012 12:26:21 +1000 Subject: Fix Text eliding with implicit height and maximumLineCount. Ignore the height of the text if the element height is invalid. Task-number: QTBUG-24293 Change-Id: I1646c3f64583da40e6166aeea24c2c4af42cb279 Reviewed-by: Yann Bodson --- src/quick/items/qquicktext.cpp | 6 ++++-- tests/auto/qtquick2/qquicktext/data/multilineelide.qml | 2 +- tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 44735c1895..28491d8f75 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -666,6 +666,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) } const int lineWidth = q->widthValid() ? q->width() : INT_MAX; + const qreal maxHeight = q->heightValid() ? q->height() : FLT_MAX; const bool customLayout = isLineLaidOutConnected(); const bool wasTruncated = truncated; @@ -715,6 +716,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) } layout.beginLayout(); + bool wrapped = false; bool truncateHeight = false; truncated = false; @@ -735,7 +737,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) // Elide the previous line if the accumulated height of the text exceeds the height // of the element. - if (multilineElide && height > q->height() && visibleCount > 1) { + if (multilineElide && height > maxHeight && visibleCount > 1) { elide = true; if (eos != -1) // There's an abbreviated string available, skip the rest as it's break; // all going to be discarded. @@ -873,7 +875,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) } if (verticalFit) { - if (truncateHeight || (q->heightValid() && unelidedRect.height() > q->height())) { + if (truncateHeight || unelidedRect.height() > maxHeight) { largeFont = scaledFontSize - 1; scaledFontSize = (smallFont + largeFont + 1) / 2; if (smallFont > largeFont) diff --git a/tests/auto/qtquick2/qquicktext/data/multilineelide.qml b/tests/auto/qtquick2/qquicktext/data/multilineelide.qml index f3bb65775b..ffca0d638a 100644 --- a/tests/auto/qtquick2/qquicktext/data/multilineelide.qml +++ b/tests/auto/qtquick2/qquicktext/data/multilineelide.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 Text { - width: 200; height: 200 + width: 200 wrapMode: Text.WordWrap elide: Text.ElideRight maximumLineCount: 3 diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index 86d502f07e..c28de8b53c 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -471,6 +471,12 @@ void tst_qquicktext::multilineElide() qreal lineHeight = myText->contentHeight() / 3.; + // Set a valid height greater than the truncated content height and ensure the line count is + // unchanged. + myText->setHeight(200); + QCOMPARE(myText->lineCount(), 3); + QCOMPARE(myText->truncated(), true); + // reduce size and ensure fewer lines are drawn myText->setHeight(lineHeight * 2); QCOMPARE(myText->lineCount(), 2); -- cgit v1.2.3 From 09ea9cace4286c639044aef79f2deb107c2a5376 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Thu, 23 Feb 2012 11:57:18 +1000 Subject: Fix for bad operator precedence causing right mouse button issues Binary or (|) has higher operator precedence than a ternary in C, causing the original expression here to function quite incorrectly for anything other than the common left-mouse-button-only case. I just added brackets -- feel free to change this to "if"s if you think that would more clearly avoid this issue in future. Change-Id: Ie20bd7e805b89a393794d3240fb0ae680b29ff64 Reviewed-by: Andrew den Exter --- src/quick/items/qquickitem_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index c2cc7d000b..fd02334ab3 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -830,8 +830,8 @@ private: Qt::MouseButtons QQuickItemPrivate::acceptedMouseButtons() const { - return extra.flag()?Qt::LeftButton:Qt::MouseButton(0) | - (extra.isAllocated()?extra->acceptedMouseButtons:Qt::MouseButtons(0)); + return ((extra.flag() ? Qt::LeftButton : Qt::MouseButton(0)) | + (extra.isAllocated() ? extra->acceptedMouseButtons : Qt::MouseButtons(0))); } QSGContext *QQuickItemPrivate::sceneGraphContext() const -- cgit v1.2.3 From bbbc44c45d9a6b7381b775413fcfcc1a72c14317 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 23 Feb 2012 11:51:31 +1000 Subject: Clean up some of the view transition docs Fix some of the wording in the docs. Change-Id: I07892bec06c78b73bdd93926719d609405e263b3 Reviewed-by: Bea Lam --- src/quick/items/qquickgridview.cpp | 69 ++++++++++++++++++++------------------ src/quick/items/qquicklistview.cpp | 69 ++++++++++++++++++++------------------ 2 files changed, 72 insertions(+), 66 deletions(-) diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp index d7f4b808f2..a7e0af487f 100644 --- a/src/quick/items/qquickgridview.cpp +++ b/src/quick/items/qquickgridview.cpp @@ -1586,10 +1586,11 @@ void QQuickGridView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::GridView::populate - This property holds the transition to apply to items that are initially created for a - view. - This transition is applied to all the items that are created when: + This property holds the transition to apply to the items that are initially created + for a view. + + It is applied to all items that are created when: \list \o The view is first created @@ -1619,10 +1620,10 @@ void QQuickGridView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::GridView::add - This property holds the transition to apply to items that are added within the view. - The transition is applied to items that have been added to the visible area of the view. For - example, here is a view that specifies such a transition: + This property holds the transition to apply to items that are added to the view. + + For example, here is a view that specifies such a transition: \code GridView { @@ -1651,11 +1652,11 @@ void QQuickGridView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::GridView::addDisplaced - This property holds the transition to apply to items in the view that are displaced by other - items that have been added to the view. - The transition is applied to items that are currently visible and have been displaced by newly - added items. For example, here is a view that specifies such a transition: + This property holds the transition to apply to items within the view that are displaced by + the addition of other items to the view. + + For example, here is a view that specifies such a transition: \code GridView { @@ -1684,11 +1685,11 @@ void QQuickGridView::setSnapMode(SnapMode mode) */ /*! \qmlproperty Transition QtQuick2::GridView::move - This property holds the transition to apply to items in the view that are moved by a move - operation. - The transition is applied to items that are moving within the view or are moving - into the view as a result of a move operation in the view's model. For example: + This property holds the transition to apply to items in the view that are being moved due + to a move operation in the view's \l model. + + For example, here is a view that specifies such a transition: \code GridView { @@ -1699,10 +1700,11 @@ void QQuickGridView::setSnapMode(SnapMode mode) } \endcode - Whenever an item is moved within the above view, the item will be animated to its new position in - the view over one second. The transition only applies to the items that are the subject of the - move operation in the model; it does not apply to the items below them that are displaced by - the move operation. To animate the displaced items, set the \l moveDisplaced property. + Whenever the \l model performs a move operation to move a particular set of indexes, the + respective items in the view will be animated to their new positions in the view over one + second. The transition only applies to the items that are the subject of the move operation + in the model; it does not apply to items below them that are displaced by the move operation. + To animate the displaced items, set the \l moveDisplaced property. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -1712,11 +1714,11 @@ void QQuickGridView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::GridView::moveDisplaced - This property holds the transition to apply to items in the view that are displaced by a - move operation in the view. - The transition is applied to items that are currently visible and have been displaced following - a move operation in the view's model. For example, here is a view that specifies such a transition: + This property holds the transition to apply to items that are displaced by a move operation in + the view's \l model. + + For example, here is a view that specifies such a transition: \code GridView { @@ -1727,12 +1729,13 @@ void QQuickGridView::setSnapMode(SnapMode mode) } \endcode - Whenever an item moves within (or moves into) the above view, all items beneath it are - displaced, causing them to move upwards (or sideways, if horizontally orientated) within the - view. As this displacement occurs, the items' movement to their new x,y positions within the - view will be animated by a NumberAnimation over one second, as specified. This transition is - not applied to the item that are actually the subject of the move operation; to animate the - moved items, set the \l move property. + Whenever the \l model performs a move operation to move a particular set of indexes, the items + between the source and destination indexes of the move operation are displaced, causing them + to move upwards or downwards (or sideways, if horizontally orientated) within the view. As this + displacement occurs, the items' movement to their new x,y positions within the view will be + animated by a NumberAnimation over one second, as specified. This transition is not applied to + the items that are the actual subjects of the move operation; to animate the moved items, set + the \l move property. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -1742,10 +1745,10 @@ void QQuickGridView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::GridView::remove + This property holds the transition to apply to items that are removed from the view. - The transition is applied to items that have been removed from the visible area of the view. For - example: + For example, here is a view that specifies such a transition: \code GridView { @@ -1762,7 +1765,7 @@ void QQuickGridView::setSnapMode(SnapMode mode) Whenever an item is removed from the above view, the item will be animated to the position (100,100) over one second, and in parallel will also change its opacity to 0. The transition only applies to the items that are removed from the view; it does not apply to the items below - them that are displaced by the removal of the items. To animate the displaced items, set the \l + them that are displaced by the removal of the items. To animate the displaced items, set the \l removeDisplaced property. Note that by the time the transition is applied, the item has already been removed from the @@ -1779,11 +1782,11 @@ void QQuickGridView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::GridView::removeDisplaced + This property holds the transition to apply to items in the view that are displaced by the removal of other items in the view. - The transition is applied to items that are currently visible and have been displaced by - the removal of items. For example, here is a view that specifies such a transition: + For example, here is a view that specifies such a transition: \code GridView { diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 906b9b3781..6324c7d2ff 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -2245,10 +2245,11 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::populate - This property holds the transition to apply to items that are initially created for a - view. - This transition is applied to all the items that are created when: + This property holds the transition to apply to the items that are initially created + for a view. + + It is applied to all items that are created when: \list \o The view is first created @@ -2278,10 +2279,10 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::add - This property holds the transition to apply to items that are added within the view. - The transition is applied to items that have been added to the visible area of the view. For - example, here is a view that specifies such a transition: + This property holds the transition to apply to items that are added to the view. + + For example, here is a view that specifies such a transition: \code ListView { @@ -2310,11 +2311,11 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::addDisplaced - This property holds the transition to apply to items in the view that are displaced by other - items that have been added to the view. - The transition is applied to items that are currently visible and have been displaced by newly - added items. For example, here is a view that specifies such a transition: + This property holds the transition to apply to items within the view that are displaced by + the addition of other items to the view. + + For example, here is a view that specifies such a transition: \code ListView { @@ -2344,11 +2345,11 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::move - This property holds the transition to apply to items in the view that are moved by a move - operation. - The transition is applied to items that are moving within the view or are moving - into the view as a result of a move operation in the view's model. For example: + This property holds the transition to apply to items in the view that are being moved due + to a move operation in the view's \l model. + + For example, here is a view that specifies such a transition: \code ListView { @@ -2359,10 +2360,11 @@ void QQuickListView::setSnapMode(SnapMode mode) } \endcode - Whenever an item is moved within the above view, the item will be animated to its new position in - the view over one second. The transition only applies to the items that are the subject of the - move operation in the model; it does not apply to the items below them that are displaced by - the move operation. To animate the displaced items, set the \l moveDisplaced property. + Whenever the \l model performs a move operation to move a particular set of indexes, the + respective items in the view will be animated to their new positions in the view over one + second. The transition only applies to the items that are the subject of the move operation + in the model; it does not apply to items below them that are displaced by the move operation. + To animate the displaced items, set the \l moveDisplaced property. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2372,11 +2374,11 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::moveDisplaced - This property holds the transition to apply to items in the view that are displaced by a - move operation in the view. - The transition is applied to items that are currently visible and have been displaced following - a move operation in the view's model. For example, here is a view that specifies such a transition: + This property holds the transition to apply to items that are displaced by a move operation in + the view's \l model. + + For example, here is a view that specifies such a transition: \code ListView { @@ -2387,12 +2389,13 @@ void QQuickListView::setSnapMode(SnapMode mode) } \endcode - Whenever an item moves within (or moves into) the above view, all items beneath it are - displaced, causing them to move upwards (or sideways, if horizontally orientated) within the - view. As this displacement occurs, the items' movement to their new x,y positions within the - view will be animated by a NumberAnimation over one second, as specified. This transition is - not applied to the item that are actually the subject of the move operation; to animate the - moved items, set the \l move property. + Whenever the \l model performs a move operation to move a particular set of indexes, the items + between the source and destination indexes of the move operation are displaced, causing them + to move upwards or downwards (or sideways, if horizontally orientated) within the view. As this + displacement occurs, the items' movement to their new x,y positions within the view will be + animated by a NumberAnimation over one second, as specified. This transition is not applied to + the items that are the actual subjects of the move operation; to animate the moved items, set + the \l move property. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2402,10 +2405,10 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::remove + This property holds the transition to apply to items that are removed from the view. - The transition is applied to items that have been removed from the visible area of the view. For - example: + For example, here is a view that specifies such a transition: \code ListView { @@ -2422,7 +2425,7 @@ void QQuickListView::setSnapMode(SnapMode mode) Whenever an item is removed from the above view, the item will be animated to the position (100,100) over one second, and in parallel will also change its opacity to 0. The transition only applies to the items that are removed from the view; it does not apply to the items below - them that are displaced by the removal of the items. To animate the displaced items, set the \l + them that are displaced by the removal of the items. To animate the displaced items, set the \l removeDisplaced property. Note that by the time the transition is applied, the item has already been removed from the @@ -2439,11 +2442,11 @@ void QQuickListView::setSnapMode(SnapMode mode) /*! \qmlproperty Transition QtQuick2::ListView::removeDisplaced + This property holds the transition to apply to items in the view that are displaced by the removal of other items in the view. - The transition is applied to items that are currently visible and have been displaced by - the removal of items. For example, here is a view that specifies such a transition: + For example, here is a view that specifies such a transition: \code ListView { -- cgit v1.2.3 From dc3165178851b9bda71dd238c8a5faca4dfa7a45 Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Thu, 23 Feb 2012 14:55:16 +1000 Subject: Remove warning produced by 'parent' reference. When Qt.createQmlObject is invoked from QML, any contained references to parent produce a warning from V8. To prevent this, move the assignment of the parent object to before the initial execution of the bindings. Task-number: QTBUG-24464 Change-Id: Ib330822f1ca46ec5a6af648a56197da09669c3f2 Reviewed-by: Martin Jones --- .../qml/v8/qdeclarativebuiltinfunctions.cpp | 19 +++++++------ .../data/createParentReference.qml | 12 ++++++++ .../tst_qdeclarativecomponent.cpp | 32 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativecomponent/data/createParentReference.qml diff --git a/src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp b/src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp index 12f06e6b76..d338508d09 100644 --- a/src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp +++ b/src/declarative/qml/v8/qdeclarativebuiltinfunctions.cpp @@ -1096,8 +1096,17 @@ v8::Handle createQmlObject(const v8::Arguments &args) V8THROW_ERROR("Qt.createQmlObject(): Component is not ready"); QObject *obj = component.beginCreate(effectiveContext); - if (obj) + if (obj) { QDeclarativeData::get(obj, true)->setImplicitDestructible(); + + obj->setParent(parentArg); + + QList functions = QDeclarativeMetaType::parentFunctions(); + for (int ii = 0; ii < functions.count(); ++ii) { + if (QDeclarativePrivate::Parented == functions.at(ii)(obj, parentArg)) + break; + } + } component.completeCreate(); if (component.isError()) { @@ -1107,14 +1116,6 @@ v8::Handle createQmlObject(const v8::Arguments &args) Q_ASSERT(obj); - obj->setParent(parentArg); - - QList functions = QDeclarativeMetaType::parentFunctions(); - for (int ii = 0; ii < functions.count(); ++ii) { - if (QDeclarativePrivate::Parented == functions.at(ii)(obj, parentArg)) - break; - } - return v8engine->newQObject(obj); } diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createParentReference.qml b/tests/auto/declarative/qdeclarativecomponent/data/createParentReference.qml new file mode 100644 index 0000000000..daa5d3c167 --- /dev/null +++ b/tests/auto/declarative/qdeclarativecomponent/data/createParentReference.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + id: root + width: 100 + height: 100 + + function createChild() { + Qt.createQmlObject("import QtQuick 2.0;" + + "Item { width: parent.width; }", root); + } +} diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp index c529649fc0..993c706092 100644 --- a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp +++ b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp @@ -71,6 +71,7 @@ private slots: void qmlCreateObject(); void qmlCreateObjectWithProperties(); void qmlIncubateObject(); + void qmlCreateParentReference(); private: QDeclarativeEngine engine; @@ -181,6 +182,37 @@ void tst_qdeclarativecomponent::qmlCreateObjectWithProperties() delete testBindingThisObj; } +static QStringList warnings; +static void msgHandler(QtMsgType, const char *warning) +{ + warnings << QString::fromUtf8(warning); +} + +void tst_qdeclarativecomponent::qmlCreateParentReference() +{ + QDeclarativeEngine engine; + + QCOMPARE(engine.outputWarningsToStandardError(), true); + + warnings.clear(); + QtMsgHandler old = qInstallMsgHandler(msgHandler); + + QDeclarativeComponent component(&engine, testFileUrl("createParentReference.qml")); + QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8()); + QObject *object = component.create(); + QVERIFY(object != 0); + + QVERIFY(QMetaObject::invokeMethod(object, "createChild")); + delete object; + + qInstallMsgHandler(old); + + engine.setOutputWarningsToStandardError(false); + QCOMPARE(engine.outputWarningsToStandardError(), false); + + QCOMPARE(warnings.count(), 0); +} + QTEST_MAIN(tst_qdeclarativecomponent) #include "tst_qdeclarativecomponent.moc" -- cgit v1.2.3 From fb3889a423365b1736cae8850cdb2b3ac77b14a8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 21 Feb 2012 10:55:34 +0100 Subject: Use new plugin system in QtDeclarative. - Use prefix "org.qt-project" for interfaces. - Use new macros, add json files. Change-Id: I53df83f95153c5c9c462098584606284470a5ae0 Reviewed-by: Martin Jones --- .../declarative/cppextensions/imageprovider/imageprovider.cpp | 6 ++++-- .../declarative/cppextensions/imageprovider/imageprovider.json | 1 + .../declarative/cppextensions/imageprovider/imageprovider.pro | 2 ++ examples/declarative/cppextensions/plugins/plugin.cpp | 6 ++---- examples/declarative/cppextensions/plugins/plugin.json | 1 + examples/declarative/cppextensions/plugins/plugins.pro | 2 ++ examples/declarative/cppextensions/qwidgets/qwidgets.json | 1 + .../painteditem/textballoons/TextBalloonPlugin/plugin.h | 3 +-- .../painteditem/textballoons/TextBalloonPlugin/textballoon.json | 1 + examples/declarative/painteditem/textballoons/textballoons.pro | 2 ++ .../tutorials/extending/chapter6-plugins/chartsplugin.cpp | 1 - .../tutorials/extending/chapter6-plugins/chartsplugin.h | 2 ++ .../tutorials/extending/chapter6-plugins/chartsplugin.json | 1 + examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp | 3 --- examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h | 1 + examples/tutorials/gettingStartedQml/filedialog/dialogplugin.json | 1 + src/declarative/debugger/qdeclarativedebugserverconnection_p.h | 4 +++- src/declarative/debugger/qdeclarativeinspectorinterface_p.h | 4 +++- src/declarative/qml/qdeclarativeextensioninterface.h | 7 ++++++- src/declarative/qml/qdeclarativepropertyvalueinterceptor_p.h | 5 ++++- src/declarative/qml/qdeclarativepropertyvaluesource.h | 5 ++++- src/imports/folderlistmodel/folderlistmodel.json | 1 + src/imports/folderlistmodel/plugin.cpp | 7 ++----- src/imports/gestures/gestures.json | 1 + src/imports/localstorage/localstorage.json | 1 + src/imports/localstorage/localstorage.pro | 4 +++- src/imports/localstorage/plugin.cpp | 4 ++-- src/imports/shaders/shaders.json | 1 + src/imports/testlib/main.cpp | 4 ++-- src/imports/testlib/testlib.json | 1 + src/imports/testlib/testlib.pro | 3 ++- src/imports/xmllistmodel/plugin.cpp | 4 ++-- src/imports/xmllistmodel/xmllistmodel.json | 1 + src/plugins/accessible/quick/accessible.json | 3 +++ src/plugins/accessible/quick/main.cpp | 8 +++++--- src/plugins/accessible/quick/quick.pro | 2 ++ src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro | 2 ++ src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp | 2 -- src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h | 1 + src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.json | 2 ++ src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro | 2 ++ src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp | 2 -- src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h | 2 +- src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json | 1 + src/quick/items/qquickvisualadaptormodel_p.h | 4 +++- src/quick/scenegraph/qsgcontextplugin_p.h | 2 +- tests/auto/declarative/qdeclarativelanguage/testtypes.h | 3 ++- tests/auto/declarative/qdeclarativemoduleplugin/empty.json | 1 + .../declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp | 4 ++-- .../auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp | 4 ++-- tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp | 4 ++-- .../declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp | 4 ++-- .../declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp | 4 ++-- .../qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp | 4 ++-- .../qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp | 4 ++-- 55 files changed, 101 insertions(+), 55 deletions(-) create mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.json create mode 100644 examples/declarative/cppextensions/plugins/plugin.json create mode 100644 examples/declarative/cppextensions/qwidgets/qwidgets.json create mode 100644 examples/declarative/painteditem/textballoons/TextBalloonPlugin/textballoon.json create mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.json create mode 100644 examples/tutorials/gettingStartedQml/filedialog/dialogplugin.json create mode 100644 src/imports/folderlistmodel/folderlistmodel.json create mode 100644 src/imports/gestures/gestures.json create mode 100644 src/imports/localstorage/localstorage.json create mode 100644 src/imports/shaders/shaders.json create mode 100644 src/imports/testlib/testlib.json create mode 100644 src/imports/xmllistmodel/xmllistmodel.json create mode 100644 src/plugins/accessible/quick/accessible.json create mode 100644 src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.json create mode 100644 src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/empty.json diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.cpp b/examples/declarative/cppextensions/imageprovider/imageprovider.cpp index 94f85753ed..7fe4b72c08 100644 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.cpp +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.cpp @@ -87,6 +87,7 @@ public: class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "imageprovider.json") public: void registerTypes(const char *uri) { @@ -101,7 +102,8 @@ public: }; -#include "imageprovider.moc" -Q_EXPORT_PLUGIN(ImageProviderExtensionPlugin); +#define QDeclarativeExtensionInterface_iid "org.qt-project.Qt.QDeclarativeExtensionInterface" + +#include "imageprovider.moc" diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.json b/examples/declarative/cppextensions/imageprovider/imageprovider.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.json @@ -0,0 +1 @@ +{} diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/cppextensions/imageprovider/imageprovider.pro index cfa7923128..dd128d56a8 100644 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.pro +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.pro @@ -7,6 +7,8 @@ TARGET = qmlimageproviderplugin SOURCES += imageprovider.cpp +OTHER_FILES += imageprovider.json + sources.files = $$SOURCES imageprovider.qml imageprovider.pro sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider diff --git a/examples/declarative/cppextensions/plugins/plugin.cpp b/examples/declarative/cppextensions/plugins/plugin.cpp index 6fbf962f4e..4ba0a928eb 100644 --- a/examples/declarative/cppextensions/plugins/plugin.cpp +++ b/examples/declarative/cppextensions/plugins/plugin.cpp @@ -141,6 +141,8 @@ MinuteTimer *TimeModel::timer=0; class QExampleQmlPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "plugin.json") + public: void registerTypes(const char *uri) { @@ -151,7 +153,3 @@ public: //![plugin] #include "plugin.moc" - -//![export] -Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin); -//![export] diff --git a/examples/declarative/cppextensions/plugins/plugin.json b/examples/declarative/cppextensions/plugins/plugin.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/declarative/cppextensions/plugins/plugin.json @@ -0,0 +1 @@ +{} diff --git a/examples/declarative/cppextensions/plugins/plugins.pro b/examples/declarative/cppextensions/plugins/plugins.pro index bdcb62ca8a..a28582a07a 100644 --- a/examples/declarative/cppextensions/plugins/plugins.pro +++ b/examples/declarative/cppextensions/plugins/plugins.pro @@ -7,6 +7,8 @@ TARGET = qmlqtimeexampleplugin SOURCES += plugin.cpp +OTHER_FILES += "plugin.json" + qdeclarativesources.files += \ com/nokia/TimeExample/qmldir \ com/nokia/TimeExample/center.png \ diff --git a/examples/declarative/cppextensions/qwidgets/qwidgets.json b/examples/declarative/cppextensions/qwidgets/qwidgets.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/declarative/cppextensions/qwidgets/qwidgets.json @@ -0,0 +1 @@ +{} diff --git a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h index 6be8611dfd..f444d31f4e 100644 --- a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h +++ b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h @@ -46,11 +46,10 @@ class TextBalloonPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "textballoon.json") public: void registerTypes(const char *uri) { qmlRegisterType(uri, 1, 0, "TextBalloon"); } }; - -Q_EXPORT_PLUGIN2(qmltextballoonplugin, TextBalloonPlugin); diff --git a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/textballoon.json b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/textballoon.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/textballoon.json @@ -0,0 +1 @@ +{} diff --git a/examples/declarative/painteditem/textballoons/textballoons.pro b/examples/declarative/painteditem/textballoons/textballoons.pro index 453a00336d..e0b9404f65 100644 --- a/examples/declarative/painteditem/textballoons/textballoons.pro +++ b/examples/declarative/painteditem/textballoons/textballoons.pro @@ -9,6 +9,8 @@ HEADERS += TextBalloonPlugin/plugin.h \ SOURCES += textballoon.cpp +OTHER_FILES += textballoon.json + DESTDIR = TextBalloonPlugin qdeclarativesources.files += \ diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp index 9c4027de8a..d75f810964 100644 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp +++ b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp @@ -49,6 +49,5 @@ void ChartsPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 1, 0, "PieSlice"); } -Q_EXPORT_PLUGIN2(chartsplugin, ChartsPlugin); //![0] diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h index bffcf000fd..863564b09c 100644 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h +++ b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h @@ -46,6 +46,8 @@ class ChartsPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "chartsplugin.json") + public: void registerTypes(const char *uri); }; diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.json b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.json @@ -0,0 +1 @@ +{} diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp index 6bc3d4d006..626ef93adc 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp +++ b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.cpp @@ -49,6 +49,3 @@ void DialogPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 1, 0, "Directory"); qmlRegisterType(uri,1,0,"File"); } - -//FileDialog is the plugin name (same as the TARGET in the project file) and DialogPlugin is the plugin classs -Q_EXPORT_PLUGIN2(FileDialog, DialogPlugin); \ No newline at end of file diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h index 03bdc1a6e4..7ad707f6d9 100644 --- a/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h +++ b/examples/tutorials/gettingStartedQml/filedialog/dialogPlugin.h @@ -46,6 +46,7 @@ class DialogPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "dialogplugin.json") public: //registerTypes is inherited from QDeclarativeExtensionPlugin diff --git a/examples/tutorials/gettingStartedQml/filedialog/dialogplugin.json b/examples/tutorials/gettingStartedQml/filedialog/dialogplugin.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/tutorials/gettingStartedQml/filedialog/dialogplugin.json @@ -0,0 +1 @@ +{} diff --git a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h index aa1c8aa0f1..e78657a73d 100644 --- a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h +++ b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h @@ -75,7 +75,9 @@ public: virtual bool waitForMessage() = 0; }; -Q_DECLARE_INTERFACE(QDeclarativeDebugServerConnection, "com.trolltech.Qt.QDeclarativeDebugServerConnection/1.0") +#define QDeclarativeDebugServerConnection_iid "org.qt-project.Qt.QDeclarativeDebugServerConnection" + +Q_DECLARE_INTERFACE(QDeclarativeDebugServerConnection, QDeclarativeDebugServerConnection_iid) QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h index e109fc015e..adfd94333d 100644 --- a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h +++ b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h @@ -74,7 +74,9 @@ public: virtual void clientMessage(const QByteArray &message) = 0; }; -Q_DECLARE_INTERFACE(QDeclarativeInspectorInterface, "com.trolltech.Qt.QDeclarativeInspectorInterface/1.0") +#define QDeclarativeInspectorInterface_iid "org.qt-project.Qt." + +Q_DECLARE_INTERFACE(QDeclarativeInspectorInterface, QDeclarativeInspectorInterface_iid) QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeextensioninterface.h b/src/declarative/qml/qdeclarativeextensioninterface.h index fcfaa7c402..ce2560cec0 100644 --- a/src/declarative/qml/qdeclarativeextensioninterface.h +++ b/src/declarative/qml/qdeclarativeextensioninterface.h @@ -65,8 +65,13 @@ public: virtual void initializeEngine(QDeclarativeEngine *engine, const char *uri) = 0; }; +#define QDeclarativeTypesExtensionInterface_iid "org.qt-project.Qt.QDeclarativeTypesExtensionInterface" + Q_DECLARE_INTERFACE(QDeclarativeTypesExtensionInterface, "org.qt-project.Qt.QDeclarativeTypesExtensionInterface/1.0") -Q_DECLARE_INTERFACE(QDeclarativeExtensionInterface, "org.qt-project.Qt.QDeclarativeExtensionInterface/1.0") + +#define QDeclarativeExtensionInterface_iid "org.qt-project.Qt.QDeclarativeExtensionInterface" + +Q_DECLARE_INTERFACE(QDeclarativeExtensionInterface, QDeclarativeExtensionInterface_iid) QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativepropertyvalueinterceptor_p.h b/src/declarative/qml/qdeclarativepropertyvalueinterceptor_p.h index ed5e54f646..939c45b6d4 100644 --- a/src/declarative/qml/qdeclarativepropertyvalueinterceptor_p.h +++ b/src/declarative/qml/qdeclarativepropertyvalueinterceptor_p.h @@ -66,7 +66,10 @@ public: virtual void setTarget(const QDeclarativeProperty &property) = 0; virtual void write(const QVariant &value) = 0; }; -Q_DECLARE_INTERFACE(QDeclarativePropertyValueInterceptor, "com.trolltech.qml.QDeclarativePropertyValueInterceptor") + +#define QDeclarativePropertyValueInterceptor_iid "org.qt-project.Qt.QDeclarativePropertyValueInterceptor" + +Q_DECLARE_INTERFACE(QDeclarativePropertyValueInterceptor, QDeclarativePropertyValueInterceptor_iid) QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativepropertyvaluesource.h b/src/declarative/qml/qdeclarativepropertyvaluesource.h index 4189cae345..d345319143 100644 --- a/src/declarative/qml/qdeclarativepropertyvaluesource.h +++ b/src/declarative/qml/qdeclarativepropertyvaluesource.h @@ -57,7 +57,10 @@ public: virtual ~QDeclarativePropertyValueSource(); virtual void setTarget(const QDeclarativeProperty &) = 0; }; -Q_DECLARE_INTERFACE(QDeclarativePropertyValueSource, "com.trolltech.qml.QDeclarativePropertyValueSource") + +#define QDeclarativePropertyValueSource_iid "org.qt-project.Qt.QDeclarativePropertyValueSource" + +Q_DECLARE_INTERFACE(QDeclarativePropertyValueSource, QDeclarativePropertyValueSource_iid) QT_END_NAMESPACE diff --git a/src/imports/folderlistmodel/folderlistmodel.json b/src/imports/folderlistmodel/folderlistmodel.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/src/imports/folderlistmodel/folderlistmodel.json @@ -0,0 +1 @@ +{} diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp index 48d7b5b7cb..767f8f6c68 100644 --- a/src/imports/folderlistmodel/plugin.cpp +++ b/src/imports/folderlistmodel/plugin.cpp @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE class QmlFolderListModelPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "folderlistmodel.json") + public: virtual void registerTypes(const char *uri) { @@ -64,8 +66,3 @@ public: QT_END_NAMESPACE #include "plugin.moc" - -//![plugin export decl] -Q_EXPORT_PLUGIN2(qmlfolderlistmodelplugin, QT_PREPEND_NAMESPACE(QmlFolderListModelPlugin)); -//![plugin export decl] - diff --git a/src/imports/gestures/gestures.json b/src/imports/gestures/gestures.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/src/imports/gestures/gestures.json @@ -0,0 +1 @@ +{} diff --git a/src/imports/localstorage/localstorage.json b/src/imports/localstorage/localstorage.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/src/imports/localstorage/localstorage.json @@ -0,0 +1 @@ +{} diff --git a/src/imports/localstorage/localstorage.pro b/src/imports/localstorage/localstorage.pro index 51a69aac4f..5164e8870d 100644 --- a/src/imports/localstorage/localstorage.pro +++ b/src/imports/localstorage/localstorage.pro @@ -6,10 +6,12 @@ QT += sql declarative declarative-private v8-private core-private SOURCES += plugin.cpp +OTHER_FILES += localstorage.json + DESTDIR = $$QT.declarative.imports/$$TARGETPATH target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH qmldir.files += $$PWD/qmldir qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH -INSTALLS += target qmldir \ No newline at end of file +INSTALLS += target qmldir diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index dd747d0d09..0ab47c1428 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -651,6 +651,8 @@ static QObject *module_api_factory(QDeclarativeEngine *engine, QJSEngine *script class QDeclarativeLocalStoragePlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "localstorage.json") + public: QDeclarativeLocalStoragePlugin() { @@ -664,5 +666,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, QDeclarativeLocalStoragePlugin); diff --git a/src/imports/shaders/shaders.json b/src/imports/shaders/shaders.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/src/imports/shaders/shaders.json @@ -0,0 +1 @@ +{} diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp index 672de10639..ec32d7c9ab 100644 --- a/src/imports/testlib/main.cpp +++ b/src/imports/testlib/main.cpp @@ -135,6 +135,8 @@ QT_BEGIN_NAMESPACE class QTestQmlModule : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "testlib.json") + public: virtual void registerTypes(const char *uri) { @@ -152,5 +154,3 @@ public: QT_END_NAMESPACE #include "main.moc" - -Q_EXPORT_PLUGIN2(qmltestplugin, QT_PREPEND_NAMESPACE(QTestQmlModule)) diff --git a/src/imports/testlib/testlib.json b/src/imports/testlib/testlib.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/src/imports/testlib/testlib.json @@ -0,0 +1 @@ +{} diff --git a/src/imports/testlib/testlib.pro b/src/imports/testlib/testlib.pro index 3b8a5bf75e..7e8f601468 100644 --- a/src/imports/testlib/testlib.pro +++ b/src/imports/testlib/testlib.pro @@ -7,7 +7,8 @@ CONFIG += qt plugin QT += declarative quick qmltest qmltest-private v8-private declarative-private core-private testlib SOURCES += main.cpp -HEADERS += + +OTHER_FILES += testlib.json DESTDIR = $$QT.declarative.imports/$$TARGETPATH diff --git a/src/imports/xmllistmodel/plugin.cpp b/src/imports/xmllistmodel/plugin.cpp index 9085a60885..07f59b846a 100644 --- a/src/imports/xmllistmodel/plugin.cpp +++ b/src/imports/xmllistmodel/plugin.cpp @@ -49,6 +49,8 @@ QT_BEGIN_NAMESPACE class QmlXmlListModelPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "xmllistmodel.json") + public: virtual void registerTypes(const char *uri) { @@ -61,5 +63,3 @@ public: QT_END_NAMESPACE #include "plugin.moc" - -Q_EXPORT_PLUGIN2(qmlxmllistmodelplugin, QT_PREPEND_NAMESPACE(QmlXmlListModelPlugin)); diff --git a/src/imports/xmllistmodel/xmllistmodel.json b/src/imports/xmllistmodel/xmllistmodel.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/src/imports/xmllistmodel/xmllistmodel.json @@ -0,0 +1 @@ +{} diff --git a/src/plugins/accessible/quick/accessible.json b/src/plugins/accessible/quick/accessible.json new file mode 100644 index 0000000000..845a45aa78 --- /dev/null +++ b/src/plugins/accessible/quick/accessible.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "QQuickView", "QQuickItem" ] +} diff --git a/src/plugins/accessible/quick/main.cpp b/src/plugins/accessible/quick/main.cpp index 08a5fe546b..af9555c690 100644 --- a/src/plugins/accessible/quick/main.cpp +++ b/src/plugins/accessible/quick/main.cpp @@ -59,6 +59,9 @@ QT_BEGIN_NAMESPACE class AccessibleQuickFactory : public QAccessiblePlugin { + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QAccessibleFactoryInterface" FILE "accessible.json") + public: AccessibleQuickFactory(); @@ -105,9 +108,8 @@ QAccessibleInterface *AccessibleQuickFactory::create(const QString &classname, Q return 0; } -Q_EXPORT_STATIC_PLUGIN(AccessibleQuickFactory) -Q_EXPORT_PLUGIN2(qtaccessiblequick, AccessibleQuickFactory) - QT_END_NAMESPACE +#include "main.moc" + #endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/quick/quick.pro b/src/plugins/accessible/quick/quick.pro index 97a1d50098..add275a815 100644 --- a/src/plugins/accessible/quick/quick.pro +++ b/src/plugins/accessible/quick/quick.pro @@ -19,5 +19,7 @@ SOURCES += \ HEADERS += \ qaccessiblequickview.h \ qaccessiblequickitem.h + +OTHERFILES += accessible.json } diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro b/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro index b9c6584afc..24efee8725 100644 --- a/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro +++ b/src/plugins/qmltooling/qmldbg_qtquick2/qmldbg_qtquick2.pro @@ -27,5 +27,7 @@ HEADERS += \ ../shared/qdeclarativeinspectorprotocol.h \ ../shared/qmlinspectorconstants.h +OTHER_FILES += qtquick2plugin.json + target.path += $$[QT_INSTALL_PLUGINS]/qmltooling INSTALLS += target diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp index 206d0b2eb9..1245a7e690 100644 --- a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp +++ b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.cpp @@ -84,5 +84,3 @@ void QtQuick2Plugin::clientMessage(const QByteArray &message) } // namespace QtQuick2 } // namespace QmlJSDebugger - -Q_EXPORT_PLUGIN2(qmldbg_qtquick2, QmlJSDebugger::QtQuick2::QtQuick2Plugin) diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h index d0f814c03c..f6f668d6b4 100644 --- a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h +++ b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.h @@ -55,6 +55,7 @@ class QtQuick2Plugin : public QObject, public QDeclarativeInspectorInterface { Q_OBJECT Q_DISABLE_COPY(QtQuick2Plugin) + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeInspectorInterface" FILE "qtquick2plugin.json") Q_INTERFACES(QDeclarativeInspectorInterface) public: diff --git a/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.json b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.json new file mode 100644 index 0000000000..311847daa5 --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_qtquick2/qtquick2plugin.json @@ -0,0 +1,2 @@ +{} + diff --git a/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro index 8ab507c055..075cc49ae5 100644 --- a/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro +++ b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro @@ -14,5 +14,7 @@ SOURCES += \ HEADERS += \ qtcpserverconnection.h +OTHER_FILES += qtcpserverconnection.json + target.path += $$[QT_INSTALL_PLUGINS]/qmltooling INSTALLS += target diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp index 529d2094bf..216c2c30b1 100644 --- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp +++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp @@ -193,7 +193,5 @@ void QTcpServerConnection::invalidPacket() qWarning("QDeclarativeDebugServer: Received a corrupted packet! Giving up ..."); } -Q_EXPORT_PLUGIN2(tcpserver, QTcpServerConnection) - QT_END_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h index f090c9709f..1154a0aa25 100644 --- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h +++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h @@ -54,9 +54,9 @@ class QTcpServerConnection : public QObject, public QDeclarativeDebugServerConne Q_OBJECT Q_DECLARE_PRIVATE(QTcpServerConnection) Q_DISABLE_COPY(QTcpServerConnection) + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeDebugServerConnection" FILE "qtcpserverconnection.json") Q_INTERFACES(QDeclarativeDebugServerConnection) - public: QTcpServerConnection(); ~QTcpServerConnection(); diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json @@ -0,0 +1 @@ +{} diff --git a/src/quick/items/qquickvisualadaptormodel_p.h b/src/quick/items/qquickvisualadaptormodel_p.h index 9ae8325450..e431f3aa26 100644 --- a/src/quick/items/qquickvisualadaptormodel_p.h +++ b/src/quick/items/qquickvisualadaptormodel_p.h @@ -121,7 +121,9 @@ public: virtual QObject *proxiedObject() = 0; }; -Q_DECLARE_INTERFACE(QQuickVisualAdaptorModelProxyInterface, "com.trolltech.qml.QQuickVisualAdaptorModelProxyInterface") +#define QQuickVisualAdaptorModelProxyInterface_iid "org.qt-project.Qt.QQuickVisualAdaptorModelProxyInterface" + +Q_DECLARE_INTERFACE(QQuickVisualAdaptorModelProxyInterface, QQuickVisualAdaptorModelProxyInterface_iid) QT_END_NAMESPACE diff --git a/src/quick/scenegraph/qsgcontextplugin_p.h b/src/quick/scenegraph/qsgcontextplugin_p.h index 081e64ecdd..6080c8b394 100644 --- a/src/quick/scenegraph/qsgcontextplugin_p.h +++ b/src/quick/scenegraph/qsgcontextplugin_p.h @@ -62,7 +62,7 @@ struct Q_QUICK_EXPORT QSGContextFactoryInterface : public QFactoryInterface }; #define QSGContextFactoryInterface_iid \ - "com.trolltech.Qt.QSGContextFactoryInterface" + "org.qt-project.Qt.QSGContextFactoryInterface" Q_DECLARE_INTERFACE(QSGContextFactoryInterface, QSGContextFactoryInterface_iid) class Q_QUICK_EXPORT QSGContextPlugin : public QObject, public QSGContextFactoryInterface diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h index 4a37139056..ec0c185123 100644 --- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h +++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h @@ -67,7 +67,8 @@ public: }; QT_BEGIN_NAMESPACE -Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface"); +#define MyInterface_iid "org.qt-project.Qt.Test.MyInterface" +Q_DECLARE_INTERFACE(MyInterface, MyInterface_iid); QT_END_NAMESPACE QML_DECLARE_INTERFACE(MyInterface); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/empty.json b/tests/auto/declarative/qdeclarativemoduleplugin/empty.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/empty.json @@ -0,0 +1 @@ +{} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp index 27e0beb4be..a8a0f69a3a 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp @@ -66,6 +66,8 @@ private: class MyPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -80,5 +82,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp index 904664ee0e..c67b5b1b63 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp @@ -66,6 +66,8 @@ private: class MyPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -80,5 +82,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp index 267535dd74..869630bd63 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp @@ -65,6 +65,8 @@ private: class MyPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -79,5 +81,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp index 0052c6ee53..51e48781f6 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp @@ -56,6 +56,8 @@ public: class MyMixedPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyMixedPlugin() { @@ -69,5 +71,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp index 6fc6eee1c7..ab8b3d479e 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp @@ -56,6 +56,8 @@ public: class MyMixedPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyMixedPlugin() { @@ -69,5 +71,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp index 7cb0365abe..88b807e14d 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp @@ -46,6 +46,8 @@ class MyPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: void registerTypes(const char *uri) { @@ -54,5 +56,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp index 2446c93bf9..fe110a28d4 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp @@ -65,6 +65,8 @@ private: class MyPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "../empty.json") + public: MyPlugin() { @@ -79,5 +81,3 @@ public: }; #include "plugin.moc" - -Q_EXPORT_PLUGIN2(plugin, MyPlugin); -- cgit v1.2.3 From 7e76d66f526de98804f01771ca0fea1ade7b6677 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 23 Feb 2012 08:51:36 +0000 Subject: Fix crash in instruction dump Change-Id: I2cfa9da120a602b52f401dd304b44cd17c47b220 Reviewed-by: Alan Alpert Reviewed-by: Roberto Raggi --- src/declarative/qml/qdeclarativeinstruction.cpp | 4 ++-- .../qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp index 799357cf04..8c9198007e 100644 --- a/src/declarative/qml/qdeclarativeinstruction.cpp +++ b/src/declarative/qml/qdeclarativeinstruction.cpp @@ -190,7 +190,7 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx) qWarning().nospace() << idx << "\t\t" << "STORE_INTERFACE\t\t" << instr->storeObject.propertyIndex; break; case QDeclarativeInstruction::StoreSignal: - qWarning().nospace() << idx << "\t\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value << "\t\t" << primitives.at(instr->storeSignal.value); + qWarning().nospace() << idx << "\t\t" << "STORE_SIGNAL\t\t" << instr->storeSignal.signalIndex << "\t" << instr->storeSignal.value; break; case QDeclarativeInstruction::StoreImportedScript: qWarning().nospace() << idx << "\t\t" << "STORE_IMPORTED_SCRIPT\t" << instr->storeScript.value; @@ -199,7 +199,7 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx) qWarning().nospace() << idx << "\t\t" << "STORE_SCRIPT_STRING\t" << instr->storeScriptString.propertyIndex << "\t" << instr->storeScriptString.value << "\t" << instr->storeScriptString.scope << "\t" << instr->storeScriptString.bindingId; break; case QDeclarativeInstruction::AssignSignalObject: - qWarning().nospace() << idx << "\t\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal << "\t\t\t" << primitives.at(instr->assignSignalObject.signal); + qWarning().nospace() << idx << "\t\t" << "ASSIGN_SIGNAL_OBJECT\t" << instr->assignSignalObject.signal; break; case QDeclarativeInstruction::AssignCustomType: qWarning().nospace() << idx << "\t\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.primitive << "\t" << instr->assignCustomType.type; diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp index 072718a95c..769d385efc 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp +++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp @@ -499,9 +499,9 @@ void tst_qdeclarativeinstruction::dump() << "24\t\tSTORE_OBJECT\t\t21" << "25\t\tSTORE_VARIANT_OBJECT\t22" << "26\t\tSTORE_INTERFACE\t\t23" - << "27\t\tSTORE_SIGNAL\t\t2\t3\t\t\"console.log(1921)\"" + << "27\t\tSTORE_SIGNAL\t\t2\t3" << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t4" - << "29\t\tASSIGN_SIGNAL_OBJECT\t4\t\t\t\"mySignal\"" + << "29\t\tASSIGN_SIGNAL_OBJECT\t4" << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9" << "31\t\tSTORE_BINDING\t26\t3\t2" << "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4" -- cgit v1.2.3 From 212204b4fff05aed43a931e71855948ec9910b59 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Mon, 20 Feb 2012 14:46:26 +0100 Subject: Fix rewrite of multiline string literals. This commits ensures that we don't rewrite `\'-terminated multiline string literals. Also, it fixes the processing of \r characters inside the string literals. Change-Id: If3d7c1b83c7306b9ccb1be31412b6f8e76434c41 Reviewed-by: Oswald Buddenhagen Reviewed-by: Aaron Kennedy --- .gitattributes | 1 + src/declarative/qml/qdeclarativerewrite.cpp | 123 +++++++++------------ src/declarative/qml/qdeclarativerewrite_p.h | 5 +- .../data/rewriteMultiLineStrings_crlf.1.qml | 13 +++ .../tst_qdeclarativeecmascript.cpp | 23 ++-- 5 files changed, 85 insertions(+), 80 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings_crlf.1.qml diff --git a/.gitattributes b/.gitattributes index a3c6108370..157176bdb8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ .tag ident +*_crlf.* eol=crlf diff --git a/src/declarative/qml/qdeclarativerewrite.cpp b/src/declarative/qml/qdeclarativerewrite.cpp index 77da943704..688e75a325 100644 --- a/src/declarative/qml/qdeclarativerewrite.cpp +++ b/src/declarative/qml/qdeclarativerewrite.cpp @@ -51,6 +51,45 @@ DEFINE_BOOL_CONFIG_OPTION(rewriteDump, QML_REWRITE_DUMP); namespace QDeclarativeRewrite { +static void rewriteStringLiteral(AST::StringLiteral *ast, const QString *code, int startPosition, TextWriter *writer) +{ + const unsigned position = ast->firstSourceLocation().begin() - startPosition + 1; + const unsigned length = ast->literalToken.length - 2; + const QStringRef spell = code->midRef(position, length); + const int end = spell.size(); + int index = 0; + + while (index < end) { + const QChar ch = spell.at(index++); + + if (index < end && ch == QLatin1Char('\\')) { + int pos = index; + + // skip a possibly empty sequence of \r characters + while (pos < end && spell.at(pos) == QLatin1Char('\r')) + ++pos; + + if (pos < end && spell.at(pos) == QLatin1Char('\n')) { + // This is a `\' followed by a newline terminator. + // In this case there's nothing to replace. We keep the code + // as it is and we resume the searching. + index = pos + 1; // refresh the index + } + } else if (ch == QLatin1Char('\r') || ch == QLatin1Char('\n')) { + const QString sep = ch == QLatin1Char('\r') ? QLatin1String("\\r") : QLatin1String("\\n"); + const int pos = index - 1; + QString s = sep; + + while (index < end && spell.at(index) == ch) { + s += sep; + ++index; + } + + writer->replace(position + pos, index - pos, s); + } + } +} + bool SharedBindingTester::isSharable(const QString &code) { Engine engine; @@ -204,40 +243,7 @@ bool RewriteBinding::visit(AST::ExpressionStatement *ast) bool RewriteBinding::visit(AST::StringLiteral *ast) { - /* When rewriting the code for bindings, we have to remove ILLEGAL JS tokens like newlines. - They're still in multi-line strings, because the QML parser allows them, but we have to - rewrite them to be JS compliant. - - For performance reasons, we don't go for total correctness. \r is only replaced if a - \n was found (since most line endings are \n or \r\n) and QChar::LineSeparator is not - even considered. QTBUG-24064. - - Note that rewriteSignalHandler has a function just like this one, for the same reason. - */ - - unsigned startOfString = ast->firstSourceLocation().begin() + 1 - _position; - unsigned stringLength = ast->firstSourceLocation().length - 2; - - int lastIndex = -1; - bool foundNewLine = false; - QStringRef subStr(_code, startOfString, stringLength); - while (true) { - lastIndex = subStr.indexOf(QLatin1Char('\n'), lastIndex + 1); - if (lastIndex == -1) - break; - foundNewLine = true; - _writer->replace(startOfString+lastIndex, 1, QLatin1String("\\n")); - } - - if (foundNewLine) { - while (true) { - lastIndex = subStr.indexOf(QLatin1Char('\r'), lastIndex + 1); - if (lastIndex == -1) - break; - _writer->replace(startOfString+lastIndex, 1, QLatin1String("\\r")); - } - } - + rewriteStringLiteral(ast, _code, _position, _writer); return false; } @@ -361,6 +367,13 @@ void RewriteBinding::rewriteCaseStatements(AST::StatementList *statements, bool } } +RewriteSignalHandler::RewriteSignalHandler() + : _writer(0) + , _code(0) + , _position(0) +{ +} + void RewriteSignalHandler::accept(AST::Node *node) { AST::Node::acceptChild(node, this); @@ -368,42 +381,10 @@ void RewriteSignalHandler::accept(AST::Node *node) bool RewriteSignalHandler::visit(AST::StringLiteral *ast) { - unsigned startOfExpressionStatement = ast->firstSourceLocation().begin() - _position; - _strStarts << startOfExpressionStatement + 1; - _strLens << ast->firstSourceLocation().length - 2; - + rewriteStringLiteral(ast, _code, _position, _writer); return false; } -void RewriteSignalHandler::rewriteMultilineStrings(QString &code) -{ - QList replaceR, replaceN; - for (int i=0; i < _strStarts.count(); i++) { - QStringRef curSubstr = QStringRef(&code, _strStarts[i], _strLens[i]); - int lastIndex = -1; - while (true) { - lastIndex = curSubstr.indexOf(QLatin1Char('\n'), lastIndex + 1); - if (lastIndex == -1) - break; - replaceN << _strStarts[i]+lastIndex; - } - - if (replaceN.count()) { - while (true) { - lastIndex = curSubstr.indexOf(QLatin1Char('\r'), lastIndex + 1); - if (lastIndex == -1) - break; - replaceR << _strStarts[i]+lastIndex; - } - } - } - for (int ii = replaceN.count() - 1; ii >= 0; ii--) - code.replace(replaceN[ii], 1, QLatin1String("\\n")); - if (replaceR.count()) - for (int ii = replaceR.count() - 1; ii >= 0; ii--) - code.replace(replaceR[ii], 1, QLatin1String("\\r")); -} - QString RewriteSignalHandler::operator()(QDeclarativeJS::AST::Node *node, const QString &code, const QString &name) { if (rewriteDump()) { @@ -417,13 +398,15 @@ QString RewriteSignalHandler::operator()(QDeclarativeJS::AST::Node *node, const if (!expression && !statement) return code; - _strStarts.clear(); - _strLens.clear(); + TextWriter w; + _writer = &w; + _code = &code; + _position = expression ? expression->firstSourceLocation().begin() : statement->firstSourceLocation().begin(); accept(node); QString rewritten = code; - rewriteMultilineStrings(rewritten); + w.write(&rewritten); rewritten = QStringLiteral("(function ") + name + QStringLiteral("() { ") + rewritten + QStringLiteral(" })"); diff --git a/src/declarative/qml/qdeclarativerewrite_p.h b/src/declarative/qml/qdeclarativerewrite_p.h index 74c408cd21..7d73e6a132 100644 --- a/src/declarative/qml/qdeclarativerewrite_p.h +++ b/src/declarative/qml/qdeclarativerewrite_p.h @@ -126,11 +126,12 @@ private: class RewriteSignalHandler: protected AST::Visitor { - QList _strStarts; - QList _strLens; + TextWriter *_writer; + const QString *_code; int _position; public: + RewriteSignalHandler(); QString operator()(QDeclarativeJS::AST::Node *node, const QString &code, const QString &name); protected: diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings_crlf.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings_crlf.1.qml new file mode 100644 index 0000000000..f84ba8c722 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings_crlf.1.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Rectangle { + id: root + + Component.onCompleted: { + var o = Qt.createQmlObject("import QtQuick 2.0; \ + \ + Item { \ + property bool b: true; \ + }", root, "Instance") + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index d30766f982..cc94e6fb4a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -1570,8 +1570,6 @@ void tst_qdeclarativeecmascript::compileInvalidBinding() { // QTBUG-23387: ensure that invalid bindings don't cause a crash. QDeclarativeComponent component(&engine, testFileUrl("v8bindingException.qml")); - QString warning = component.url().toString() + ":16: SyntaxError: Unexpected token ILLEGAL"; - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); QObject *object = component.create(); QVERIFY(object != 0); delete object; @@ -5287,12 +5285,21 @@ void tst_qdeclarativeecmascript::qtbug_21864() void tst_qdeclarativeecmascript::rewriteMultiLineStrings() { - // QTBUG-23387 - QDeclarativeComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml")); - QObject *o = component.create(); - QVERIFY(o != 0); - QTRY_COMPARE(o->property("test").toBool(), true); - delete o; + { + // QTBUG-23387 + QDeclarativeComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QTRY_COMPARE(o->property("test").toBool(), true); + delete o; + } + + { + QDeclarativeComponent component(&engine, testFileUrl("rewriteMultiLineStrings_crlf.1.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + delete o; + } } void tst_qdeclarativeecmascript::qobjectConnectionListExceptionHandling() -- cgit v1.2.3 From 8efc0ba05023654b6640a6050a4952becca4d68f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Feb 2012 00:34:32 +0100 Subject: Remove use of QT_ASCII_CAST_WARN_CONSTRUCTOR. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes build after I0b4df4c99600cacbaafbf0bc4270cd4978600956 Change-Id: I9cf326b52e0e7e267b8fbc422175713cee9352f5 Reviewed-by: Jędrzej Nowacki --- src/declarative/qml/v8/qjsvalue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/v8/qjsvalue.h b/src/declarative/qml/v8/qjsvalue.h index bfe0ec0951..07fe3dcfac 100644 --- a/src/declarative/qml/v8/qjsvalue.h +++ b/src/declarative/qml/v8/qjsvalue.h @@ -68,7 +68,7 @@ public: QJSValue(const QString &value); QJSValue(const QLatin1String &value); #ifndef QT_NO_CAST_FROM_ASCII - QT_ASCII_CAST_WARN_CONSTRUCTOR QJSValue(const char *str); + QT_ASCII_CAST_WARN QJSValue(const char *str); #endif QJSValue &operator=(const QJSValue &other); -- cgit v1.2.3 From 5fee1e79cc1c18acf58f9171a73a7525154a65cd Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 23 Feb 2012 14:11:48 +1000 Subject: Use floating point types for position offsets and cursorRectangle. Rounding to align painting to pixel boundaries is no longer necessary are largely removed. Correct the few instances remaining in TextEdit and TextInput. Change-Id: Ic6ec57092d74ec43b23d85cd8868e0190acc3e09 Reviewed-by: Yann Bodson --- src/quick/items/qquicktextedit.cpp | 22 +++---- src/quick/items/qquicktextedit_p.h | 6 +- src/quick/items/qquicktextedit_p_p.h | 8 +-- src/quick/items/qquicktextinput.cpp | 42 ++++++------ src/quick/items/qquicktextinput_p.h | 4 +- src/quick/items/qquicktextinput_p_p.h | 13 ++-- .../qtquick2/qquicktextedit/tst_qquicktextedit.cpp | 38 +++++------ .../qquicktextinput/tst_qquicktextinput.cpp | 77 +++++++++++----------- 8 files changed, 102 insertions(+), 108 deletions(-) diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 06264715a1..66285fcd2b 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -732,10 +732,10 @@ QRectF QQuickTextEdit::positionToRectangle(int pos) const Position 0 is before the first character, position 1 is after the first character but before the second, and so on until position \l {text}.length, which is after all characters. */ -int QQuickTextEdit::positionAt(int x, int y) const +int QQuickTextEdit::positionAt(qreal x, qreal y) const { Q_D(const QQuickTextEdit); - int r = d->document->documentLayout()->hitTest(QPoint(x,y-d->yoff), Qt::FuzzyHit); + int r = d->document->documentLayout()->hitTest(QPointF(x,y-d->yoff), Qt::FuzzyHit); QTextCursor cursor = d->control->textCursor(); if (r > cursor.position()) { // The cursor position includes positions within the preedit text, but only positions in the @@ -1290,10 +1290,10 @@ Qt::TextInteractionFlags QQuickTextEdit::textInteractionFlags() const automatically when it changes. The width of the delegate is unaffected by changes in the cursor rectangle. */ -QRect QQuickTextEdit::cursorRectangle() const +QRectF QQuickTextEdit::cursorRectangle() const { Q_D(const QQuickTextEdit); - return d->control->cursorRect().toRect().translated(0,d->yoff); + return d->control->cursorRect().translated(0, d->yoff); } bool QQuickTextEdit::event(QEvent *event) @@ -1863,11 +1863,11 @@ void QQuickTextEdit::updateSize() } else { d->document->setTextWidth(-1); } - QFontMetrics fm = QFontMetrics(d->font); - int dy = height(); - dy -= (int)d->document->size().height(); + QFontMetricsF fm(d->font); + qreal dy = height(); + dy -= d->document->size().height(); - int nyoff; + qreal nyoff; if (heightValid()) { if (d->vAlign == AlignBottom) nyoff = dy; @@ -1883,7 +1883,7 @@ void QQuickTextEdit::updateSize() setBaselineOffset(fm.ascent() + d->yoff + d->textMargin); //### need to comfirm cost of always setting these - int newWidth = qCeil(d->document->idealWidth()); + qreal newWidth = d->document->idealWidth(); if (!widthValid() && d->document->textWidth() != newWidth) d->document->setTextWidth(newWidth); // ### Text does not align if width is not set (QTextDoc bug) // ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed. @@ -1892,13 +1892,13 @@ void QQuickTextEdit::updateSize() iWidth = newWidth; else if (d->requireImplicitWidth) iWidth = naturalWidth; - qreal newHeight = d->document->isEmpty() ? fm.height() : (int)d->document->size().height(); + qreal newHeight = d->document->isEmpty() ? fm.height() : d->document->size().height(); if (iWidth > -1) setImplicitSize(iWidth, newHeight); else setImplicitHeight(newHeight); - QSize size(newWidth, newHeight); + QSizeF size(newWidth, newHeight); if (d->contentSize != size) { d->contentSize = size; emit contentSizeChanged(); diff --git a/src/quick/items/qquicktextedit_p.h b/src/quick/items/qquicktextedit_p.h index 5f6317ab09..b3fd32af69 100644 --- a/src/quick/items/qquicktextedit_p.h +++ b/src/quick/items/qquicktextedit_p.h @@ -79,7 +79,7 @@ class Q_AUTOTEST_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged) Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged) Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged) - Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) + Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) Q_PROPERTY(QDeclarativeComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged) Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged) Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged) @@ -212,7 +212,7 @@ public: void setTextInteractionFlags(Qt::TextInteractionFlags flags); Qt::TextInteractionFlags textInteractionFlags() const; - QRect cursorRectangle() const; + QRectF cursorRectangle() const; QVariant inputMethodQuery(Qt::InputMethodQuery property) const; @@ -224,7 +224,7 @@ public: void resetBaseUrl(); Q_INVOKABLE QRectF positionToRectangle(int) const; - Q_INVOKABLE int positionAt(int x, int y) const; + Q_INVOKABLE int positionAt(qreal x, qreal y) const; Q_INVOKABLE void moveCursorSelection(int pos); Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode); diff --git a/src/quick/items/qquicktextedit_p_p.h b/src/quick/items/qquicktextedit_p_p.h index 1497c207ee..8ec589da29 100644 --- a/src/quick/items/qquicktextedit_p_p.h +++ b/src/quick/items/qquicktextedit_p_p.h @@ -69,8 +69,8 @@ class QQuickTextEditPrivate : public QQuickImplicitSizeItemPrivate public: QQuickTextEditPrivate() : color(QRgb(0xFF000000)), selectionColor(QRgb(0xFF000080)), selectedTextColor(QRgb(0xFFFFFFFF)) - , textMargin(0.0), font(sourceFont), cursorComponent(0), cursor(0), document(0), control(0) - , lastSelectionStart(0), lastSelectionEnd(0), lineCount(0), yoff(0) + , textMargin(0.0), yoff(0), font(sourceFont), cursorComponent(0), cursor(0), document(0), control(0) + , lastSelectionStart(0), lastSelectionEnd(0), lineCount(0) , hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop) , format(QQuickTextEdit::PlainText), wrapMode(QQuickTextEdit::NoWrap) , mouseSelectionMode(QQuickTextEdit::SelectCharacters), inputMethodHints(Qt::ImhNone) @@ -98,9 +98,10 @@ public: QColor selectionColor; QColor selectedTextColor; - QSize contentSize; + QSizeF contentSize; qreal textMargin; + qreal yoff; QString text; QUrl baseUrl; @@ -115,7 +116,6 @@ public: int lastSelectionStart; int lastSelectionEnd; int lineCount; - int yoff; enum UpdateType { UpdateNone, diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 9b11e2e43a..6f079dc045 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -677,7 +677,7 @@ void QQuickTextInput::setCursorPosition(int cp) cursor rectangle. */ -QRect QQuickTextInput::cursorRectangle() const +QRectF QQuickTextInput::cursorRectangle() const { Q_D(const QQuickTextInput); @@ -688,12 +688,8 @@ QRect QQuickTextInput::cursorRectangle() const c = 0; QTextLine l = d->m_textLayout.lineForTextPosition(c); if (!l.isValid()) - return QRect(); - return QRect( - qRound(l.cursorToX(c) - d->hscroll), - qRound(l.y() - d->vscroll), - 1, - qCeil(l.height())); + return QRectF(); + return QRectF(l.cursorToX(c) - d->hscroll, l.y() - d->vscroll, 1, l.height()); } /*! @@ -1368,7 +1364,7 @@ void QQuickTextInput::positionAt(QDeclarativeV8Function *args) const args->returnValue(v8::Int32::New(pos)); } -int QQuickTextInputPrivate::positionAt(int x, int y, QTextLine::CursorPosition position) const +int QQuickTextInputPrivate::positionAt(qreal x, qreal y, QTextLine::CursorPosition position) const { x += hscroll; y += vscroll; @@ -1432,7 +1428,7 @@ void QQuickTextInput::mouseDoubleClickEvent(QMouseEvent *event) d->selectWordAtPos(cursor); event->setAccepted(true); if (!d->hasPendingTripleClick()) { - d->tripleClickStartPoint = event->localPos().toPoint(); + d->tripleClickStartPoint = event->localPos(); d->tripleClickTimer.start(); } } else { @@ -1617,15 +1613,15 @@ void QQuickTextInputPrivate::updateHorizontalScroll() Q_Q(QQuickTextInput); QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor + m_preeditCursor); const int preeditLength = m_textLayout.preeditAreaText().length(); - const int width = qMax(0, qFloor(q->width())); - int widthUsed = currentLine.isValid() ? qRound(currentLine.naturalTextWidth()) : 0; + const qreal width = qMax(0, q->width()); + qreal widthUsed = currentLine.isValid() ? currentLine.naturalTextWidth() : 0; int previousScroll = hscroll; if (!autoScroll || widthUsed <= width || m_echoMode == QQuickTextInput::NoEcho) { hscroll = 0; } else { Q_ASSERT(currentLine.isValid()); - int cix = qRound(currentLine.cursorToX(m_cursor + preeditLength)); + qreal cix = currentLine.cursorToX(m_cursor + preeditLength); if (cix - hscroll >= width) { // text doesn't fit, cursor is to the right of br (scroll right) hscroll = cix - width; @@ -1640,7 +1636,7 @@ void QQuickTextInputPrivate::updateHorizontalScroll() if (preeditLength > 0) { // check to ensure long pre-edit text doesn't push the cursor // off to the left - cix = qRound(currentLine.cursorToX(m_cursor + qMax(0, m_preeditCursor - 1))); + cix = currentLine.cursorToX(m_cursor + qMax(0, m_preeditCursor - 1)); if (cix < hscroll) hscroll = cix; } @@ -1653,9 +1649,9 @@ void QQuickTextInputPrivate::updateVerticalScroll() { Q_Q(QQuickTextInput); const int preeditLength = m_textLayout.preeditAreaText().length(); - const int height = qMax(0, qFloor(q->height())); - int heightUsed = boundingRect.height(); - int previousScroll = vscroll; + const qreal height = qMax(0, q->height()); + qreal heightUsed = boundingRect.height(); + qreal previousScroll = vscroll; if (!autoScroll || heightUsed <= height) { // text fits in br; use vscroll for alignment @@ -1674,8 +1670,8 @@ void QQuickTextInputPrivate::updateVerticalScroll() } else { QTextLine currentLine = m_textLayout.lineForTextPosition(m_cursor + preeditLength); QRectF r = currentLine.isValid() ? currentLine.rect() : QRectF(); - int top = qFloor(r.top()); - int bottom = qCeil(r.bottom()); + qreal top = r.top(); + int bottom = r.bottom(); if (bottom - vscroll >= height) { // text doesn't fit, cursor is to the below the br (scroll down) @@ -1692,7 +1688,7 @@ void QQuickTextInputPrivate::updateVerticalScroll() // check to ensure long pre-edit text doesn't push the cursor // off the top currentLine = m_textLayout.lineForTextPosition(m_cursor + qMax(0, m_preeditCursor - 1)); - top = currentLine.isValid() ? qRound(currentLine.rect().top()) : 0; + top = currentLine.isValid() ? currentLine.rect().top() : 0; if (top < vscroll) vscroll = top; } @@ -1742,11 +1738,11 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData node->deleteContent(); node->setMatrix(QMatrix4x4()); - QPoint offset = QPoint(0,0); + QPointF offset(0, 0); if (d->autoScroll && d->m_textLayout.lineCount() > 0) { - QFontMetrics fm = QFontMetrics(d->font); + QFontMetricsF fm(d->font); // the y offset is there to keep the baseline constant in case we have script changes in the text. - offset = -QPoint(d->hscroll, d->vscroll + qRound(d->m_textLayout.lineAt(0).ascent()) - fm.ascent()); + offset = -QPoint(d->hscroll, d->vscroll + d->m_textLayout.lineAt(0).ascent() - fm.ascent()); } else { offset = -QPoint(d->hscroll, d->vscroll); } @@ -2732,7 +2728,7 @@ void QQuickTextInputPrivate::updateLayout() updateType = UpdatePaintNode; q->update(); - q->setImplicitSize(qCeil(boundingRect.width()), qCeil(boundingRect.height())); + q->setImplicitSize(boundingRect.width(), boundingRect.height()); if (previousRect != boundingRect) emit q->contentSizeChanged(); diff --git a/src/quick/items/qquicktextinput_p.h b/src/quick/items/qquicktextinput_p.h index 0e60cf6ce4..ebd3d58957 100644 --- a/src/quick/items/qquicktextinput_p.h +++ b/src/quick/items/qquicktextinput_p.h @@ -76,7 +76,7 @@ class Q_AUTOTEST_EXPORT QQuickTextInput : public QQuickImplicitSizeItem Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged) Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged) Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged) - Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) + Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) Q_PROPERTY(QDeclarativeComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged) Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged) Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged) @@ -195,7 +195,7 @@ public: int cursorPosition() const; void setCursorPosition(int cp); - QRect cursorRectangle() const; + QRectF cursorRectangle() const; int selectionStart() const; int selectionEnd() const; diff --git a/src/quick/items/qquicktextinput_p_p.h b/src/quick/items/qquicktextinput_p_p.h index e48b000e5c..1921451f88 100644 --- a/src/quick/items/qquicktextinput_p_p.h +++ b/src/quick/items/qquicktextinput_p_p.h @@ -77,14 +77,14 @@ class Q_AUTOTEST_EXPORT QQuickTextInputPrivate : public QQuickImplicitSizeItemPr Q_DECLARE_PUBLIC(QQuickTextInput) public: QQuickTextInputPrivate() - : cursorItem(0) + : hscroll(0) + , vscroll(0) + , cursorItem(0) , textNode(0) , m_maskData(0) , color(QRgb(0xFF000000)) , selectionColor(QRgb(0xFF000080)) , selectedTextColor(QRgb(0xFFFFFFFF)) - , hscroll(0) - , vscroll(0) , m_cursor(0) , m_preeditCursor(0) , m_blinkPeriod(0) @@ -179,6 +179,9 @@ public: QDeclarativeGuard m_validator; #endif + qreal hscroll; + qreal vscroll; + QTextLayout m_textLayout; QString m_text; QString m_inputMask; @@ -203,8 +206,6 @@ public: #endif int lastSelectionStart; int lastSelectionEnd; - int hscroll; - int vscroll; int m_cursor; int m_preeditCursor; int m_blinkPeriod; // 0 for non-blinking cursor @@ -295,7 +296,7 @@ public: int selectionStart() const { return hasSelectedText() ? m_selstart : -1; } int selectionEnd() const { return hasSelectedText() ? m_selend : -1; } - int positionAt(int x, int y, QTextLine::CursorPosition position) const; + int positionAt(qreal x, qreal y, QTextLine::CursorPosition position) const; int positionAt(const QPointF &point, QTextLine::CursorPosition position = QTextLine::CursorBetweenCharacters) const { return positionAt(point.x(), point.y(), position); } diff --git a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp index 62b85b8d24..e2673c1f17 100644 --- a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp @@ -461,10 +461,10 @@ void tst_qquicktextedit::width() layout.endLayout(); - qreal metricWidth = ceil(layout.boundingRect().width()); + qreal metricWidth = layout.boundingRect().width(); QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(metricWidth)); + QCOMPARE(textEditObject->width(), metricWidth); } for (int i = 0; i < richText.size(); i++) @@ -475,7 +475,7 @@ void tst_qquicktextedit::width() if (requiresUnhintedMetrics) document.setUseDesignMetrics(true); - int documentWidth = ceil(document.idealWidth()); + qreal documentWidth = document.idealWidth(); QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }"; QDeclarativeComponent texteditComponent(&engine); @@ -483,7 +483,7 @@ void tst_qquicktextedit::width() QQuickTextEdit *textEditObject = qobject_cast(texteditComponent.create()); QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(documentWidth)); + QCOMPARE(textEditObject->width(), documentWidth); } } @@ -1843,8 +1843,8 @@ void tst_qquicktextedit::cursorDelegate() //Test Delegate gets moved for (int i=0; i<= textEditObject->text().length(); i++) { textEditObject->setCursorPosition(i); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); } // Clear preedit text; QInputMethodEvent event; @@ -1858,8 +1858,8 @@ void tst_qquicktextedit::cursorDelegate() QTest::mouseClick(&view, Qt::LeftButton, 0, point1); QTest::qWait(50); QTRY_VERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); // Test delegate gets moved on mouse drag textEditObject->setCursorPosition(0); @@ -1869,27 +1869,27 @@ void tst_qquicktextedit::cursorDelegate() QGuiApplication::sendEvent(&view, &mv); QTest::mouseRelease(&view, Qt::LeftButton, 0, point2); QTest::qWait(50); - QTRY_COMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QTRY_COMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); textEditObject->setReadOnly(true); textEditObject->setCursorPosition(0); QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint()); QTest::qWait(50); QTRY_VERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); textEditObject->setCursorPosition(0); QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint()); QTest::qWait(50); QTRY_VERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); textEditObject->setCursorPosition(0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textEditObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textEditObject->cursorRectangle().y(), delegateObject->y()); //Test Delegate gets deleted textEditObject->setCursorDelegate(0); QVERIFY(!textEditObject->findChild("cursorInstance")); @@ -2582,14 +2582,14 @@ void tst_qquicktextedit::cursorRectangleSize() qApp->sendEvent(qApp->focusObject(), &event); QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF(); - QRect cursorRectFromItem = textEdit->cursorRectangle(); + QRectF cursorRectFromItem = textEdit->cursorRectangle(); QRectF cursorRectFromPositionToRectangle = textEdit->positionToRectangle(textEdit->cursorPosition()); // item and input query cursor rectangles match - QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect()); + QCOMPARE(cursorRectFromItem, cursorRectFromQuery); // item cursor rectangle and positionToRectangle calculations match - QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect()); + QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle); // item-canvas transform and input item transform match QCOMPARE(QQuickItemPrivate::get(textEdit)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform()); diff --git a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp index c1768bd98a..236b12002e 100644 --- a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp @@ -2341,12 +2341,12 @@ void tst_qquicktextinput::cursorDelegate() //Test Delegate gets moved for (int i=0; i<= textInputObject->text().length(); i++) { textInputObject->setCursorPosition(i); - QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y()); } textInputObject->setCursorPosition(0); - QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); + QCOMPARE(textInputObject->cursorRectangle().x(), delegateObject->x()); + QCOMPARE(textInputObject->cursorRectangle().y(), delegateObject->y()); //Test Delegate gets deleted textInputObject->setCursorDelegate(0); QVERIFY(!textInputObject->findChild("cursorInstance")); @@ -2404,9 +2404,6 @@ void tst_qquicktextinput::cursorVisible() QCOMPARE(spy.count(), 7); } -static QRect round(const QRectF &r) { - return QRect(qRound(r.left()), qRound(r.top()), qCeil(r.width()), qCeil(r.height())); } - void tst_qquicktextinput::cursorRectangle() { @@ -2430,7 +2427,7 @@ void tst_qquicktextinput::cursorRectangle() input.setWidth(line.cursorToX(5, QTextLine::Leading)); input.setHeight(qCeil(line.height() * 3 / 2)); - QRect r; + QRectF r; // some tolerance for different fonts. #ifdef Q_OS_LINUX @@ -2445,28 +2442,28 @@ void tst_qquicktextinput::cursorRectangle() QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } // Check the cursor rectangle remains within the input bounding rect when auto scrolling. - QVERIFY(r.left() < input.width()); + QVERIFY(r.left() < input.width() + error); QVERIFY(r.right() >= input.width() - error); for (int i = 6; i < text.length(); ++i) { input.setCursorPosition(i); QCOMPARE(r, input.cursorRectangle()); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } for (int i = text.length() - 2; i >= 0; --i) { input.setCursorPosition(i); r = input.cursorRectangle(); - QCOMPARE(r.top(), 0); + QCOMPARE(r.top(), 0.); QVERIFY(r.right() >= 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } // Check position with word wrap. @@ -2478,24 +2475,24 @@ void tst_qquicktextinput::cursorRectangle() QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); - QCOMPARE(r.top(), 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(r.top(), 0.); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } input.setCursorPosition(6); r = input.cursorRectangle(); - QCOMPARE(r.left(), 0); + QCOMPARE(r.left(), 0.); QVERIFY(r.top() > line.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(6)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(6), r); for (int i = 7; i < text.length(); ++i) { input.setCursorPosition(i); r = input.cursorRectangle(); QVERIFY(r.top() > line.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } // Check vertical scrolling with word wrap. @@ -2506,40 +2503,40 @@ void tst_qquicktextinput::cursorRectangle() QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing))); QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading))); - QCOMPARE(r.top(), 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(round(input.positionToRectangle(i))), r); + QCOMPARE(r.top(), 0.); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } input.setCursorPosition(6); r = input.cursorRectangle(); - QCOMPARE(r.left(), 0); + QCOMPARE(r.left(), 0.); QVERIFY(r.bottom() >= input.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(6)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(6), r); for (int i = 7; i < text.length(); ++i) { input.setCursorPosition(i); r = input.cursorRectangle(); QVERIFY(r.bottom() >= input.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } for (int i = text.length() - 2; i >= 6; --i) { input.setCursorPosition(i); r = input.cursorRectangle(); QVERIFY(r.bottom() >= input.height() - error); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } for (int i = 5; i >= 0; --i) { input.setCursorPosition(i); r = input.cursorRectangle(); - QCOMPARE(r.top(), 0); - QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r); - QCOMPARE(round(input.positionToRectangle(i)), r); + QCOMPARE(r.top(), 0.); + QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRectF(), r); + QCOMPARE(input.positionToRectangle(i), r); } input.setText("Hi!"); @@ -3228,14 +3225,14 @@ void tst_qquicktextinput::cursorRectangleSize() qApp->sendEvent(qApp->focusObject(), &event); QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF(); - QRect cursorRectFromItem = textInput->cursorRectangle(); + QRectF cursorRectFromItem = textInput->cursorRectangle(); QRectF cursorRectFromPositionToRectangle = textInput->positionToRectangle(textInput->cursorPosition()); // item and input query cursor rectangles match - QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect()); + QCOMPARE(cursorRectFromItem, cursorRectFromQuery); // item cursor rectangle and positionToRectangle calculations match - QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect()); + QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle); // item-canvas transform and input item transform match QCOMPARE(QQuickItemPrivate::get(textInput)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform()); -- cgit v1.2.3 From c4e177c049c2cd1513d81421dab31f8d4b5123e4 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 23 Feb 2012 09:50:15 +0000 Subject: Allow V8 bindings to assign to value type sub properties This was an overly defensive change because it wasn't clear if the isAlias check would catch aliased value type sub properties. Change-Id: Iee2805d22f281c1fd188b14e265687fd8e7042db Reviewed-by: Roberto Raggi --- src/declarative/qml/qdeclarativecompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index c4efc85461..b7b882cd97 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -3609,7 +3609,7 @@ bool QDeclarativeCompiler::completeComponentBuild() bool isSharable = false; binding.rewrittenExpression = rewriteBinding(binding.expression.asAST(), expression, &isSharable); - if (isSharable && !binding.property->isValueTypeSubProperty && !binding.property->isAlias /* See above re alias */ && + if (isSharable && !binding.property->isAlias /* See above re alias */ && binding.property->type != qMetaTypeId()) { binding.dataType = BindingReference::V8; sharedBindings.append(b); -- cgit v1.2.3 From 91d543f00904a6caa2fab850ff3eca12de2d65ac Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 24 Feb 2012 10:22:35 +1000 Subject: Add additional autotests for signal handlers. Change-Id: Ie94ce8b536347981310abeb077a88acedf44c7e6 Reviewed-by: Chris Adams --- .../data/signalAssignment.3.qml | 5 +++++ .../data/signalAssignment.4.qml | 6 ++++++ .../declarative/qdeclarativeecmascript/testtypes.h | 2 ++ .../tst_qdeclarativeecmascript.cpp | 21 +++++++++++++++++++++ .../qdeclarativelanguage/data/signal.5.errors.txt | 1 + .../qdeclarativelanguage/data/signal.5.qml | 6 ++++++ .../tst_qdeclarativelanguage.cpp | 1 + tests/auto/declarative/qmlmin/tst_qmlmin.cpp | 3 ++- 8 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.3.qml create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.4.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.5.errors.txt create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.3.qml new file mode 100644 index 0000000000..690b7cf216 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.3.qml @@ -0,0 +1,5 @@ +import Qt.test 1.0 + +MyQmlObject { + onUnnamedArgumentSignal: setString('pass ' + a + ' ' + c) +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.4.qml new file mode 100644 index 0000000000..0e1e728a86 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.4.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + + +MyQmlObject { + onSignalWithGlobalName: setString('pass ' + parseInt("5")) +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index a463d3f64a..ce8e80e81b 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -180,6 +180,7 @@ public: signals: void basicSignal(); void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e); + void unnamedArgumentSignal(int a, qreal, QString c); void stringChanged(); void urlChanged(); void objectChanged(); @@ -188,6 +189,7 @@ signals: void signalWithUnknownType(const MyQmlObject::MyType &arg); void signalWithVariant(const QVariant &arg); void signalWithQJSValue(const QJSValue &arg); + void signalWithGlobalName(int parseInt); void intChanged(); public slots: diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index cc94e6fb4a..7fc137e38d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -376,6 +376,27 @@ void tst_qdeclarativeecmascript::signalAssignment() QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2")); delete object; } + + { + QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.3.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->string(), QString()); + emit object->unnamedArgumentSignal(19, 10.25, "Hello world!"); + QEXPECT_FAIL("", "QTBUG-24481", Continue); + QCOMPARE(object->string(), QString("pass 19 Hello world!")); + delete object; + } + + { + QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.4.qml")); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->string(), QString()); + emit object->signalWithGlobalName(19); + QCOMPARE(object->string(), QString("pass 5")); + delete object; + } } void tst_qdeclarativeecmascript::methods() diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.5.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/signal.5.errors.txt new file mode 100644 index 0000000000..cf772e881e --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.5.errors.txt @@ -0,0 +1 @@ +4:27:Expected token `identifier' diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml b/tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml new file mode 100644 index 0000000000..63921cb2ca --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + signal mySignal(string) +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 480a898ff0..1f211ae963 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -354,6 +354,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false; QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false; QTest::newRow("signal.4") << "signal.4.qml" << "signal.4.errors.txt" << false; + QTest::newRow("signal.5") << "signal.5.qml" << "signal.5.errors.txt" << false; QTest::newRow("method.1") << "method.1.qml" << "method.1.errors.txt" << false; diff --git a/tests/auto/declarative/qmlmin/tst_qmlmin.cpp b/tests/auto/declarative/qmlmin/tst_qmlmin.cpp index c6b019071e..df4e2a01dc 100644 --- a/tests/auto/declarative/qmlmin/tst_qmlmin.cpp +++ b/tests/auto/declarative/qmlmin/tst_qmlmin.cpp @@ -96,10 +96,11 @@ void tst_qmlmin::initTestCase() // Add invalid files (i.e. files with syntax errors) invalidFiles << "tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml"; + invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml"; + invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.5.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/property.4.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/empty.qml"; - invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml"; invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml"; -- cgit v1.2.3 From 9d2b618fa022daeabd45e57aa1596197db883037 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 20 Feb 2012 10:34:44 +1000 Subject: Start of examples refactor This is the general reorg of the examples directory structure, plus additional guidelines. calculator, animations and accessibility have been updated to the new standards and tested, as an example. Task-number: QTBUG-24133 Change-Id: I76c3b86751d3195ba2a5474ff23afb875765e9a4 Reviewed-by: Alan Alpert --- .gitignore | 16 +- doc/config/qtquick.qdocconf | 3 +- doc/src/examples/examples-groups.qdoc | 19 - doc/src/examples/examples-toys.qdoc | 7 - examples/HACKING | 23 + examples/README | 12 + examples/declarative/README | 13 - .../declarative/accessibility/accessibility.qml | 105 --- .../declarative/accessibility/widgets/Button.qml | 79 -- examples/declarative/animation/animation.qml | 62 -- .../declarative/animation/animation.qmlproject | 16 - .../animation/basics/color-animation.qml | 121 --- .../animation/basics/images/face-smile.png | Bin 15408 -> 0 bytes .../declarative/animation/basics/images/moon.png | Bin 2433 -> 0 bytes .../declarative/animation/basics/images/shadow.png | Bin 425 -> 0 bytes .../declarative/animation/basics/images/star.png | Bin 349 -> 0 bytes .../declarative/animation/basics/images/sun.png | Bin 8153 -> 0 bytes .../animation/basics/property-animation.qml | 105 --- .../declarative/animation/behaviors/SideRect.qml | 62 -- .../animation/behaviors/behavior-example.qml | 118 --- .../declarative/animation/behaviors/wigglytext.qml | 108 --- .../animation/easing/content/QuitButton.qml | 52 -- .../declarative/animation/easing/content/quit.png | Bin 583 -> 0 bytes examples/declarative/animation/easing/easing.qml | 170 ---- .../animation/pathanimation/pathanimation.qml | 108 --- .../pathinterpolator/pathinterpolator.qml | 115 --- examples/declarative/animation/states/qt-logo.png | Bin 5149 -> 0 bytes examples/declarative/animation/states/states.qml | 101 --- .../declarative/animation/states/transitions.qml | 130 --- examples/declarative/calculator/calculator.qml | 163 ---- examples/declarative/calculator/content/Button.qml | 84 -- .../declarative/calculator/content/Display.qml | 68 -- .../declarative/calculator/content/calculator.js | 91 --- .../calculator/content/images/button-.png | Bin 1288 -> 0 bytes .../calculator/content/images/button-blue.png | Bin 1565 -> 0 bytes .../calculator/content/images/button-green.png | Bin 1543 -> 0 bytes .../calculator/content/images/button-purple.png | Bin 1566 -> 0 bytes .../calculator/content/images/button-red.png | Bin 1586 -> 0 bytes .../calculator/content/images/display.png | Bin 998 -> 0 bytes examples/declarative/calculator/content/qmldir | 2 - .../declarative/canvas/bezierCurve/bezierCurve.qml | 124 --- examples/declarative/canvas/clip/clip.qml | 150 ---- examples/declarative/canvas/contents/Button.qml | 87 --- examples/declarative/canvas/contents/ScrollBar.qml | 74 -- examples/declarative/canvas/contents/Slider.qml | 115 --- examples/declarative/canvas/contents/Stocks.qml | 147 ---- examples/declarative/canvas/contents/TitleBar.qml | 70 -- examples/declarative/canvas/contents/ToolBar.qml | 69 -- .../canvas/contents/images/button-pressed.png | Bin 571 -> 0 bytes .../declarative/canvas/contents/images/button.png | Bin 564 -> 0 bytes .../declarative/canvas/contents/images/default.svg | 82 -- .../declarative/canvas/contents/images/gloss.png | Bin 1236 -> 0 bytes .../canvas/contents/images/lineedit.png | Bin 1415 -> 0 bytes .../canvas/contents/images/lineedit.sci | 5 - .../declarative/canvas/contents/images/quit.png | Bin 2369 -> 0 bytes .../declarative/canvas/contents/images/stripes.png | Bin 257 -> 0 bytes .../canvas/contents/images/titlebar.png | Bin 1436 -> 0 bytes .../canvas/contents/images/titlebar.sci | 5 - .../canvas/contents/images/toolbutton.png | Bin 2550 -> 0 bytes .../canvas/contents/images/toolbutton.sci | 5 - examples/declarative/canvas/contents/qt-logo.png | Bin 23519 -> 0 bytes .../canvas/quadraticCurveTo/quadraticCurveTo.qml | 128 --- .../declarative/canvas/roundedrect/roundedrect.qml | 125 --- examples/declarative/canvas/smile/smile.qml | 128 --- examples/declarative/canvas/squircle/squircle.png | Bin 771 -> 0 bytes examples/declarative/canvas/squircle/squircle.qml | 155 ---- examples/declarative/canvas/stockchart/README | 5 - .../stockchart/com/nokia/StockChartExample/qmldir | 1 - examples/declarative/canvas/stockchart/model.cpp | 255 ------ examples/declarative/canvas/stockchart/model.h | 166 ---- examples/declarative/canvas/stockchart/plugin.cpp | 60 -- examples/declarative/canvas/stockchart/stock.qml | 726 ----------------- .../declarative/canvas/stockchart/stockchart.pro | 20 - examples/declarative/canvas/tiger/tiger.js | 721 ----------------- examples/declarative/canvas/tiger/tiger.qml | 129 --- .../canvas/twitterfriends/TwitterUser.qml | 294 ------- .../declarative/canvas/twitterfriends/cache.js | 42 - .../declarative/canvas/twitterfriends/twitter.qml | 141 ---- .../declarative/cppextensions/cppextensions.pro | 8 - .../cppextensions/cppextensions.qmlproject | 16 - .../imageprovider/ImageProviderCore/qmldir | 2 - .../imageprovider/imageprovider-example.qml | 49 -- .../cppextensions/imageprovider/imageprovider.cpp | 109 --- .../cppextensions/imageprovider/imageprovider.pro | 22 - .../imageprovider/imageprovider.qmlproject | 14 - .../networkaccessmanagerfactory/main.cpp | 108 --- .../networkaccessmanagerfactory.pro | 4 - .../networkaccessmanagerfactory.qmlproject | 14 - .../networkaccessmanagerfactory.qrc | 5 - .../networkaccessmanagerfactory/view.qml | 47 -- examples/declarative/cppextensions/plugins/README | 9 - .../plugins/com/nokia/TimeExample/Clock.qml | 90 --- .../plugins/com/nokia/TimeExample/center.png | Bin 765 -> 0 bytes .../plugins/com/nokia/TimeExample/clock.png | Bin 20653 -> 0 bytes .../plugins/com/nokia/TimeExample/hour.png | Bin 625 -> 0 bytes .../plugins/com/nokia/TimeExample/minute.png | Bin 625 -> 0 bytes .../plugins/com/nokia/TimeExample/qmldir | 2 - .../declarative/cppextensions/plugins/plugin.cpp | 155 ---- .../declarative/cppextensions/plugins/plugins.pro | 27 - .../declarative/cppextensions/plugins/plugins.qml | 53 -- .../cppextensions/plugins/plugins.qmlproject | 16 - .../referenceexamples/adding/adding.pro | 11 - .../referenceexamples/adding/adding.qrc | 5 - .../referenceexamples/adding/example.qml | 48 -- .../referenceexamples/adding/main.cpp | 64 -- .../referenceexamples/adding/person.cpp | 68 -- .../referenceexamples/adding/person.h | 65 -- .../referenceexamples/attached/attached.pro | 13 - .../referenceexamples/attached/attached.qrc | 5 - .../referenceexamples/attached/birthdayparty.cpp | 91 --- .../referenceexamples/attached/birthdayparty.h | 89 --- .../referenceexamples/attached/example.qml | 68 -- .../referenceexamples/attached/main.cpp | 91 --- .../referenceexamples/attached/person.cpp | 118 --- .../referenceexamples/attached/person.h | 105 --- .../referenceexamples/binding/binding.pro | 15 - .../referenceexamples/binding/binding.qrc | 5 - .../referenceexamples/binding/birthdayparty.cpp | 113 --- .../referenceexamples/binding/birthdayparty.h | 102 --- .../referenceexamples/binding/example.qml | 77 -- .../binding/happybirthdaysong.cpp | 85 -- .../referenceexamples/binding/happybirthdaysong.h | 74 -- .../referenceexamples/binding/main.cpp | 92 --- .../referenceexamples/binding/person.cpp | 138 ---- .../referenceexamples/binding/person.h | 113 --- .../referenceexamples/coercion/birthdayparty.cpp | 71 -- .../referenceexamples/coercion/birthdayparty.h | 69 -- .../referenceexamples/coercion/coercion.pro | 13 - .../referenceexamples/coercion/coercion.qrc | 5 - .../referenceexamples/coercion/example.qml | 55 -- .../referenceexamples/coercion/main.cpp | 80 -- .../referenceexamples/coercion/person.cpp | 79 -- .../referenceexamples/coercion/person.h | 83 -- .../referenceexamples/default/birthdayparty.cpp | 71 -- .../referenceexamples/default/birthdayparty.h | 70 -- .../referenceexamples/default/default.pro | 13 - .../referenceexamples/default/default.qrc | 5 - .../referenceexamples/default/example.qml | 54 -- .../referenceexamples/default/main.cpp | 75 -- .../referenceexamples/default/person.cpp | 78 -- .../referenceexamples/default/person.h | 77 -- .../referenceexamples/extended/example.qml | 47 -- .../referenceexamples/extended/extended.pro | 11 - .../referenceexamples/extended/extended.qrc | 5 - .../referenceexamples/extended/lineedit.cpp | 104 --- .../referenceexamples/extended/lineedit.h | 73 -- .../referenceexamples/extended/main.cpp | 64 -- .../referenceexamples/grouped/birthdayparty.cpp | 71 -- .../referenceexamples/grouped/birthdayparty.h | 69 -- .../referenceexamples/grouped/example.qml | 77 -- .../referenceexamples/grouped/grouped.pro | 13 - .../referenceexamples/grouped/grouped.qrc | 5 - .../referenceexamples/grouped/main.cpp | 85 -- .../referenceexamples/grouped/person.cpp | 118 --- .../referenceexamples/grouped/person.h | 107 --- .../referenceexamples/methods/birthdayparty.cpp | 80 -- .../referenceexamples/methods/birthdayparty.h | 71 -- .../referenceexamples/methods/example.qml | 58 -- .../referenceexamples/methods/main.cpp | 68 -- .../referenceexamples/methods/methods.pro | 13 - .../referenceexamples/methods/methods.qrc | 5 - .../referenceexamples/methods/person.cpp | 66 -- .../referenceexamples/methods/person.h | 63 -- .../referenceexamples/properties/birthdayparty.cpp | 73 -- .../referenceexamples/properties/birthdayparty.h | 75 -- .../referenceexamples/properties/example.qml | 55 -- .../referenceexamples/properties/main.cpp | 70 -- .../referenceexamples/properties/person.cpp | 66 -- .../referenceexamples/properties/person.h | 63 -- .../referenceexamples/properties/properties.pro | 13 - .../referenceexamples/properties/properties.qrc | 5 - .../referenceexamples/referenceexamples.pro | 14 - .../referenceexamples/referenceexamples.qmlproject | 14 - .../referenceexamples/signal/birthdayparty.cpp | 98 --- .../referenceexamples/signal/birthdayparty.h | 92 --- .../referenceexamples/signal/example.qml | 72 -- .../referenceexamples/signal/main.cpp | 91 --- .../referenceexamples/signal/person.cpp | 118 --- .../referenceexamples/signal/person.h | 105 --- .../referenceexamples/signal/signal.pro | 13 - .../referenceexamples/signal/signal.qrc | 5 - .../valuesource/birthdayparty.cpp | 108 --- .../referenceexamples/valuesource/birthdayparty.h | 97 --- .../referenceexamples/valuesource/example.qml | 76 -- .../valuesource/happybirthdaysong.cpp | 80 -- .../valuesource/happybirthdaysong.h | 79 -- .../referenceexamples/valuesource/main.cpp | 93 --- .../referenceexamples/valuesource/person.cpp | 118 --- .../referenceexamples/valuesource/person.h | 105 --- .../referenceexamples/valuesource/valuesource.pro | 15 - .../referenceexamples/valuesource/valuesource.qrc | 5 - examples/declarative/declarative.pro | 38 - .../declarative/draganddrop/dragtarget.qmlproject | 14 - .../declarative/draganddrop/tiles/DragTile.qml | 89 --- .../declarative/draganddrop/tiles/DropTile.qml | 68 -- examples/declarative/draganddrop/tiles/tiles.qml | 109 --- .../declarative/draganddrop/views/gridview.qml | 117 --- examples/declarative/flickr/content/Button.qml | 79 -- .../declarative/flickr/content/GridDelegate.qml | 111 --- .../declarative/flickr/content/ImageDetails.qml | 323 -------- .../declarative/flickr/content/ListDelegate.qml | 64 -- examples/declarative/flickr/content/Progress.qml | 88 --- examples/declarative/flickr/content/RssModel.qml | 64 -- examples/declarative/flickr/content/ScrollBar.qml | 81 -- examples/declarative/flickr/content/Slider.qml | 91 --- examples/declarative/flickr/content/TitleBar.qml | 128 --- examples/declarative/flickr/content/ToolBar.qml | 69 -- .../declarative/flickr/content/UnifiedDelegate.qml | 154 ---- .../declarative/flickr/content/images/gloss.png | Bin 1236 -> 0 bytes .../declarative/flickr/content/images/lineedit.png | Bin 1415 -> 0 bytes .../declarative/flickr/content/images/lineedit.sci | 5 - .../declarative/flickr/content/images/noise.png | Bin 25447 -> 0 bytes .../declarative/flickr/content/images/particle.png | Bin 5148 -> 0 bytes .../declarative/flickr/content/images/quit.png | Bin 2369 -> 0 bytes .../flickr/content/images/squareParticle.png | Bin 933 -> 0 bytes .../declarative/flickr/content/images/stripes.png | Bin 257 -> 0 bytes .../declarative/flickr/content/images/titlebar.png | Bin 1436 -> 0 bytes .../declarative/flickr/content/images/titlebar.sci | 5 - .../flickr/content/images/toolbutton.png | Bin 2550 -> 0 bytes .../flickr/content/images/toolbutton.sci | 5 - examples/declarative/flickr/content/qmldir | 10 - examples/declarative/flickr/flickr-90.qml | 52 -- examples/declarative/flickr/flickr.qml | 158 ---- examples/declarative/flickr/flickr.qmlproject | 17 - examples/declarative/i18n/i18n.qml | 78 -- examples/declarative/i18n/i18n/base.ts | 12 - examples/declarative/i18n/i18n/qml_en_AU.ts | 12 - examples/declarative/i18n/i18n/qml_fr.ts | 12 - examples/declarative/imageelements/borderimage.qml | 97 --- .../imageelements/content/BearSheet.png | Bin 406337 -> 0 bytes .../imageelements/content/ImageCell.qml | 60 -- .../imageelements/content/MyBorderImage.qml | 90 --- .../imageelements/content/ShadowRectangle.qml | 54 -- examples/declarative/imageelements/content/bw.png | Bin 1357 -> 0 bytes .../imageelements/content/colors-round.sci | 7 - .../imageelements/content/colors-stretch.sci | 5 - .../declarative/imageelements/content/colors.png | Bin 1655 -> 0 bytes .../declarative/imageelements/content/qt-logo.png | Bin 5149 -> 0 bytes .../declarative/imageelements/content/shadow.png | Bin 588 -> 0 bytes .../declarative/imageelements/content/speaker.png | Bin 784525 -> 0 bytes examples/declarative/imageelements/image.qml | 67 -- .../declarative/imageelements/imageelements.qml | 58 -- .../imageelements/imageelements.qmlproject | 16 - examples/declarative/imageelements/shadows.qml | 64 -- .../declarative/imageelements/simplesprite.qml | 59 -- examples/declarative/imageelements/spriteimage.qml | 116 --- .../keyinteraction/focus/Core/ContextMenu.qml | 65 -- .../keyinteraction/focus/Core/GridMenu.qml | 105 --- .../keyinteraction/focus/Core/ListMenu.qml | 105 --- .../keyinteraction/focus/Core/ListViewDelegate.qml | 85 -- .../keyinteraction/focus/Core/images/arrow.png | Bin 583 -> 0 bytes .../keyinteraction/focus/Core/images/qt-logo.png | Bin 5149 -> 0 bytes .../declarative/keyinteraction/focus/focus.qml | 111 --- examples/declarative/locale/locale.qml | 132 ---- .../minehunt/MinehuntCore/Explosion.qml | 69 -- .../declarative/minehunt/MinehuntCore/Tile.qml | 128 --- .../minehunt/MinehuntCore/pics/back.png | Bin 558 -> 0 bytes .../minehunt/MinehuntCore/pics/background.png | Bin 313930 -> 0 bytes .../minehunt/MinehuntCore/pics/bomb-color.png | Bin 284 -> 0 bytes .../minehunt/MinehuntCore/pics/bomb.png | Bin 535 -> 0 bytes .../minehunt/MinehuntCore/pics/face-sad.png | Bin 14844 -> 0 bytes .../minehunt/MinehuntCore/pics/face-smile-big.png | Bin 13810 -> 0 bytes .../minehunt/MinehuntCore/pics/face-smile.png | Bin 15408 -> 0 bytes .../minehunt/MinehuntCore/pics/flag-color.png | Bin 219 -> 0 bytes .../minehunt/MinehuntCore/pics/flag.png | Bin 196 -> 0 bytes .../minehunt/MinehuntCore/pics/front.png | Bin 580 -> 0 bytes .../minehunt/MinehuntCore/pics/quit.png | Bin 583 -> 0 bytes .../minehunt/MinehuntCore/pics/star.png | Bin 2677 -> 0 bytes examples/declarative/minehunt/MinehuntCore/qmldir | 2 - examples/declarative/minehunt/README | 6 - examples/declarative/minehunt/main.cpp | 64 -- examples/declarative/minehunt/minehunt.cpp | 221 ------ examples/declarative/minehunt/minehunt.h | 129 --- examples/declarative/minehunt/minehunt.pro | 5 - examples/declarative/minehunt/minehunt.qml | 112 --- examples/declarative/minehunt/minehunt.qmlproject | 16 - examples/declarative/minehunt/minehunt.qrc | 20 - .../abstractitemmodel/abstractitemmodel.pro | 10 - .../abstractitemmodel/abstractitemmodel.qrc | 6 - .../modelviews/abstractitemmodel/main.cpp | 70 -- .../modelviews/abstractitemmodel/model.cpp | 90 --- .../modelviews/abstractitemmodel/model.h | 83 -- .../modelviews/abstractitemmodel/view.qml | 50 -- .../modelviews/gridview/gridview-example.qml | 93 --- .../modelviews/gridview/pics/AddressBook_48.png | Bin 3350 -> 0 bytes .../modelviews/gridview/pics/AudioPlayer_48.png | Bin 3806 -> 0 bytes .../modelviews/gridview/pics/Camera_48.png | Bin 3540 -> 0 bytes .../modelviews/gridview/pics/DateBook_48.png | Bin 2610 -> 0 bytes .../modelviews/gridview/pics/EMail_48.png | Bin 3655 -> 0 bytes .../modelviews/gridview/pics/TodoList_48.png | Bin 3429 -> 0 bytes .../modelviews/gridview/pics/VideoPlayer_48.png | Bin 4151 -> 0 bytes .../modelviews/listview/content/PetsModel.qml | 98 --- .../listview/content/PressAndHoldButton.qml | 82 -- .../modelviews/listview/content/RecipesModel.qml | 129 --- .../modelviews/listview/content/TextButton.qml | 78 -- .../modelviews/listview/content/ToggleButton.qml | 58 -- .../listview/content/pics/arrow-down.png | Bin 594 -> 0 bytes .../modelviews/listview/content/pics/arrow-up.png | Bin 692 -> 0 bytes .../listview/content/pics/fruit-salad.jpg | Bin 17952 -> 0 bytes .../modelviews/listview/content/pics/hamburger.jpg | Bin 8572 -> 0 bytes .../modelviews/listview/content/pics/lemonade.jpg | Bin 6645 -> 0 bytes .../listview/content/pics/list-delete.png | Bin 831 -> 0 bytes .../listview/content/pics/minus-sign.png | Bin 250 -> 0 bytes .../modelviews/listview/content/pics/moreDown.png | Bin 217 -> 0 bytes .../modelviews/listview/content/pics/moreUp.png | Bin 212 -> 0 bytes .../modelviews/listview/content/pics/pancakes.jpg | Bin 9163 -> 0 bytes .../modelviews/listview/content/pics/plus-sign.png | Bin 462 -> 0 bytes .../listview/content/pics/vegetable-soup.jpg | Bin 8639 -> 0 bytes .../modelviews/listview/dynamiclist.qml | 203 ----- .../modelviews/listview/expandingdelegates.qml | 202 ----- .../declarative/modelviews/listview/highlight.qml | 99 --- .../modelviews/listview/highlightranges.qml | 122 --- .../declarative/modelviews/listview/sections.qml | 127 --- examples/declarative/modelviews/modelviews.pro | 8 - examples/declarative/modelviews/modelviews.qml | 64 -- .../declarative/modelviews/modelviews.qmlproject | 16 - .../modelviews/objectlistmodel/dataobject.cpp | 78 -- .../modelviews/objectlistmodel/dataobject.h | 76 -- .../modelviews/objectlistmodel/main.cpp | 78 -- .../modelviews/objectlistmodel/objectlistmodel.pro | 6 - .../objectlistmodel/objectlistmodel.qmlproject | 14 - .../modelviews/objectlistmodel/objectlistmodel.qrc | 5 - .../modelviews/objectlistmodel/view.qml | 55 -- .../declarative/modelviews/package/Delegate.qml | 88 --- examples/declarative/modelviews/package/view.qml | 76 -- .../modelviews/parallax/content/ParallaxView.qml | 123 --- .../modelviews/parallax/content/Smiley.qml | 84 -- .../parallax/content/pics/background.jpg | Bin 209814 -> 0 bytes .../parallax/content/pics/face-smile.png | Bin 15408 -> 0 bytes .../modelviews/parallax/content/pics/home-page.png | Bin 3051 -> 0 bytes .../modelviews/parallax/content/pics/home-page.svg | 445 ----------- .../modelviews/parallax/content/pics/shadow.png | Bin 425 -> 0 bytes .../parallax/content/pics/yast-joystick.png | Bin 2723 -> 0 bytes .../modelviews/parallax/content/pics/yast-wol.png | Bin 3769 -> 0 bytes .../declarative/modelviews/parallax/parallax.qml | 77 -- .../modelviews/pathview/pathview-example.qml | 107 --- .../modelviews/pathview/pics/AddressBook_48.png | Bin 3350 -> 0 bytes .../modelviews/pathview/pics/AudioPlayer_48.png | Bin 3806 -> 0 bytes .../modelviews/pathview/pics/Camera_48.png | Bin 3540 -> 0 bytes .../modelviews/pathview/pics/DateBook_48.png | Bin 2610 -> 0 bytes .../modelviews/pathview/pics/EMail_48.png | Bin 3655 -> 0 bytes .../modelviews/pathview/pics/TodoList_48.png | Bin 3429 -> 0 bytes .../modelviews/pathview/pics/VideoPlayer_48.png | Bin 4151 -> 0 bytes .../modelviews/stringlistmodel/main.cpp | 77 -- .../modelviews/stringlistmodel/stringlistmodel.pro | 4 - .../modelviews/stringlistmodel/stringlistmodel.qrc | 5 - .../modelviews/stringlistmodel/view.qml | 54 -- .../modelviews/visualdatamodel/dragselection.qml | 200 ----- .../modelviews/visualdatamodel/slideshow.qml | 156 ---- .../modelviews/visualdatamodel/sortedmodel.qml | 141 ---- .../visualdatamodel/visualdatamodel.qmlproject | 14 - .../modelviews/visualitemmodel/visualitemmodel.qml | 115 --- examples/declarative/openglunderqml/main.cpp | 60 -- examples/declarative/openglunderqml/main.qml | 78 -- .../declarative/openglunderqml/openglunderqml.pro | 6 - examples/declarative/openglunderqml/squircle.cpp | 123 --- examples/declarative/openglunderqml/squircle.h | 76 -- examples/declarative/painteditem/painteditem.pro | 5 - examples/declarative/painteditem/smile/main.cpp | 96 --- examples/declarative/painteditem/smile/smile.pro | 11 - examples/declarative/painteditem/smile/smile.qml | 132 ---- .../textballoons/TextBalloonPlugin/plugin.h | 55 -- .../textballoons/TextBalloonPlugin/qmldir | 1 - .../painteditem/textballoons/textballoon.cpp | 92 --- .../painteditem/textballoons/textballoon.h | 68 -- .../painteditem/textballoons/textballoons.pro | 25 - .../painteditem/textballoons/textballoons.qml | 110 --- examples/declarative/particles/affectors/age.qml | 97 --- .../declarative/particles/affectors/attractor.qml | 213 ----- .../particles/affectors/customaffector.qml | 173 ---- .../declarative/particles/affectors/friction.qml | 109 --- .../declarative/particles/affectors/gravity.qml | 103 --- .../declarative/particles/affectors/groupgoal.qml | 193 ----- examples/declarative/particles/affectors/move.qml | 141 ---- .../declarative/particles/affectors/spritegoal.qml | 212 ----- .../declarative/particles/affectors/turbulence.qml | 135 ---- .../declarative/particles/affectors/wander.qml | 95 --- .../particles/customparticle/blurparticles.qml | 140 ---- .../particles/customparticle/fragmentshader.qml | 115 --- .../particles/customparticle/imagecolors.qml | 118 --- .../particles/emitters/burstandpulse.qml | 84 -- .../particles/emitters/customemitter.qml | 92 --- .../declarative/particles/emitters/emitmask.qml | 72 -- .../particles/emitters/maximumemitted.qml | 81 -- .../particles/emitters/shapeanddirection.qml | 112 --- .../particles/emitters/timedgroupchanges.qml | 121 --- .../particles/emitters/trailemitter.qml | 175 ----- .../particles/emitters/velocityfrommotion.qml | 311 -------- .../particles/exampleslauncher/content/Button.qml | 73 -- .../particles/exampleslauncher/content/Shell.qml | 78 -- .../particles/exampleslauncher/content/launcher.js | 8 - .../exampleslauncher/exampleslauncher.qml | 116 --- .../particles/imageparticle/allatonce.qml | 98 --- .../particles/imageparticle/colored.qml | 86 -- .../particles/imageparticle/colortable.qml | 84 -- .../particles/imageparticle/deformation.qml | 121 --- .../particles/imageparticle/rotation.qml | 71 -- .../particles/imageparticle/sharing.qml | 199 ----- .../particles/imageparticle/sprites.qml | 116 --- examples/declarative/particles/images/_explo.png | Bin 81528 -> 0 bytes .../particles/images/backgroundLeaves.jpg | Bin 78665 -> 0 bytes .../declarative/particles/images/bear_tiles.png | Bin 40349 -> 0 bytes examples/declarative/particles/images/candle.png | Bin 1348 -> 0 bytes .../declarative/particles/images/colortable.png | Bin 704 -> 0 bytes .../declarative/particles/images/finalfrontier.png | Bin 695061 -> 0 bytes examples/declarative/particles/images/flower.png | Bin 4683 -> 0 bytes .../particles/images/launcherIcons/allatonce.png | Bin 7075 -> 0 bytes .../particles/images/launcherIcons/attractor.png | Bin 31296 -> 0 bytes .../images/launcherIcons/blurparticles.png | Bin 19109 -> 0 bytes .../particles/images/launcherIcons/close.png | Bin 2144 -> 0 bytes .../particles/images/launcherIcons/colortable.png | Bin 6538 -> 0 bytes .../images/launcherIcons/customaffector.png | Bin 10350 -> 0 bytes .../images/launcherIcons/customemitter.png | Bin 22967 -> 0 bytes .../particles/images/launcherIcons/deformation.png | Bin 2870 -> 0 bytes .../particles/images/launcherIcons/delegates.png | Bin 1892 -> 0 bytes .../images/launcherIcons/dynamicemitters.png | Bin 9347 -> 0 bytes .../particles/images/launcherIcons/emitmask.png | Bin 45055 -> 0 bytes .../particles/images/launcherIcons/flickr.png | Bin 10542 -> 0 bytes .../images/launcherIcons/fragmentshader.png | Bin 22294 -> 0 bytes .../images/launcherIcons/gridsplosion.png | Bin 8154 -> 0 bytes .../particles/images/launcherIcons/groupgoal.png | Bin 7173 -> 0 bytes .../particles/images/launcherIcons/imagecolors.png | Bin 56647 -> 0 bytes .../particles/images/launcherIcons/list.png | Bin 32912 -> 0 bytes .../images/launcherIcons/maximumemitted.png | Bin 1019 -> 0 bytes .../images/launcherIcons/multiplepainters.png | Bin 8572 -> 0 bytes .../particles/images/launcherIcons/package.png | Bin 3163 -> 0 bytes .../images/launcherIcons/particleview.png | Bin 26560 -> 0 bytes .../images/launcherIcons/plasmapatrol.png | Bin 9839 -> 0 bytes .../particles/images/launcherIcons/remove.png | Bin 2144 -> 0 bytes .../particles/images/launcherIcons/rotation.png | Bin 20661 -> 0 bytes .../particles/images/launcherIcons/samegame.png | Bin 8647 -> 0 bytes .../images/launcherIcons/shapeanddirection.png | Bin 11359 -> 0 bytes .../images/launcherIcons/spaceexplorer.png | Bin 9152 -> 0 bytes .../particles/images/launcherIcons/spritegoal.png | Bin 35579 -> 0 bytes .../particles/images/launcherIcons/sprites.png | Bin 17009 -> 0 bytes .../images/launcherIcons/spritevariedparticles.png | Bin 2569 -> 0 bytes .../particles/images/launcherIcons/startstop.png | Bin 13670 -> 0 bytes .../images/launcherIcons/timedgroupchanges.png | Bin 16139 -> 0 bytes .../images/launcherIcons/trailemitter.png | Bin 5371 -> 0 bytes .../particles/images/launcherIcons/trails.png | Bin 23168 -> 0 bytes .../particles/images/launcherIcons/turbulence.png | Bin 9684 -> 0 bytes .../images/launcherIcons/velocityfrommotion.png | Bin 36360 -> 0 bytes .../particles/images/launcherIcons/wander.png | Bin 5858 -> 0 bytes .../declarative/particles/images/matchmask.png | Bin 2369 -> 0 bytes examples/declarative/particles/images/meteor.png | Bin 83169 -> 0 bytes .../declarative/particles/images/meteor_explo.png | Bin 219946 -> 0 bytes examples/declarative/particles/images/meteors.png | Bin 132137 -> 0 bytes examples/declarative/particles/images/nullRock.png | Bin 140 -> 0 bytes examples/declarative/particles/images/particle.png | Bin 861 -> 0 bytes .../declarative/particles/images/particle2.png | Bin 3909 -> 0 bytes .../declarative/particles/images/particle3.png | Bin 3186 -> 0 bytes .../declarative/particles/images/particle4.png | Bin 1799 -> 0 bytes .../declarative/particles/images/particleA.png | Bin 3541 -> 0 bytes .../declarative/particles/images/portal_bg.png | Bin 96858 -> 0 bytes .../declarative/particles/images/realLeaf1.png | Bin 15625 -> 0 bytes .../declarative/particles/images/realLeaf2.png | Bin 13660 -> 0 bytes .../declarative/particles/images/realLeaf3.png | Bin 23809 -> 0 bytes .../declarative/particles/images/realLeaf4.png | Bin 23655 -> 0 bytes examples/declarative/particles/images/rocket.png | Bin 7315 -> 0 bytes examples/declarative/particles/images/rocket2.png | Bin 1918 -> 0 bytes .../declarative/particles/images/sizeInOut.png | Bin 251 -> 0 bytes .../declarative/particles/images/snowflake.png | Bin 189327 -> 0 bytes .../declarative/particles/images/sparkleSize.png | Bin 378 -> 0 bytes examples/declarative/particles/images/star.png | Bin 1550 -> 0 bytes .../declarative/particles/images/starfish_0.png | Bin 15972 -> 0 bytes .../declarative/particles/images/starfish_1.png | Bin 15746 -> 0 bytes .../declarative/particles/images/starfish_2.png | Bin 16067 -> 0 bytes .../declarative/particles/images/starfish_3.png | Bin 16201 -> 0 bytes .../declarative/particles/images/starfish_4.png | Bin 14698 -> 0 bytes .../declarative/particles/images/starfish_mask.png | Bin 11301 -> 0 bytes .../particles/itemparticle/content/Delegate.qml | 88 --- .../particles/itemparticle/content/Delegate2.qml | 79 -- .../itemparticle/content/ExpandingDelegate.qml | 204 ----- .../particles/itemparticle/content/RssModel.qml | 56 -- .../particles/itemparticle/content/bubble.png | Bin 3413 -> 0 bytes .../particles/itemparticle/content/script.js | 27 - .../particles/itemparticle/delegates.qml | 91 --- .../particles/itemparticle/particleview.qml | 274 ------- .../particles/plasmapatrol/PlasmaPatrol.qmlproject | 19 - examples/declarative/particles/plasmapatrol/TODO | 10 - .../plasmapatrol/content/BlasterHardpoint.qml | 133 ---- .../particles/plasmapatrol/content/Button.qml | 66 -- .../plasmapatrol/content/CannonHardpoint.qml | 97 --- .../particles/plasmapatrol/content/ChoiceBox.qml | 105 --- .../particles/plasmapatrol/content/Cruiser.qml | 146 ---- .../particles/plasmapatrol/content/Frigate.qml | 114 --- .../particles/plasmapatrol/content/Hardpoint.qml | 114 --- .../particles/plasmapatrol/content/HelpScreens.qml | 268 ------- .../plasmapatrol/content/LaserHardpoint.qml | 108 --- .../plasmapatrol/content/PlasmaPatrolParticles.qml | 173 ---- .../plasmapatrol/content/SequentialLoader.qml | 54 -- .../particles/plasmapatrol/content/Ship.qml | 114 --- .../particles/plasmapatrol/content/Sloop.qml | 108 --- .../plasmapatrol/content/pics/TitleText.png | Bin 1109 -> 0 bytes .../plasmapatrol/content/pics/blur-circle2.png | Bin 3627 -> 0 bytes .../plasmapatrol/content/pics/blur-circle3.png | Bin 5148 -> 0 bytes .../plasmapatrol/content/pics/finalfrontier.png | Bin 695061 -> 0 bytes .../particles/plasmapatrol/content/pics/meteor.png | Bin 83169 -> 0 bytes .../plasmapatrol/content/pics/meteor_explo.png | Bin 81528 -> 0 bytes .../plasmapatrol/content/pics/nullRock.png | Bin 140 -> 0 bytes .../plasmapatrol/content/pics/particle.png | Bin 861 -> 0 bytes .../particles/plasmapatrol/content/pics/star.png | Bin 1550 -> 0 bytes .../particles/plasmapatrol/content/pics/star2.png | Bin 6507 -> 0 bytes .../particles/plasmapatrol/content/pics/star3.png | Bin 4602 -> 0 bytes .../particles/plasmapatrol/plasmapatrol.qml | 386 --------- .../particles/simple/dynamiccomparison.qml | 126 --- .../particles/simple/dynamicemitters.qml | 122 --- .../particles/simple/multiplepainters.qml | 90 --- .../declarative/particles/simple/startstop.qml | 81 -- .../photoviewer/PhotoViewerCore/AlbumDelegate.qml | 147 ---- .../photoviewer/PhotoViewerCore/BusyIndicator.qml | 50 -- .../photoviewer/PhotoViewerCore/Button.qml | 72 -- .../photoviewer/PhotoViewerCore/EditableButton.qml | 86 -- .../photoviewer/PhotoViewerCore/PhotoDelegate.qml | 188 ----- .../photoviewer/PhotoViewerCore/ProgressBar.qml | 57 -- .../photoviewer/PhotoViewerCore/RssModel.qml | 57 -- .../photoviewer/PhotoViewerCore/Tag.qml | 91 --- .../PhotoViewerCore/images/box-shadow.png | Bin 588 -> 0 bytes .../photoviewer/PhotoViewerCore/images/busy.png | Bin 2629 -> 0 bytes .../PhotoViewerCore/images/cardboard.png | Bin 8844 -> 0 bytes .../declarative/photoviewer/PhotoViewerCore/qmldir | 8 - .../photoviewer/PhotoViewerCore/script/script.js | 27 - examples/declarative/photoviewer/i18n/base.ts | 30 - examples/declarative/photoviewer/i18n/qml_fr.qm | Bin 268 -> 0 bytes examples/declarative/photoviewer/i18n/qml_fr.ts | 30 - examples/declarative/photoviewer/photoviewer.qml | 110 --- .../declarative/photoviewer/photoviewer.qmlproject | 20 - .../declarative/positioners/content/Button.qml | 78 -- examples/declarative/positioners/content/add.png | Bin 810 -> 0 bytes examples/declarative/positioners/content/del.png | Bin 488 -> 0 bytes .../positioners/positioners-attachedproperties.qml | 106 --- examples/declarative/positioners/positioners.qml | 264 ------- .../layoutdirection/layoutdirection.qml | 246 ------ .../layoutdirection/layoutdirection.qmlproject | 16 - .../layoutmirroring/layoutmirroring.qml | 313 -------- .../layoutmirroring/layoutmirroring.qmlproject | 16 - .../righttoleft/textalignment/textalignment.qml | 427 ---------- .../textalignment/textalignment.qmlproject | 16 - .../declarative/rssnews/content/BusyIndicator.qml | 53 -- .../rssnews/content/CategoryDelegate.qml | 82 -- .../declarative/rssnews/content/NewsDelegate.qml | 71 -- examples/declarative/rssnews/content/RssFeeds.qml | 59 -- examples/declarative/rssnews/content/ScrollBar.qml | 107 --- .../declarative/rssnews/content/images/busy.png | Bin 2629 -> 0 bytes .../rssnews/content/images/scrollbar.png | Bin 161 -> 0 bytes examples/declarative/rssnews/rssnews.qml | 112 --- examples/declarative/rssnews/rssnews.qmlproject | 16 - .../declarative/samegame/content/BoomBlock.qml | 112 --- examples/declarative/samegame/content/Button.qml | 75 -- examples/declarative/samegame/content/Dialog.qml | 81 -- examples/declarative/samegame/content/GameArea.qml | 92 --- .../samegame/content/NameInputDialog.qml | 93 --- .../samegame/content/pics/background.png | Bin 313930 -> 0 bytes .../samegame/content/pics/blueStone.png | Bin 3054 -> 0 bytes .../samegame/content/pics/greenStone.png | Bin 2932 -> 0 bytes .../declarative/samegame/content/pics/particle.png | Bin 861 -> 0 bytes .../declarative/samegame/content/pics/redStone.png | Bin 2902 -> 0 bytes .../samegame/content/pics/yellowStone.png | Bin 3056 -> 0 bytes examples/declarative/samegame/content/samegame.js | 290 ------- examples/declarative/samegame/samegame.qml | 87 --- examples/declarative/samegame/samegame.qmlproject | 16 - examples/declarative/script/script.pro | 4 - examples/declarative/script/shell/main.cpp | 153 ---- examples/declarative/script/shell/shell.pro | 7 - .../declarative/shadereffects/content/Slider.qml | 93 --- .../shadereffects/content/face-smile.png | Bin 15408 -> 0 bytes .../declarative/shadereffects/content/qt-logo.png | Bin 13923 -> 0 bytes .../declarative/shadereffects/shadereffects.qml | 300 ------- examples/declarative/shared/Button.qml | 64 -- examples/declarative/shared/LauncherList.qml | 101 --- examples/declarative/shared/README | 11 - .../declarative/shared/SimpleLauncherDelegate.qml | 53 -- examples/declarative/shared/back.png | Bin 404 -> 0 bytes examples/declarative/snake/content/Button.qml | 66 -- examples/declarative/snake/content/Cookie.qml | 102 --- .../declarative/snake/content/HighScoreModel.qml | 140 ---- examples/declarative/snake/content/Link.qml | 129 --- examples/declarative/snake/content/Skull.qml | 62 -- examples/declarative/snake/content/pics/README | 1 - .../declarative/snake/content/pics/background.png | Bin 144508 -> 0 bytes .../declarative/snake/content/pics/blueStar.png | Bin 272 -> 0 bytes .../declarative/snake/content/pics/blueStone.png | Bin 3139 -> 0 bytes examples/declarative/snake/content/pics/cookie.png | Bin 2729 -> 0 bytes examples/declarative/snake/content/pics/eyes.svg | 118 --- examples/declarative/snake/content/pics/head.png | Bin 3473 -> 0 bytes examples/declarative/snake/content/pics/pause.png | Bin 4327 -> 0 bytes .../declarative/snake/content/pics/redStar.png | Bin 273 -> 0 bytes .../declarative/snake/content/pics/redStone.png | Bin 3456 -> 0 bytes examples/declarative/snake/content/pics/skull.png | Bin 2543 -> 0 bytes examples/declarative/snake/content/pics/snake.jpg | Bin 663901 -> 0 bytes examples/declarative/snake/content/pics/star.png | Bin 262 -> 0 bytes .../declarative/snake/content/pics/stoneShadow.png | Bin 1699 -> 0 bytes .../declarative/snake/content/pics/yellowStar.png | Bin 276 -> 0 bytes .../declarative/snake/content/pics/yellowStone.png | Bin 2667 -> 0 bytes examples/declarative/snake/content/snake.js | 316 -------- examples/declarative/snake/snake.qml | 272 ------- examples/declarative/snake/snake.qmlproject | 16 - examples/declarative/sqllocalstorage/hello.qml | 78 -- examples/declarative/text/fonts/availableFonts.qml | 57 -- examples/declarative/text/fonts/banner.qml | 61 -- .../text/fonts/content/fonts/tarzeau_ocr_a.ttf | Bin 24544 -> 0 bytes examples/declarative/text/fonts/fonts.qml | 104 --- examples/declarative/text/fonts/hello.qml | 79 -- examples/declarative/text/imgtag/TextWithImage.qml | 55 -- .../declarative/text/imgtag/images/face-sad.png | Bin 6148 -> 0 bytes .../text/imgtag/images/face-smile-big.png | Bin 6058 -> 0 bytes .../declarative/text/imgtag/images/face-smile.png | Bin 6446 -> 0 bytes .../declarative/text/imgtag/images/heart200.png | Bin 8248 -> 0 bytes examples/declarative/text/imgtag/images/qtlogo.png | Bin 6450 -> 0 bytes .../declarative/text/imgtag/images/starfish_2.png | Bin 18243 -> 0 bytes examples/declarative/text/imgtag/imgtag.qml | 101 --- examples/declarative/text/styledtext-layout.qml | 107 --- examples/declarative/text/text.qml | 57 -- examples/declarative/text/text.qmlproject | 16 - .../text/textselection/pics/endHandle.png | Bin 185 -> 0 bytes .../text/textselection/pics/endHandle.sci | 5 - .../text/textselection/pics/startHandle.png | Bin 178 -> 0 bytes .../text/textselection/pics/startHandle.sci | 5 - .../text/textselection/textselection.qml | 211 ----- .../threading/threadedlistmodel/dataloader.js | 49 -- .../threadedlistmodel/threadedlistmodel.qmlproject | 56 -- .../threading/threadedlistmodel/timedisplay.qml | 76 -- .../threading/workerscript/workerscript.js | 15 - .../threading/workerscript/workerscript.qml | 83 -- .../threading/workerscript/workerscript.qmlproject | 16 - .../mousearea/mousearea-example.qml | 176 ----- .../touchinteraction/multipointtouch/bearwhack.qml | 133 ---- .../content/AugmentedTouchPoint.qml | 70 -- .../multipointtouch/content/Bear0.png | Bin 15163 -> 0 bytes .../multipointtouch/content/Bear1.png | Bin 99378 -> 0 bytes .../multipointtouch/content/Bear2.png | Bin 80759 -> 0 bytes .../multipointtouch/content/Bear3.png | Bin 21122 -> 0 bytes .../multipointtouch/content/BearB.png | Bin 18667 -> 0 bytes .../content/BearWhackParticleSystem.qml | 180 ----- .../multipointtouch/content/ParticleFlame.qml | 65 -- .../multipointtouch/content/blur-circle.png | Bin 4279 -> 0 bytes .../multipointtouch/content/blur-circle3.png | Bin 5148 -> 0 bytes .../multipointtouch/content/heart-blur.png | Bin 5406 -> 0 bytes .../multipointtouch/content/title.png | Bin 81252 -> 0 bytes .../multipointtouch/multiflame.qml | 91 --- .../touchinteraction/pincharea/flickresize.qml | 97 --- .../touchinteraction/pincharea/qt-logo.jpg | Bin 40886 -> 0 bytes .../touchinteraction/touchinteraction.qml | 57 -- .../touchinteraction/touchinteraction.qmlproject | 16 - examples/declarative/toys/clocks/clocks.qml | 88 --- examples/declarative/toys/clocks/content/Clock.qml | 143 ---- .../declarative/toys/clocks/content/QuitButton.qml | 52 -- examples/declarative/toys/clocks/content/arrow.png | Bin 692 -> 0 bytes .../declarative/toys/clocks/content/background.png | Bin 46895 -> 0 bytes .../declarative/toys/clocks/content/center.png | Bin 765 -> 0 bytes .../toys/clocks/content/clock-night.png | Bin 23359 -> 0 bytes examples/declarative/toys/clocks/content/clock.png | Bin 20653 -> 0 bytes examples/declarative/toys/clocks/content/hour.png | Bin 625 -> 0 bytes .../declarative/toys/clocks/content/minute.png | Bin 625 -> 0 bytes examples/declarative/toys/clocks/content/quit.png | Bin 583 -> 0 bytes .../declarative/toys/clocks/content/second.png | Bin 303 -> 0 bytes .../declarative/toys/corkboards/content/Day.qml | 153 ---- .../declarative/toys/corkboards/content/cork.jpg | Bin 149337 -> 0 bytes .../toys/corkboards/content/note-yellow.png | Bin 54559 -> 0 bytes .../declarative/toys/corkboards/content/tack.png | Bin 7282 -> 0 bytes .../declarative/toys/corkboards/corkboards.qml | 116 --- .../toys/dynamicscene/content/Button.qml | 80 -- .../toys/dynamicscene/content/GenericSceneItem.qml | 49 -- .../toys/dynamicscene/content/PaletteItem.qml | 59 -- .../toys/dynamicscene/content/PerspectiveItem.qml | 65 -- .../declarative/toys/dynamicscene/content/Sun.qml | 78 -- .../toys/dynamicscene/content/images/NOTE | 1 - .../dynamicscene/content/images/face-smile.png | Bin 15408 -> 0 bytes .../toys/dynamicscene/content/images/moon.png | Bin 1757 -> 0 bytes .../dynamicscene/content/images/rabbit_brown.png | Bin 1245 -> 0 bytes .../toys/dynamicscene/content/images/rabbit_bw.png | Bin 1759 -> 0 bytes .../toys/dynamicscene/content/images/star.png | Bin 349 -> 0 bytes .../toys/dynamicscene/content/images/sun.png | Bin 8153 -> 0 bytes .../toys/dynamicscene/content/images/tree_s.png | Bin 3406 -> 0 bytes .../toys/dynamicscene/content/itemCreation.js | 62 -- .../declarative/toys/dynamicscene/dynamicscene.qml | 275 ------- .../toys/tic-tac-toe/content/Button.qml | 79 -- .../toys/tic-tac-toe/content/TicTac.qml | 60 -- .../toys/tic-tac-toe/content/pics/board.png | Bin 12258 -> 0 bytes .../toys/tic-tac-toe/content/pics/o.png | Bin 1470 -> 0 bytes .../toys/tic-tac-toe/content/pics/x.png | Bin 1331 -> 0 bytes .../toys/tic-tac-toe/content/tic-tac-toe.js | 149 ---- .../declarative/toys/tic-tac-toe/tic-tac-toe.qml | 123 --- examples/declarative/toys/tvtennis/tvtennis.qml | 109 --- .../dynamicview/dynamicview1/PetsModel.qml | 102 --- .../dynamicview/dynamicview1/dynamicview.qml | 90 --- .../dynamicview/dynamicview2/PetsModel.qml | 98 --- .../dynamicview/dynamicview2/dynamicview.qml | 121 --- .../dynamicview/dynamicview3/PetsModel.qml | 98 --- .../dynamicview/dynamicview3/dynamicview.qml | 143 ---- .../dynamicview/dynamicview4/ListSelector.qml | 120 --- .../dynamicview/dynamicview4/PetsModel.qml | 98 --- .../dynamicview/dynamicview4/dynamicview.qml | 219 ------ .../tutorials/extending/chapter1-basics/app.qml | 60 -- .../extending/chapter1-basics/chapter1-basics.pro | 5 - .../tutorials/extending/chapter1-basics/main.cpp | 57 -- .../extending/chapter1-basics/piechart.cpp | 79 -- .../tutorials/extending/chapter1-basics/piechart.h | 71 -- .../tutorials/extending/chapter2-methods/app.qml | 66 -- .../chapter2-methods/chapter2-methods.pro | 5 - .../tutorials/extending/chapter2-methods/main.cpp | 57 -- .../extending/chapter2-methods/piechart.cpp | 84 -- .../extending/chapter2-methods/piechart.h | 84 -- .../tutorials/extending/chapter3-bindings/app.qml | 74 -- .../chapter3-bindings/chapter3-bindings.pro | 5 - .../tutorials/extending/chapter3-bindings/main.cpp | 57 -- .../extending/chapter3-bindings/piechart.cpp | 86 -- .../extending/chapter3-bindings/piechart.h | 84 -- .../extending/chapter4-customPropertyTypes/app.qml | 60 -- .../chapter4-customPropertyTypes.pro | 7 - .../chapter4-customPropertyTypes/main.cpp | 66 -- .../chapter4-customPropertyTypes/piechart.cpp | 70 -- .../chapter4-customPropertyTypes/piechart.h | 78 -- .../chapter4-customPropertyTypes/pieslice.cpp | 66 -- .../chapter4-customPropertyTypes/pieslice.h | 66 -- .../extending/chapter5-listproperties/app.qml | 70 -- .../chapter5-listproperties.pro | 7 - .../extending/chapter5-listproperties/main.cpp | 58 -- .../extending/chapter5-listproperties/piechart.cpp | 72 -- .../extending/chapter5-listproperties/piechart.h | 75 -- .../extending/chapter5-listproperties/pieslice.cpp | 86 -- .../extending/chapter5-listproperties/pieslice.h | 76 -- .../extending/chapter6-plugins/ChartsPlugin/qmldir | 1 - .../tutorials/extending/chapter6-plugins/app.qml | 69 -- .../chapter6-plugins/chapter6-plugins.pro | 18 - .../extending/chapter6-plugins/chartsplugin.cpp | 53 -- .../extending/chapter6-plugins/chartsplugin.h | 57 -- .../extending/chapter6-plugins/piechart.cpp | 71 -- .../extending/chapter6-plugins/piechart.h | 69 -- .../extending/chapter6-plugins/pieslice.cpp | 86 -- .../extending/chapter6-plugins/pieslice.h | 74 -- .../declarative/tutorials/extending/extending.pro | 10 - examples/declarative/tutorials/helloworld/Cell.qml | 72 -- .../declarative/tutorials/helloworld/tutorial1.qml | 63 -- .../declarative/tutorials/helloworld/tutorial2.qml | 72 -- .../declarative/tutorials/helloworld/tutorial3.qml | 91 --- .../tutorials/samegame/samegame1/Block.qml | 53 -- .../tutorials/samegame/samegame1/Button.qml | 83 -- .../tutorials/samegame/samegame1/samegame.qml | 82 -- .../samegame/samegame1/samegame1.qmlproject | 16 - .../tutorials/samegame/samegame2/Block.qml | 51 -- .../tutorials/samegame/samegame2/Button.qml | 81 -- .../tutorials/samegame/samegame2/samegame.js | 63 -- .../tutorials/samegame/samegame2/samegame.qml | 85 -- .../samegame/samegame2/samegame2.qmlproject | 16 - .../tutorials/samegame/samegame3/Block.qml | 63 -- .../tutorials/samegame/samegame3/Button.qml | 81 -- .../tutorials/samegame/samegame3/Dialog.qml | 71 -- .../tutorials/samegame/samegame3/samegame.js | 174 ----- .../tutorials/samegame/samegame3/samegame.qml | 109 --- .../samegame/samegame3/samegame3.qmlproject | 16 - .../samegame/samegame4/content/BoomBlock.qml | 122 --- .../samegame/samegame4/content/Button.qml | 81 -- .../samegame/samegame4/content/Dialog.qml | 107 --- .../samegame/samegame4/content/samegame.js | 226 ------ .../tutorials/samegame/samegame4/highscores/README | 1 - .../samegame/samegame4/highscores/score_data.xml | 2 - .../samegame/samegame4/highscores/score_style.xsl | 28 - .../samegame/samegame4/highscores/scores.php | 31 - .../tutorials/samegame/samegame4/samegame.qml | 115 --- .../samegame/samegame4/samegame4.qmlproject | 16 - .../tutorials/samegame/shared/pics/background.jpg | Bin 36473 -> 0 bytes .../tutorials/samegame/shared/pics/blueStar.png | Bin 278 -> 0 bytes .../tutorials/samegame/shared/pics/blueStone.png | Bin 3054 -> 0 bytes .../tutorials/samegame/shared/pics/greenStar.png | Bin 273 -> 0 bytes .../tutorials/samegame/shared/pics/greenStone.png | Bin 2932 -> 0 bytes .../tutorials/samegame/shared/pics/redStar.png | Bin 274 -> 0 bytes .../tutorials/samegame/shared/pics/redStone.png | Bin 2902 -> 0 bytes .../tutorials/samegame/shared/pics/star.png | Bin 262 -> 0 bytes .../tutorials/samegame/shared/pics/yellowStone.png | Bin 3056 -> 0 bytes examples/declarative/tutorials/tutorials.pro | 5 - .../declarative/tutorials/tutorials.qmlproject | 14 - .../declarative/twitter/TwitterCore/Button.qml | 90 --- .../twitter/TwitterCore/FatDelegate.qml | 105 --- examples/declarative/twitter/TwitterCore/Input.qml | 65 -- .../declarative/twitter/TwitterCore/Loading.qml | 49 -- .../twitter/TwitterCore/MultiTitleBar.qml | 60 -- .../declarative/twitter/TwitterCore/RssModel.qml | 80 -- .../declarative/twitter/TwitterCore/SearchView.qml | 124 --- .../declarative/twitter/TwitterCore/TitleBar.qml | 130 --- .../declarative/twitter/TwitterCore/ToolBar.qml | 64 -- .../declarative/twitter/TwitterCore/UserModel.qml | 66 -- .../twitter/TwitterCore/images/gloss.png | Bin 1236 -> 0 bytes .../twitter/TwitterCore/images/lineedit.png | Bin 1415 -> 0 bytes .../twitter/TwitterCore/images/lineedit.sci | 5 - .../twitter/TwitterCore/images/loading.png | Bin 813 -> 0 bytes .../twitter/TwitterCore/images/quit.png | Bin 2369 -> 0 bytes .../twitter/TwitterCore/images/stripes.png | Bin 257 -> 0 bytes .../twitter/TwitterCore/images/titlebar.png | Bin 1436 -> 0 bytes .../twitter/TwitterCore/images/titlebar.sci | 5 - .../twitter/TwitterCore/images/toolbutton.png | Bin 2550 -> 0 bytes .../twitter/TwitterCore/images/toolbutton.sci | 5 - examples/declarative/twitter/TwitterCore/qmldir | 10 - examples/declarative/twitter/twitter.qml | 135 ---- examples/declarative/twitter/twitter.qmlproject | 16 - .../ui-components/dialcontrol/content/Dial.qml | 86 -- .../dialcontrol/content/QuitButton.qml | 52 -- .../dialcontrol/content/background.png | Bin 35876 -> 0 bytes .../ui-components/dialcontrol/content/needle.png | Bin 342 -> 0 bytes .../dialcontrol/content/needle_shadow.png | Bin 632 -> 0 bytes .../ui-components/dialcontrol/content/overlay.png | Bin 3564 -> 0 bytes .../ui-components/dialcontrol/content/quit.png | Bin 583 -> 0 bytes .../ui-components/dialcontrol/dialcontrol.qml | 98 --- .../ui-components/flipable/content/5_heart.png | Bin 3872 -> 0 bytes .../ui-components/flipable/content/9_club.png | Bin 6135 -> 0 bytes .../ui-components/flipable/content/Card.qml | 80 -- .../ui-components/flipable/content/back.png | Bin 1418 -> 0 bytes .../ui-components/flipable/flipable.qml | 55 -- .../progressbar/content/ProgressBar.qml | 83 -- .../progressbar/content/background.png | Bin 426 -> 0 bytes .../declarative/ui-components/progressbar/main.qml | 73 -- .../ui-components/scrollbar/ScrollBar.qml | 74 -- .../declarative/ui-components/scrollbar/main.qml | 93 --- .../ui-components/scrollbar/pics/niagara_falls.jpg | Bin 142510 -> 0 bytes .../ui-components/scrollbar/scrollbar.qmlproject | 16 - .../ui-components/searchbox/SearchBox.qml | 109 --- .../ui-components/searchbox/images/clear.png | Bin 429 -> 0 bytes .../searchbox/images/lineedit-bg-focus.png | Bin 526 -> 0 bytes .../ui-components/searchbox/images/lineedit-bg.png | Bin 426 -> 0 bytes .../declarative/ui-components/searchbox/main.qml | 60 -- .../ui-components/searchbox/searchbox.qmlproject | 16 - .../ui-components/slideswitch/content/Switch.qml | 117 --- .../slideswitch/content/background.png | Bin 3091 -> 0 bytes .../slideswitch/content/background.svg | 23 - .../ui-components/slideswitch/content/knob.png | Bin 3101 -> 0 bytes .../ui-components/slideswitch/content/knob.svg | 867 --------------------- .../ui-components/slideswitch/slideswitch.qml | 51 -- .../ui-components/spinner/content/Spinner.qml | 70 -- .../ui-components/spinner/content/spinner-bg.png | Bin 345 -> 0 bytes .../spinner/content/spinner-select.png | Bin 320 -> 0 bytes .../declarative/ui-components/spinner/main.qml | 61 -- .../ui-components/spinner/spinner.qmlproject | 16 - .../ui-components/tabwidget/TabWidget.qml | 102 --- .../declarative/ui-components/tabwidget/main.qml | 99 --- .../declarative/ui-components/tabwidget/tab.png | Bin 507 -> 0 bytes .../ui-components/tabwidget/tabwidget.qmlproject | 16 - examples/declarative/window/Window.qml | 58 -- examples/declarative/window/screen/screenInfo.qml | 90 --- examples/declarative/window/standalone.qml | 71 -- examples/declarative/window/window.cpp | 58 -- examples/declarative/window/window.pro | 5 - examples/declarative/xml/xmlhttprequest/data.xml | 5 - .../xml/xmlhttprequest/xmlhttprequest-example.qml | 95 --- .../demos/calculator/CalculatorCore/Button.qml | 84 ++ .../demos/calculator/CalculatorCore/Display.qml | 68 ++ .../demos/calculator/CalculatorCore/calculator.js | 95 +++ .../calculator/CalculatorCore/images/button-.png | Bin 0 -> 1288 bytes .../CalculatorCore/images/button-blue.png | Bin 0 -> 1565 bytes .../CalculatorCore/images/button-green.png | Bin 0 -> 1543 bytes .../CalculatorCore/images/button-purple.png | Bin 0 -> 1566 bytes .../CalculatorCore/images/button-red.png | Bin 0 -> 1586 bytes .../calculator/CalculatorCore/images/display.png | Bin 0 -> 998 bytes examples/demos/calculator/CalculatorCore/qmldir | 2 + examples/demos/calculator/calculator-desktop.qml | 136 ++++ examples/demos/calculator/calculator-mobile.qml | 164 ++++ examples/demos/calculator/calculator.pro | 9 + examples/demos/calculator/calculator.qdoc | 37 + examples/demos/calculator/main.cpp | 66 ++ examples/demos/clocks/clocks.qml | 88 +++ examples/demos/clocks/content/Clock.qml | 143 ++++ examples/demos/clocks/content/QuitButton.qml | 52 ++ examples/demos/clocks/content/arrow.png | Bin 0 -> 692 bytes examples/demos/clocks/content/background.png | Bin 0 -> 46895 bytes examples/demos/clocks/content/center.png | Bin 0 -> 765 bytes examples/demos/clocks/content/clock-night.png | Bin 0 -> 23359 bytes examples/demos/clocks/content/clock.png | Bin 0 -> 20653 bytes examples/demos/clocks/content/hour.png | Bin 0 -> 625 bytes examples/demos/clocks/content/minute.png | Bin 0 -> 625 bytes examples/demos/clocks/content/quit.png | Bin 0 -> 583 bytes examples/demos/clocks/content/second.png | Bin 0 -> 303 bytes examples/demos/corkboards/content/Day.qml | 153 ++++ examples/demos/corkboards/content/cork.jpg | Bin 0 -> 149337 bytes examples/demos/corkboards/content/note-yellow.png | Bin 0 -> 54559 bytes examples/demos/corkboards/content/tack.png | Bin 0 -> 7282 bytes examples/demos/corkboards/corkboards.qml | 116 +++ examples/demos/demos.pro | 2 + examples/demos/dynamicscene/content/Button.qml | 80 ++ .../dynamicscene/content/GenericSceneItem.qml | 49 ++ .../demos/dynamicscene/content/PaletteItem.qml | 59 ++ .../demos/dynamicscene/content/PerspectiveItem.qml | 65 ++ examples/demos/dynamicscene/content/Sun.qml | 78 ++ examples/demos/dynamicscene/content/images/NOTE | 1 + .../dynamicscene/content/images/face-smile.png | Bin 0 -> 15408 bytes .../demos/dynamicscene/content/images/moon.png | Bin 0 -> 1757 bytes .../dynamicscene/content/images/rabbit_brown.png | Bin 0 -> 1245 bytes .../dynamicscene/content/images/rabbit_bw.png | Bin 0 -> 1759 bytes .../demos/dynamicscene/content/images/star.png | Bin 0 -> 349 bytes examples/demos/dynamicscene/content/images/sun.png | Bin 0 -> 8153 bytes .../demos/dynamicscene/content/images/tree_s.png | Bin 0 -> 3406 bytes .../demos/dynamicscene/content/itemCreation.js | 62 ++ examples/demos/dynamicscene/dynamicscene.qml | 275 +++++++ examples/demos/flickr/content/Button.qml | 79 ++ examples/demos/flickr/content/GridDelegate.qml | 111 +++ examples/demos/flickr/content/ImageDetails.qml | 323 ++++++++ examples/demos/flickr/content/ListDelegate.qml | 64 ++ examples/demos/flickr/content/Progress.qml | 88 +++ examples/demos/flickr/content/RssModel.qml | 64 ++ examples/demos/flickr/content/ScrollBar.qml | 81 ++ examples/demos/flickr/content/Slider.qml | 91 +++ examples/demos/flickr/content/TitleBar.qml | 128 +++ examples/demos/flickr/content/ToolBar.qml | 69 ++ examples/demos/flickr/content/UnifiedDelegate.qml | 154 ++++ examples/demos/flickr/content/images/gloss.png | Bin 0 -> 1236 bytes examples/demos/flickr/content/images/lineedit.png | Bin 0 -> 1415 bytes examples/demos/flickr/content/images/lineedit.sci | 5 + examples/demos/flickr/content/images/noise.png | Bin 0 -> 25447 bytes examples/demos/flickr/content/images/particle.png | Bin 0 -> 5148 bytes examples/demos/flickr/content/images/quit.png | Bin 0 -> 2369 bytes .../demos/flickr/content/images/squareParticle.png | Bin 0 -> 933 bytes examples/demos/flickr/content/images/stripes.png | Bin 0 -> 257 bytes examples/demos/flickr/content/images/titlebar.png | Bin 0 -> 1436 bytes examples/demos/flickr/content/images/titlebar.sci | 5 + .../demos/flickr/content/images/toolbutton.png | Bin 0 -> 2550 bytes .../demos/flickr/content/images/toolbutton.sci | 5 + examples/demos/flickr/content/qmldir | 10 + examples/demos/flickr/flickr-90.qml | 52 ++ examples/demos/flickr/flickr.qml | 158 ++++ examples/demos/flickr/flickr.qmlproject | 17 + examples/demos/minehunt/MinehuntCore/Explosion.qml | 69 ++ examples/demos/minehunt/MinehuntCore/Tile.qml | 128 +++ examples/demos/minehunt/MinehuntCore/pics/back.png | Bin 0 -> 558 bytes .../minehunt/MinehuntCore/pics/background.png | Bin 0 -> 313930 bytes .../minehunt/MinehuntCore/pics/bomb-color.png | Bin 0 -> 284 bytes examples/demos/minehunt/MinehuntCore/pics/bomb.png | Bin 0 -> 535 bytes .../demos/minehunt/MinehuntCore/pics/face-sad.png | Bin 0 -> 14844 bytes .../minehunt/MinehuntCore/pics/face-smile-big.png | Bin 0 -> 13810 bytes .../minehunt/MinehuntCore/pics/face-smile.png | Bin 0 -> 15408 bytes .../minehunt/MinehuntCore/pics/flag-color.png | Bin 0 -> 219 bytes examples/demos/minehunt/MinehuntCore/pics/flag.png | Bin 0 -> 196 bytes .../demos/minehunt/MinehuntCore/pics/front.png | Bin 0 -> 580 bytes examples/demos/minehunt/MinehuntCore/pics/quit.png | Bin 0 -> 583 bytes examples/demos/minehunt/MinehuntCore/pics/star.png | Bin 0 -> 2677 bytes examples/demos/minehunt/MinehuntCore/qmldir | 2 + examples/demos/minehunt/README | 6 + examples/demos/minehunt/main.cpp | 64 ++ examples/demos/minehunt/minehunt.cpp | 221 ++++++ examples/demos/minehunt/minehunt.h | 129 +++ examples/demos/minehunt/minehunt.pro | 5 + examples/demos/minehunt/minehunt.qml | 112 +++ examples/demos/minehunt/minehunt.qmlproject | 16 + examples/demos/minehunt/minehunt.qrc | 20 + .../photoviewer/PhotoViewerCore/AlbumDelegate.qml | 147 ++++ .../photoviewer/PhotoViewerCore/BusyIndicator.qml | 50 ++ .../demos/photoviewer/PhotoViewerCore/Button.qml | 72 ++ .../photoviewer/PhotoViewerCore/EditableButton.qml | 86 ++ .../photoviewer/PhotoViewerCore/PhotoDelegate.qml | 188 +++++ .../photoviewer/PhotoViewerCore/ProgressBar.qml | 57 ++ .../demos/photoviewer/PhotoViewerCore/RssModel.qml | 57 ++ examples/demos/photoviewer/PhotoViewerCore/Tag.qml | 91 +++ .../PhotoViewerCore/images/box-shadow.png | Bin 0 -> 588 bytes .../photoviewer/PhotoViewerCore/images/busy.png | Bin 0 -> 2629 bytes .../PhotoViewerCore/images/cardboard.png | Bin 0 -> 8844 bytes examples/demos/photoviewer/PhotoViewerCore/qmldir | 8 + .../photoviewer/PhotoViewerCore/script/script.js | 27 + examples/demos/photoviewer/i18n/base.ts | 30 + examples/demos/photoviewer/i18n/qml_fr.qm | Bin 0 -> 268 bytes examples/demos/photoviewer/i18n/qml_fr.ts | 30 + examples/demos/photoviewer/photoviewer.qml | 110 +++ examples/demos/photoviewer/photoviewer.qmlproject | 20 + .../demos/plasmapatrol/PlasmaPatrol.qmlproject | 19 + examples/demos/plasmapatrol/TODO | 10 + .../plasmapatrol/content/BlasterHardpoint.qml | 133 ++++ examples/demos/plasmapatrol/content/Button.qml | 66 ++ .../demos/plasmapatrol/content/CannonHardpoint.qml | 97 +++ examples/demos/plasmapatrol/content/ChoiceBox.qml | 105 +++ examples/demos/plasmapatrol/content/Cruiser.qml | 146 ++++ examples/demos/plasmapatrol/content/Frigate.qml | 114 +++ examples/demos/plasmapatrol/content/Hardpoint.qml | 114 +++ .../demos/plasmapatrol/content/HelpScreens.qml | 268 +++++++ .../demos/plasmapatrol/content/LaserHardpoint.qml | 108 +++ .../plasmapatrol/content/PlasmaPatrolParticles.qml | 173 ++++ .../plasmapatrol/content/SequentialLoader.qml | 54 ++ examples/demos/plasmapatrol/content/Ship.qml | 114 +++ examples/demos/plasmapatrol/content/Sloop.qml | 108 +++ .../demos/plasmapatrol/content/pics/TitleText.png | Bin 0 -> 1109 bytes .../plasmapatrol/content/pics/blur-circle2.png | Bin 0 -> 3627 bytes .../plasmapatrol/content/pics/blur-circle3.png | Bin 0 -> 5148 bytes .../plasmapatrol/content/pics/finalfrontier.png | Bin 0 -> 695061 bytes .../demos/plasmapatrol/content/pics/meteor.png | Bin 0 -> 83169 bytes .../plasmapatrol/content/pics/meteor_explo.png | Bin 0 -> 81528 bytes .../demos/plasmapatrol/content/pics/nullRock.png | Bin 0 -> 140 bytes .../demos/plasmapatrol/content/pics/particle.png | Bin 0 -> 861 bytes examples/demos/plasmapatrol/content/pics/star.png | Bin 0 -> 1550 bytes examples/demos/plasmapatrol/content/pics/star2.png | Bin 0 -> 6507 bytes examples/demos/plasmapatrol/content/pics/star3.png | Bin 0 -> 4602 bytes examples/demos/plasmapatrol/plasmapatrol.qml | 386 +++++++++ examples/demos/rssnews/content/BusyIndicator.qml | 53 ++ .../demos/rssnews/content/CategoryDelegate.qml | 82 ++ examples/demos/rssnews/content/NewsDelegate.qml | 71 ++ examples/demos/rssnews/content/RssFeeds.qml | 59 ++ examples/demos/rssnews/content/ScrollBar.qml | 107 +++ examples/demos/rssnews/content/images/busy.png | Bin 0 -> 2629 bytes .../demos/rssnews/content/images/scrollbar.png | Bin 0 -> 161 bytes examples/demos/rssnews/rssnews.qml | 112 +++ examples/demos/rssnews/rssnews.qmlproject | 16 + examples/demos/samegame/content/BoomBlock.qml | 112 +++ examples/demos/samegame/content/Button.qml | 75 ++ examples/demos/samegame/content/Dialog.qml | 81 ++ examples/demos/samegame/content/GameArea.qml | 92 +++ .../demos/samegame/content/NameInputDialog.qml | 93 +++ .../demos/samegame/content/pics/background.png | Bin 0 -> 313930 bytes examples/demos/samegame/content/pics/blueStone.png | Bin 0 -> 3054 bytes .../demos/samegame/content/pics/greenStone.png | Bin 0 -> 2932 bytes examples/demos/samegame/content/pics/particle.png | Bin 0 -> 861 bytes examples/demos/samegame/content/pics/redStone.png | Bin 0 -> 2902 bytes .../demos/samegame/content/pics/yellowStone.png | Bin 0 -> 3056 bytes examples/demos/samegame/content/samegame.js | 290 +++++++ examples/demos/samegame/samegame.qml | 87 +++ examples/demos/samegame/samegame.qmlproject | 16 + examples/demos/snake/content/Button.qml | 66 ++ examples/demos/snake/content/Cookie.qml | 102 +++ examples/demos/snake/content/HighScoreModel.qml | 140 ++++ examples/demos/snake/content/Link.qml | 129 +++ examples/demos/snake/content/Skull.qml | 62 ++ examples/demos/snake/content/pics/README | 1 + examples/demos/snake/content/pics/background.png | Bin 0 -> 144508 bytes examples/demos/snake/content/pics/blueStar.png | Bin 0 -> 272 bytes examples/demos/snake/content/pics/blueStone.png | Bin 0 -> 3139 bytes examples/demos/snake/content/pics/cookie.png | Bin 0 -> 2729 bytes examples/demos/snake/content/pics/eyes.svg | 118 +++ examples/demos/snake/content/pics/head.png | Bin 0 -> 3473 bytes examples/demos/snake/content/pics/pause.png | Bin 0 -> 4327 bytes examples/demos/snake/content/pics/redStar.png | Bin 0 -> 273 bytes examples/demos/snake/content/pics/redStone.png | Bin 0 -> 3456 bytes examples/demos/snake/content/pics/skull.png | Bin 0 -> 2543 bytes examples/demos/snake/content/pics/snake.jpg | Bin 0 -> 663901 bytes examples/demos/snake/content/pics/star.png | Bin 0 -> 262 bytes examples/demos/snake/content/pics/stoneShadow.png | Bin 0 -> 1699 bytes examples/demos/snake/content/pics/yellowStar.png | Bin 0 -> 276 bytes examples/demos/snake/content/pics/yellowStone.png | Bin 0 -> 2667 bytes examples/demos/snake/content/snake.js | 316 ++++++++ examples/demos/snake/snake.qml | 273 +++++++ examples/demos/snake/snake.qmlproject | 16 + examples/demos/tic-tac-toe/content/Button.qml | 79 ++ examples/demos/tic-tac-toe/content/TicTac.qml | 60 ++ examples/demos/tic-tac-toe/content/pics/board.png | Bin 0 -> 12258 bytes examples/demos/tic-tac-toe/content/pics/o.png | Bin 0 -> 1470 bytes examples/demos/tic-tac-toe/content/pics/x.png | Bin 0 -> 1331 bytes examples/demos/tic-tac-toe/content/tic-tac-toe.js | 149 ++++ examples/demos/tic-tac-toe/tic-tac-toe.qml | 123 +++ examples/demos/tvtennis/tvtennis.qml | 109 +++ examples/demos/twitter/TwitterCore/Button.qml | 90 +++ examples/demos/twitter/TwitterCore/FatDelegate.qml | 105 +++ examples/demos/twitter/TwitterCore/Input.qml | 65 ++ examples/demos/twitter/TwitterCore/Loading.qml | 49 ++ .../demos/twitter/TwitterCore/MultiTitleBar.qml | 60 ++ examples/demos/twitter/TwitterCore/RssModel.qml | 80 ++ examples/demos/twitter/TwitterCore/SearchView.qml | 124 +++ examples/demos/twitter/TwitterCore/TitleBar.qml | 130 +++ examples/demos/twitter/TwitterCore/ToolBar.qml | 64 ++ examples/demos/twitter/TwitterCore/UserModel.qml | 66 ++ .../demos/twitter/TwitterCore/images/gloss.png | Bin 0 -> 1236 bytes .../demos/twitter/TwitterCore/images/lineedit.png | Bin 0 -> 1415 bytes .../demos/twitter/TwitterCore/images/lineedit.sci | 5 + .../demos/twitter/TwitterCore/images/loading.png | Bin 0 -> 813 bytes examples/demos/twitter/TwitterCore/images/quit.png | Bin 0 -> 2369 bytes .../demos/twitter/TwitterCore/images/stripes.png | Bin 0 -> 257 bytes .../demos/twitter/TwitterCore/images/titlebar.png | Bin 0 -> 1436 bytes .../demos/twitter/TwitterCore/images/titlebar.sci | 5 + .../twitter/TwitterCore/images/toolbutton.png | Bin 0 -> 2550 bytes .../twitter/TwitterCore/images/toolbutton.sci | 5 + examples/demos/twitter/TwitterCore/qmldir | 10 + examples/demos/twitter/twitter.qml | 135 ++++ examples/demos/twitter/twitter.qmlproject | 16 + examples/embedded/embedded.pro | 2 - examples/embedded/qmlcalculator/deployment.pri | 4 - examples/embedded/qmlcalculator/qmlcalculator.cpp | 63 -- examples/embedded/qmlcalculator/qmlcalculator.pro | 5 - examples/embedded/qmlclocks/deployment.pri | 4 - examples/embedded/qmlclocks/qmlclocks.cpp | 63 -- examples/embedded/qmlclocks/qmlclocks.pro | 5 - examples/embedded/qmldialcontrol/deployment.pri | 4 - .../embedded/qmldialcontrol/qmldialcontrol.cpp | 63 -- .../embedded/qmldialcontrol/qmldialcontrol.pro | 5 - examples/embedded/qmleasing/deployment.pri | 4 - examples/embedded/qmleasing/qmleasing.cpp | 63 -- examples/embedded/qmleasing/qmleasing.pro | 5 - examples/embedded/qmlflickr/deployment.pri | 4 - examples/embedded/qmlflickr/qmlflickr.cpp | 104 --- examples/embedded/qmlflickr/qmlflickr.pro | 5 - examples/embedded/qmlphotoviewer/deployment.pri | 4 - .../embedded/qmlphotoviewer/qmlphotoviewer.cpp | 104 --- .../embedded/qmlphotoviewer/qmlphotoviewer.pro | 5 - examples/embedded/qmltwitter/deployment.pri | 4 - examples/embedded/qmltwitter/qmltwitter.cpp | 103 --- examples/embedded/qmltwitter/qmltwitter.pro | 5 - examples/examples.pro | 2 +- examples/localstorage/hello.qml | 78 ++ examples/localstorage/localstorage.pro | 1 + examples/particles/affectors/age.qml | 97 +++ examples/particles/affectors/attractor.qml | 213 +++++ examples/particles/affectors/customaffector.qml | 173 ++++ examples/particles/affectors/friction.qml | 109 +++ examples/particles/affectors/gravity.qml | 103 +++ examples/particles/affectors/groupgoal.qml | 193 +++++ examples/particles/affectors/move.qml | 141 ++++ examples/particles/affectors/spritegoal.qml | 212 +++++ examples/particles/affectors/turbulence.qml | 135 ++++ examples/particles/affectors/wander.qml | 95 +++ .../particles/customparticle/blurparticles.qml | 140 ++++ .../particles/customparticle/fragmentshader.qml | 115 +++ examples/particles/customparticle/imagecolors.qml | 118 +++ examples/particles/emitters/burstandpulse.qml | 84 ++ examples/particles/emitters/customemitter.qml | 92 +++ examples/particles/emitters/emitmask.qml | 72 ++ examples/particles/emitters/maximumemitted.qml | 81 ++ examples/particles/emitters/shapeanddirection.qml | 112 +++ examples/particles/emitters/timedgroupchanges.qml | 121 +++ examples/particles/emitters/trailemitter.qml | 175 +++++ examples/particles/emitters/velocityfrommotion.qml | 311 ++++++++ .../particles/exampleslauncher/content/Button.qml | 73 ++ .../particles/exampleslauncher/content/Shell.qml | 78 ++ .../particles/exampleslauncher/content/launcher.js | 8 + .../exampleslauncher/exampleslauncher.qml | 116 +++ examples/particles/imageparticle/allatonce.qml | 98 +++ examples/particles/imageparticle/colored.qml | 86 ++ examples/particles/imageparticle/colortable.qml | 84 ++ examples/particles/imageparticle/deformation.qml | 121 +++ examples/particles/imageparticle/rotation.qml | 71 ++ examples/particles/imageparticle/sharing.qml | 199 +++++ examples/particles/imageparticle/sprites.qml | 116 +++ examples/particles/images/_explo.png | Bin 0 -> 81528 bytes examples/particles/images/backgroundLeaves.jpg | Bin 0 -> 78665 bytes examples/particles/images/bear_tiles.png | Bin 0 -> 40349 bytes examples/particles/images/candle.png | Bin 0 -> 1348 bytes examples/particles/images/colortable.png | Bin 0 -> 704 bytes examples/particles/images/finalfrontier.png | Bin 0 -> 695061 bytes examples/particles/images/flower.png | Bin 0 -> 4683 bytes .../particles/images/launcherIcons/allatonce.png | Bin 0 -> 7075 bytes .../particles/images/launcherIcons/attractor.png | Bin 0 -> 31296 bytes .../images/launcherIcons/blurparticles.png | Bin 0 -> 19109 bytes examples/particles/images/launcherIcons/close.png | Bin 0 -> 2144 bytes .../particles/images/launcherIcons/colortable.png | Bin 0 -> 6538 bytes .../images/launcherIcons/customaffector.png | Bin 0 -> 10350 bytes .../images/launcherIcons/customemitter.png | Bin 0 -> 22967 bytes .../particles/images/launcherIcons/deformation.png | Bin 0 -> 2870 bytes .../particles/images/launcherIcons/delegates.png | Bin 0 -> 1892 bytes .../images/launcherIcons/dynamicemitters.png | Bin 0 -> 9347 bytes .../particles/images/launcherIcons/emitmask.png | Bin 0 -> 45055 bytes examples/particles/images/launcherIcons/flickr.png | Bin 0 -> 10542 bytes .../images/launcherIcons/fragmentshader.png | Bin 0 -> 22294 bytes .../images/launcherIcons/gridsplosion.png | Bin 0 -> 8154 bytes .../particles/images/launcherIcons/groupgoal.png | Bin 0 -> 7173 bytes .../particles/images/launcherIcons/imagecolors.png | Bin 0 -> 56647 bytes examples/particles/images/launcherIcons/list.png | Bin 0 -> 32912 bytes .../images/launcherIcons/maximumemitted.png | Bin 0 -> 1019 bytes .../images/launcherIcons/multiplepainters.png | Bin 0 -> 8572 bytes .../particles/images/launcherIcons/package.png | Bin 0 -> 3163 bytes .../images/launcherIcons/particleview.png | Bin 0 -> 26560 bytes .../images/launcherIcons/plasmapatrol.png | Bin 0 -> 9839 bytes examples/particles/images/launcherIcons/remove.png | Bin 0 -> 2144 bytes .../particles/images/launcherIcons/rotation.png | Bin 0 -> 20661 bytes .../particles/images/launcherIcons/samegame.png | Bin 0 -> 8647 bytes .../images/launcherIcons/shapeanddirection.png | Bin 0 -> 11359 bytes .../images/launcherIcons/spaceexplorer.png | Bin 0 -> 9152 bytes .../particles/images/launcherIcons/spritegoal.png | Bin 0 -> 35579 bytes .../particles/images/launcherIcons/sprites.png | Bin 0 -> 17009 bytes .../images/launcherIcons/spritevariedparticles.png | Bin 0 -> 2569 bytes .../particles/images/launcherIcons/startstop.png | Bin 0 -> 13670 bytes .../images/launcherIcons/timedgroupchanges.png | Bin 0 -> 16139 bytes .../images/launcherIcons/trailemitter.png | Bin 0 -> 5371 bytes examples/particles/images/launcherIcons/trails.png | Bin 0 -> 23168 bytes .../particles/images/launcherIcons/turbulence.png | Bin 0 -> 9684 bytes .../images/launcherIcons/velocityfrommotion.png | Bin 0 -> 36360 bytes examples/particles/images/launcherIcons/wander.png | Bin 0 -> 5858 bytes examples/particles/images/matchmask.png | Bin 0 -> 2369 bytes examples/particles/images/meteor.png | Bin 0 -> 83169 bytes examples/particles/images/meteor_explo.png | Bin 0 -> 219946 bytes examples/particles/images/meteors.png | Bin 0 -> 132137 bytes examples/particles/images/nullRock.png | Bin 0 -> 140 bytes examples/particles/images/particle.png | Bin 0 -> 861 bytes examples/particles/images/particle2.png | Bin 0 -> 3909 bytes examples/particles/images/particle3.png | Bin 0 -> 3186 bytes examples/particles/images/particle4.png | Bin 0 -> 1799 bytes examples/particles/images/particleA.png | Bin 0 -> 3541 bytes examples/particles/images/portal_bg.png | Bin 0 -> 96858 bytes examples/particles/images/realLeaf1.png | Bin 0 -> 15625 bytes examples/particles/images/realLeaf2.png | Bin 0 -> 13660 bytes examples/particles/images/realLeaf3.png | Bin 0 -> 23809 bytes examples/particles/images/realLeaf4.png | Bin 0 -> 23655 bytes examples/particles/images/rocket.png | Bin 0 -> 7315 bytes examples/particles/images/rocket2.png | Bin 0 -> 1918 bytes examples/particles/images/sizeInOut.png | Bin 0 -> 251 bytes examples/particles/images/snowflake.png | Bin 0 -> 189327 bytes examples/particles/images/sparkleSize.png | Bin 0 -> 378 bytes examples/particles/images/star.png | Bin 0 -> 1550 bytes examples/particles/images/starfish_0.png | Bin 0 -> 15972 bytes examples/particles/images/starfish_1.png | Bin 0 -> 15746 bytes examples/particles/images/starfish_2.png | Bin 0 -> 16067 bytes examples/particles/images/starfish_3.png | Bin 0 -> 16201 bytes examples/particles/images/starfish_4.png | Bin 0 -> 14698 bytes examples/particles/images/starfish_mask.png | Bin 0 -> 11301 bytes .../particles/itemparticle/content/Delegate.qml | 88 +++ .../particles/itemparticle/content/Delegate2.qml | 79 ++ .../itemparticle/content/ExpandingDelegate.qml | 204 +++++ .../particles/itemparticle/content/RssModel.qml | 56 ++ examples/particles/itemparticle/content/bubble.png | Bin 0 -> 3413 bytes examples/particles/itemparticle/content/script.js | 27 + examples/particles/itemparticle/delegates.qml | 91 +++ examples/particles/itemparticle/particleview.qml | 274 +++++++ examples/particles/particles.pro | 1 + examples/particles/simple/dynamiccomparison.qml | 126 +++ examples/particles/simple/dynamicemitters.qml | 122 +++ examples/particles/simple/multiplepainters.qml | 90 +++ examples/particles/simple/startstop.qml | 81 ++ examples/qml/cppextensions/cppextensions.pro | 8 + .../qml/cppextensions/cppextensions.qmlproject | 16 + .../imageprovider/ImageProviderCore/qmldir | 2 + .../imageprovider/imageprovider-example.qml | 49 ++ .../cppextensions/imageprovider/imageprovider.cpp | 109 +++ .../cppextensions/imageprovider/imageprovider.pro | 22 + .../imageprovider/imageprovider.qmlproject | 14 + .../networkaccessmanagerfactory/main.cpp | 108 +++ .../networkaccessmanagerfactory.pro | 4 + .../networkaccessmanagerfactory.qmlproject | 14 + .../networkaccessmanagerfactory.qrc | 5 + .../networkaccessmanagerfactory/view.qml | 47 ++ examples/qml/cppextensions/plugins/README | 9 + .../plugins/com/nokia/TimeExample/Clock.qml | 90 +++ .../plugins/com/nokia/TimeExample/center.png | Bin 0 -> 765 bytes .../plugins/com/nokia/TimeExample/clock.png | Bin 0 -> 20653 bytes .../plugins/com/nokia/TimeExample/hour.png | Bin 0 -> 625 bytes .../plugins/com/nokia/TimeExample/minute.png | Bin 0 -> 625 bytes .../plugins/com/nokia/TimeExample/qmldir | 2 + examples/qml/cppextensions/plugins/plugin.cpp | 155 ++++ examples/qml/cppextensions/plugins/plugins.pro | 27 + examples/qml/cppextensions/plugins/plugins.qml | 53 ++ .../qml/cppextensions/plugins/plugins.qmlproject | 16 + .../referenceexamples/adding/adding.pro | 11 + .../referenceexamples/adding/adding.qrc | 5 + .../referenceexamples/adding/example.qml | 48 ++ .../referenceexamples/adding/main.cpp | 64 ++ .../referenceexamples/adding/person.cpp | 68 ++ .../referenceexamples/adding/person.h | 65 ++ .../referenceexamples/attached/attached.pro | 13 + .../referenceexamples/attached/attached.qrc | 5 + .../referenceexamples/attached/birthdayparty.cpp | 91 +++ .../referenceexamples/attached/birthdayparty.h | 89 +++ .../referenceexamples/attached/example.qml | 68 ++ .../referenceexamples/attached/main.cpp | 91 +++ .../referenceexamples/attached/person.cpp | 118 +++ .../referenceexamples/attached/person.h | 105 +++ .../referenceexamples/binding/binding.pro | 15 + .../referenceexamples/binding/binding.qrc | 5 + .../referenceexamples/binding/birthdayparty.cpp | 113 +++ .../referenceexamples/binding/birthdayparty.h | 102 +++ .../referenceexamples/binding/example.qml | 77 ++ .../binding/happybirthdaysong.cpp | 85 ++ .../referenceexamples/binding/happybirthdaysong.h | 74 ++ .../referenceexamples/binding/main.cpp | 92 +++ .../referenceexamples/binding/person.cpp | 138 ++++ .../referenceexamples/binding/person.h | 113 +++ .../referenceexamples/coercion/birthdayparty.cpp | 71 ++ .../referenceexamples/coercion/birthdayparty.h | 69 ++ .../referenceexamples/coercion/coercion.pro | 13 + .../referenceexamples/coercion/coercion.qrc | 5 + .../referenceexamples/coercion/example.qml | 55 ++ .../referenceexamples/coercion/main.cpp | 80 ++ .../referenceexamples/coercion/person.cpp | 79 ++ .../referenceexamples/coercion/person.h | 83 ++ .../referenceexamples/default/birthdayparty.cpp | 71 ++ .../referenceexamples/default/birthdayparty.h | 70 ++ .../referenceexamples/default/default.pro | 13 + .../referenceexamples/default/default.qrc | 5 + .../referenceexamples/default/example.qml | 54 ++ .../referenceexamples/default/main.cpp | 75 ++ .../referenceexamples/default/person.cpp | 78 ++ .../referenceexamples/default/person.h | 77 ++ .../referenceexamples/extended/example.qml | 47 ++ .../referenceexamples/extended/extended.pro | 11 + .../referenceexamples/extended/extended.qrc | 5 + .../referenceexamples/extended/lineedit.cpp | 104 +++ .../referenceexamples/extended/lineedit.h | 73 ++ .../referenceexamples/extended/main.cpp | 64 ++ .../referenceexamples/grouped/birthdayparty.cpp | 71 ++ .../referenceexamples/grouped/birthdayparty.h | 69 ++ .../referenceexamples/grouped/example.qml | 77 ++ .../referenceexamples/grouped/grouped.pro | 13 + .../referenceexamples/grouped/grouped.qrc | 5 + .../referenceexamples/grouped/main.cpp | 85 ++ .../referenceexamples/grouped/person.cpp | 118 +++ .../referenceexamples/grouped/person.h | 107 +++ .../referenceexamples/methods/birthdayparty.cpp | 80 ++ .../referenceexamples/methods/birthdayparty.h | 71 ++ .../referenceexamples/methods/example.qml | 58 ++ .../referenceexamples/methods/main.cpp | 68 ++ .../referenceexamples/methods/methods.pro | 13 + .../referenceexamples/methods/methods.qrc | 5 + .../referenceexamples/methods/person.cpp | 66 ++ .../referenceexamples/methods/person.h | 63 ++ .../referenceexamples/properties/birthdayparty.cpp | 73 ++ .../referenceexamples/properties/birthdayparty.h | 75 ++ .../referenceexamples/properties/example.qml | 55 ++ .../referenceexamples/properties/main.cpp | 70 ++ .../referenceexamples/properties/person.cpp | 66 ++ .../referenceexamples/properties/person.h | 63 ++ .../referenceexamples/properties/properties.pro | 13 + .../referenceexamples/properties/properties.qrc | 5 + .../referenceexamples/referenceexamples.pro | 14 + .../referenceexamples/referenceexamples.qmlproject | 14 + .../referenceexamples/signal/birthdayparty.cpp | 98 +++ .../referenceexamples/signal/birthdayparty.h | 92 +++ .../referenceexamples/signal/example.qml | 72 ++ .../referenceexamples/signal/main.cpp | 91 +++ .../referenceexamples/signal/person.cpp | 118 +++ .../referenceexamples/signal/person.h | 105 +++ .../referenceexamples/signal/signal.pro | 13 + .../referenceexamples/signal/signal.qrc | 5 + .../valuesource/birthdayparty.cpp | 108 +++ .../referenceexamples/valuesource/birthdayparty.h | 97 +++ .../referenceexamples/valuesource/example.qml | 76 ++ .../valuesource/happybirthdaysong.cpp | 80 ++ .../valuesource/happybirthdaysong.h | 79 ++ .../referenceexamples/valuesource/main.cpp | 93 +++ .../referenceexamples/valuesource/person.cpp | 118 +++ .../referenceexamples/valuesource/person.h | 105 +++ .../referenceexamples/valuesource/valuesource.pro | 15 + .../referenceexamples/valuesource/valuesource.qrc | 5 + examples/qml/i18n/i18n.qml | 78 ++ examples/qml/i18n/i18n/base.ts | 12 + examples/qml/i18n/i18n/qml_en_AU.ts | 12 + examples/qml/i18n/i18n/qml_fr.ts | 12 + examples/qml/locale/locale.qml | 132 ++++ examples/qml/qml.pro | 1 + examples/qml/script/script.pro | 4 + examples/qml/script/shell/main.cpp | 153 ++++ examples/qml/script/shell/shell.pro | 7 + examples/qml/xmlhttprequest/data.xml | 5 + .../qml/xmlhttprequest/xmlhttprequest-example.qml | 95 +++ examples/qtquick/accessibility/accessibility.pro | 10 + examples/qtquick/accessibility/accessibility.qml | 110 +++ .../qtquick/accessibility/accessibility.qmlproject | 16 + examples/qtquick/accessibility/content/Button.qml | 80 ++ examples/qtquick/accessibility/main.cpp | 41 + examples/qtquick/animation/animation.pro | 10 + examples/qtquick/animation/animation.qml | 90 +++ examples/qtquick/animation/animation.qmlproject | 16 + .../qtquick/animation/basics/color-animation.qml | 121 +++ .../qtquick/animation/basics/images/face-smile.png | Bin 0 -> 15408 bytes examples/qtquick/animation/basics/images/moon.png | Bin 0 -> 2433 bytes .../qtquick/animation/basics/images/shadow.png | Bin 0 -> 425 bytes examples/qtquick/animation/basics/images/star.png | Bin 0 -> 349 bytes examples/qtquick/animation/basics/images/sun.png | Bin 0 -> 8153 bytes .../animation/basics/property-animation.qml | 105 +++ examples/qtquick/animation/behaviors/SideRect.qml | 62 ++ .../animation/behaviors/behavior-example.qml | 118 +++ .../qtquick/animation/behaviors/wigglytext.qml | 108 +++ .../animation/easing/content/QuitButton.qml | 52 ++ examples/qtquick/animation/easing/content/quit.png | Bin 0 -> 583 bytes examples/qtquick/animation/easing/easing.qml | 157 ++++ examples/qtquick/animation/main.cpp | 41 + .../animation/pathanimation/pathanimation.qml | 105 +++ .../pathinterpolator/pathinterpolator.qml | 112 +++ examples/qtquick/animation/states/qt-logo.png | Bin 0 -> 5149 bytes examples/qtquick/animation/states/states.qml | 101 +++ examples/qtquick/animation/states/transitions.qml | 130 +++ .../qtquick/canvas/bezierCurve/bezierCurve.qml | 124 +++ examples/qtquick/canvas/clip/clip.qml | 150 ++++ examples/qtquick/canvas/contents/Button.qml | 87 +++ examples/qtquick/canvas/contents/ScrollBar.qml | 74 ++ examples/qtquick/canvas/contents/Slider.qml | 115 +++ examples/qtquick/canvas/contents/Stocks.qml | 147 ++++ examples/qtquick/canvas/contents/TitleBar.qml | 70 ++ examples/qtquick/canvas/contents/ToolBar.qml | 69 ++ .../canvas/contents/images/button-pressed.png | Bin 0 -> 571 bytes examples/qtquick/canvas/contents/images/button.png | Bin 0 -> 564 bytes .../qtquick/canvas/contents/images/default.svg | 82 ++ examples/qtquick/canvas/contents/images/gloss.png | Bin 0 -> 1236 bytes .../qtquick/canvas/contents/images/lineedit.png | Bin 0 -> 1415 bytes .../qtquick/canvas/contents/images/lineedit.sci | 5 + examples/qtquick/canvas/contents/images/quit.png | Bin 0 -> 2369 bytes .../qtquick/canvas/contents/images/stripes.png | Bin 0 -> 257 bytes .../qtquick/canvas/contents/images/titlebar.png | Bin 0 -> 1436 bytes .../qtquick/canvas/contents/images/titlebar.sci | 5 + .../qtquick/canvas/contents/images/toolbutton.png | Bin 0 -> 2550 bytes .../qtquick/canvas/contents/images/toolbutton.sci | 5 + examples/qtquick/canvas/contents/qt-logo.png | Bin 0 -> 23519 bytes .../canvas/quadraticCurveTo/quadraticCurveTo.qml | 128 +++ .../qtquick/canvas/roundedrect/roundedrect.qml | 125 +++ examples/qtquick/canvas/smile/smile.qml | 128 +++ examples/qtquick/canvas/squircle/squircle.png | Bin 0 -> 771 bytes examples/qtquick/canvas/squircle/squircle.qml | 155 ++++ examples/qtquick/canvas/stockchart/README | 5 + .../stockchart/com/nokia/StockChartExample/qmldir | 1 + examples/qtquick/canvas/stockchart/model.cpp | 255 ++++++ examples/qtquick/canvas/stockchart/model.h | 166 ++++ examples/qtquick/canvas/stockchart/plugin.cpp | 60 ++ examples/qtquick/canvas/stockchart/stock.qml | 726 +++++++++++++++++ examples/qtquick/canvas/stockchart/stockchart.pro | 20 + examples/qtquick/canvas/tiger/tiger.js | 721 +++++++++++++++++ examples/qtquick/canvas/tiger/tiger.qml | 129 +++ .../qtquick/canvas/twitterfriends/TwitterUser.qml | 294 +++++++ examples/qtquick/canvas/twitterfriends/cache.js | 42 + examples/qtquick/canvas/twitterfriends/twitter.qml | 141 ++++ examples/qtquick/draganddrop/dragtarget.qmlproject | 14 + examples/qtquick/draganddrop/tiles/DragTile.qml | 89 +++ examples/qtquick/draganddrop/tiles/DropTile.qml | 68 ++ examples/qtquick/draganddrop/tiles/tiles.qml | 109 +++ examples/qtquick/draganddrop/views/gridview.qml | 117 +++ examples/qtquick/imageelements/borderimage.qml | 103 +++ .../qtquick/imageelements/content/BearSheet.png | Bin 0 -> 406337 bytes .../qtquick/imageelements/content/ImageCell.qml | 60 ++ .../imageelements/content/MyBorderImage.qml | 90 +++ .../imageelements/content/ShadowRectangle.qml | 54 ++ examples/qtquick/imageelements/content/bw.png | Bin 0 -> 1357 bytes .../qtquick/imageelements/content/colors-round.sci | 7 + .../imageelements/content/colors-stretch.sci | 5 + examples/qtquick/imageelements/content/colors.png | Bin 0 -> 1655 bytes examples/qtquick/imageelements/content/qt-logo.png | Bin 0 -> 5149 bytes examples/qtquick/imageelements/content/shadow.png | Bin 0 -> 588 bytes examples/qtquick/imageelements/content/speaker.png | Bin 0 -> 784525 bytes examples/qtquick/imageelements/image.qml | 72 ++ examples/qtquick/imageelements/imageelements.qml | 58 ++ .../qtquick/imageelements/imageelements.qmlproject | 16 + examples/qtquick/imageelements/shadows.qml | 64 ++ examples/qtquick/imageelements/simplesprite.qml | 59 ++ examples/qtquick/imageelements/spriteimage.qml | 116 +++ .../keyinteraction/focus/Core/ContextMenu.qml | 65 ++ .../qtquick/keyinteraction/focus/Core/GridMenu.qml | 105 +++ .../qtquick/keyinteraction/focus/Core/ListMenu.qml | 105 +++ .../keyinteraction/focus/Core/ListViewDelegate.qml | 85 ++ .../keyinteraction/focus/Core/images/arrow.png | Bin 0 -> 583 bytes .../keyinteraction/focus/Core/images/qt-logo.png | Bin 0 -> 5149 bytes examples/qtquick/keyinteraction/focus/focus.qml | 111 +++ .../abstractitemmodel/abstractitemmodel.pro | 10 + .../abstractitemmodel/abstractitemmodel.qrc | 6 + .../qtquick/modelviews/abstractitemmodel/main.cpp | 70 ++ .../qtquick/modelviews/abstractitemmodel/model.cpp | 90 +++ .../qtquick/modelviews/abstractitemmodel/model.h | 83 ++ .../qtquick/modelviews/abstractitemmodel/view.qml | 50 ++ .../modelviews/gridview/gridview-example.qml | 93 +++ .../modelviews/gridview/pics/AddressBook_48.png | Bin 0 -> 3350 bytes .../modelviews/gridview/pics/AudioPlayer_48.png | Bin 0 -> 3806 bytes .../qtquick/modelviews/gridview/pics/Camera_48.png | Bin 0 -> 3540 bytes .../modelviews/gridview/pics/DateBook_48.png | Bin 0 -> 2610 bytes .../qtquick/modelviews/gridview/pics/EMail_48.png | Bin 0 -> 3655 bytes .../modelviews/gridview/pics/TodoList_48.png | Bin 0 -> 3429 bytes .../modelviews/gridview/pics/VideoPlayer_48.png | Bin 0 -> 4151 bytes .../modelviews/listview/content/PetsModel.qml | 98 +++ .../listview/content/PressAndHoldButton.qml | 82 ++ .../modelviews/listview/content/RecipesModel.qml | 129 +++ .../modelviews/listview/content/TextButton.qml | 78 ++ .../modelviews/listview/content/ToggleButton.qml | 58 ++ .../listview/content/pics/arrow-down.png | Bin 0 -> 594 bytes .../modelviews/listview/content/pics/arrow-up.png | Bin 0 -> 692 bytes .../listview/content/pics/fruit-salad.jpg | Bin 0 -> 17952 bytes .../modelviews/listview/content/pics/hamburger.jpg | Bin 0 -> 8572 bytes .../modelviews/listview/content/pics/lemonade.jpg | Bin 0 -> 6645 bytes .../listview/content/pics/list-delete.png | Bin 0 -> 831 bytes .../listview/content/pics/minus-sign.png | Bin 0 -> 250 bytes .../modelviews/listview/content/pics/moreDown.png | Bin 0 -> 217 bytes .../modelviews/listview/content/pics/moreUp.png | Bin 0 -> 212 bytes .../modelviews/listview/content/pics/pancakes.jpg | Bin 0 -> 9163 bytes .../modelviews/listview/content/pics/plus-sign.png | Bin 0 -> 462 bytes .../listview/content/pics/vegetable-soup.jpg | Bin 0 -> 8639 bytes .../qtquick/modelviews/listview/dynamiclist.qml | 203 +++++ .../modelviews/listview/expandingdelegates.qml | 202 +++++ examples/qtquick/modelviews/listview/highlight.qml | 99 +++ .../modelviews/listview/highlightranges.qml | 122 +++ examples/qtquick/modelviews/listview/sections.qml | 127 +++ examples/qtquick/modelviews/modelviews.pro | 8 + examples/qtquick/modelviews/modelviews.qml | 64 ++ examples/qtquick/modelviews/modelviews.qmlproject | 16 + .../modelviews/objectlistmodel/dataobject.cpp | 78 ++ .../modelviews/objectlistmodel/dataobject.h | 76 ++ .../qtquick/modelviews/objectlistmodel/main.cpp | 78 ++ .../modelviews/objectlistmodel/objectlistmodel.pro | 6 + .../objectlistmodel/objectlistmodel.qmlproject | 14 + .../modelviews/objectlistmodel/objectlistmodel.qrc | 5 + .../qtquick/modelviews/objectlistmodel/view.qml | 55 ++ examples/qtquick/modelviews/package/Delegate.qml | 88 +++ examples/qtquick/modelviews/package/view.qml | 80 ++ .../qtquick/modelviews/parallax/content/Clock.qml | 143 ++++ .../modelviews/parallax/content/ParallaxView.qml | 123 +++ .../modelviews/parallax/content/QuitButton.qml | 52 ++ .../qtquick/modelviews/parallax/content/Smiley.qml | 84 ++ .../modelviews/parallax/content/background.png | Bin 0 -> 46895 bytes .../qtquick/modelviews/parallax/content/center.png | Bin 0 -> 765 bytes .../modelviews/parallax/content/clock-night.png | Bin 0 -> 23359 bytes .../qtquick/modelviews/parallax/content/clock.png | Bin 0 -> 20653 bytes .../qtquick/modelviews/parallax/content/hour.png | Bin 0 -> 625 bytes .../qtquick/modelviews/parallax/content/minute.png | Bin 0 -> 625 bytes .../parallax/content/pics/background.jpg | Bin 0 -> 209814 bytes .../parallax/content/pics/face-smile.png | Bin 0 -> 15408 bytes .../modelviews/parallax/content/pics/home-page.png | Bin 0 -> 3051 bytes .../modelviews/parallax/content/pics/home-page.svg | 445 +++++++++++ .../modelviews/parallax/content/pics/shadow.png | Bin 0 -> 425 bytes .../parallax/content/pics/yast-joystick.png | Bin 0 -> 2723 bytes .../modelviews/parallax/content/pics/yast-wol.png | Bin 0 -> 3769 bytes .../qtquick/modelviews/parallax/content/quit.png | Bin 0 -> 583 bytes .../qtquick/modelviews/parallax/content/second.png | Bin 0 -> 303 bytes examples/qtquick/modelviews/parallax/parallax.qml | 76 ++ .../modelviews/pathview/pathview-example.qml | 107 +++ .../modelviews/pathview/pics/AddressBook_48.png | Bin 0 -> 3350 bytes .../modelviews/pathview/pics/AudioPlayer_48.png | Bin 0 -> 3806 bytes .../qtquick/modelviews/pathview/pics/Camera_48.png | Bin 0 -> 3540 bytes .../modelviews/pathview/pics/DateBook_48.png | Bin 0 -> 2610 bytes .../qtquick/modelviews/pathview/pics/EMail_48.png | Bin 0 -> 3655 bytes .../modelviews/pathview/pics/TodoList_48.png | Bin 0 -> 3429 bytes .../modelviews/pathview/pics/VideoPlayer_48.png | Bin 0 -> 4151 bytes .../qtquick/modelviews/stringlistmodel/main.cpp | 77 ++ .../modelviews/stringlistmodel/stringlistmodel.pro | 4 + .../modelviews/stringlistmodel/stringlistmodel.qrc | 5 + .../qtquick/modelviews/stringlistmodel/view.qml | 54 ++ .../modelviews/visualdatamodel/dragselection.qml | 200 +++++ .../modelviews/visualdatamodel/slideshow.qml | 156 ++++ .../modelviews/visualdatamodel/sortedmodel.qml | 141 ++++ .../visualdatamodel/visualdatamodel.qmlproject | 14 + .../modelviews/visualitemmodel/visualitemmodel.qml | 116 +++ examples/qtquick/mousearea/mousearea-example.qml | 176 +++++ examples/qtquick/openglunderqml/main.cpp | 60 ++ examples/qtquick/openglunderqml/main.qml | 78 ++ examples/qtquick/openglunderqml/openglunderqml.pro | 6 + examples/qtquick/openglunderqml/squircle.cpp | 123 +++ examples/qtquick/openglunderqml/squircle.h | 76 ++ examples/qtquick/painteditem/painteditem.pro | 5 + examples/qtquick/painteditem/smile/main.cpp | 96 +++ examples/qtquick/painteditem/smile/smile.pro | 11 + examples/qtquick/painteditem/smile/smile.qml | 132 ++++ .../textballoons/TextBalloonPlugin/plugin.h | 55 ++ .../textballoons/TextBalloonPlugin/qmldir | 1 + .../painteditem/textballoons/textballoon.cpp | 92 +++ .../qtquick/painteditem/textballoons/textballoon.h | 68 ++ .../painteditem/textballoons/textballoons.pro | 25 + .../painteditem/textballoons/textballoons.qml | 110 +++ examples/qtquick/positioners/content/Button.qml | 78 ++ examples/qtquick/positioners/content/add.png | Bin 0 -> 810 bytes examples/qtquick/positioners/content/del.png | Bin 0 -> 488 bytes .../positioners/positioners-attachedproperties.qml | 106 +++ examples/qtquick/positioners/positioners.qml | 268 +++++++ examples/qtquick/qtquick.pro | 17 + .../layoutdirection/layoutdirection.qml | 246 ++++++ .../layoutdirection/layoutdirection.qmlproject | 16 + .../layoutmirroring/layoutmirroring.qml | 313 ++++++++ .../layoutmirroring/layoutmirroring.qmlproject | 16 + .../righttoleft/textalignment/textalignment.qml | 427 ++++++++++ .../textalignment/textalignment.qmlproject | 16 + examples/qtquick/shadereffects/content/Slider.qml | 93 +++ .../qtquick/shadereffects/content/face-smile.png | Bin 0 -> 15408 bytes examples/qtquick/shadereffects/content/qt-logo.png | Bin 0 -> 13923 bytes examples/qtquick/shadereffects/shadereffects.qml | 315 ++++++++ examples/qtquick/text/fonts/availableFonts.qml | 57 ++ examples/qtquick/text/fonts/banner.qml | 61 ++ .../text/fonts/content/fonts/tarzeau_ocr_a.ttf | Bin 0 -> 24544 bytes examples/qtquick/text/fonts/fonts.qml | 104 +++ examples/qtquick/text/fonts/hello.qml | 79 ++ examples/qtquick/text/imgtag/TextWithImage.qml | 55 ++ examples/qtquick/text/imgtag/images/face-sad.png | Bin 0 -> 6148 bytes .../qtquick/text/imgtag/images/face-smile-big.png | Bin 0 -> 6058 bytes examples/qtquick/text/imgtag/images/face-smile.png | Bin 0 -> 6446 bytes examples/qtquick/text/imgtag/images/heart200.png | Bin 0 -> 8248 bytes examples/qtquick/text/imgtag/images/qtlogo.png | Bin 0 -> 6450 bytes examples/qtquick/text/imgtag/images/starfish_2.png | Bin 0 -> 18243 bytes examples/qtquick/text/imgtag/imgtag.qml | 101 +++ examples/qtquick/text/styledtext-layout.qml | 107 +++ examples/qtquick/text/text.qml | 57 ++ examples/qtquick/text/text.qmlproject | 16 + .../qtquick/text/textselection/pics/endHandle.png | Bin 0 -> 185 bytes .../qtquick/text/textselection/pics/endHandle.sci | 5 + .../text/textselection/pics/startHandle.png | Bin 0 -> 178 bytes .../text/textselection/pics/startHandle.sci | 5 + .../qtquick/text/textselection/textselection.qml | 211 +++++ .../threading/threadedlistmodel/dataloader.js | 49 ++ .../threadedlistmodel/threadedlistmodel.qmlproject | 56 ++ .../threading/threadedlistmodel/timedisplay.qml | 76 ++ .../qtquick/threading/workerscript/workerscript.js | 15 + .../threading/workerscript/workerscript.qml | 83 ++ .../threading/workerscript/workerscript.qmlproject | 16 + .../touchinteraction/multipointtouch/bearwhack.qml | 133 ++++ .../content/AugmentedTouchPoint.qml | 70 ++ .../multipointtouch/content/Bear0.png | Bin 0 -> 15163 bytes .../multipointtouch/content/Bear1.png | Bin 0 -> 99378 bytes .../multipointtouch/content/Bear2.png | Bin 0 -> 80759 bytes .../multipointtouch/content/Bear3.png | Bin 0 -> 21122 bytes .../multipointtouch/content/BearB.png | Bin 0 -> 18667 bytes .../content/BearWhackParticleSystem.qml | 180 +++++ .../multipointtouch/content/ParticleFlame.qml | 65 ++ .../multipointtouch/content/blur-circle.png | Bin 0 -> 4279 bytes .../multipointtouch/content/blur-circle3.png | Bin 0 -> 5148 bytes .../multipointtouch/content/heart-blur.png | Bin 0 -> 5406 bytes .../multipointtouch/content/title.png | Bin 0 -> 81252 bytes .../multipointtouch/multiflame.qml | 91 +++ .../touchinteraction/pincharea/flickresize.qml | 97 +++ .../qtquick/touchinteraction/pincharea/qt-logo.jpg | Bin 0 -> 40886 bytes .../qtquick/touchinteraction/touchinteraction.qml | 56 ++ .../touchinteraction/touchinteraction.qmlproject | 16 + examples/shared/Button.qml | 64 ++ examples/shared/LauncherList.qml | 102 +++ examples/shared/README | 11 + examples/shared/SimpleLauncherDelegate.qml | 53 ++ examples/shared/images/back.png | Bin 0 -> 404 bytes examples/shared/qmldir | 3 + examples/shared/shared.h | 49 ++ examples/shared/shared.pro | 9 + .../dynamicview/dynamicview1/PetsModel.qml | 102 +++ .../dynamicview/dynamicview1/dynamicview.qml | 90 +++ .../dynamicview/dynamicview2/PetsModel.qml | 98 +++ .../dynamicview/dynamicview2/dynamicview.qml | 121 +++ .../dynamicview/dynamicview3/PetsModel.qml | 98 +++ .../dynamicview/dynamicview3/dynamicview.qml | 143 ++++ .../dynamicview/dynamicview4/ListSelector.qml | 120 +++ .../dynamicview/dynamicview4/PetsModel.qml | 98 +++ .../dynamicview/dynamicview4/dynamicview.qml | 219 ++++++ .../tutorials/extending/chapter1-basics/app.qml | 60 ++ .../extending/chapter1-basics/chapter1-basics.pro | 5 + .../tutorials/extending/chapter1-basics/main.cpp | 57 ++ .../extending/chapter1-basics/piechart.cpp | 79 ++ .../tutorials/extending/chapter1-basics/piechart.h | 71 ++ .../tutorials/extending/chapter2-methods/app.qml | 66 ++ .../chapter2-methods/chapter2-methods.pro | 5 + .../tutorials/extending/chapter2-methods/main.cpp | 57 ++ .../extending/chapter2-methods/piechart.cpp | 84 ++ .../extending/chapter2-methods/piechart.h | 84 ++ .../tutorials/extending/chapter3-bindings/app.qml | 74 ++ .../chapter3-bindings/chapter3-bindings.pro | 5 + .../tutorials/extending/chapter3-bindings/main.cpp | 57 ++ .../extending/chapter3-bindings/piechart.cpp | 86 ++ .../extending/chapter3-bindings/piechart.h | 84 ++ .../extending/chapter4-customPropertyTypes/app.qml | 60 ++ .../chapter4-customPropertyTypes.pro | 7 + .../chapter4-customPropertyTypes/main.cpp | 66 ++ .../chapter4-customPropertyTypes/piechart.cpp | 70 ++ .../chapter4-customPropertyTypes/piechart.h | 78 ++ .../chapter4-customPropertyTypes/pieslice.cpp | 66 ++ .../chapter4-customPropertyTypes/pieslice.h | 66 ++ .../extending/chapter5-listproperties/app.qml | 70 ++ .../chapter5-listproperties.pro | 7 + .../extending/chapter5-listproperties/main.cpp | 58 ++ .../extending/chapter5-listproperties/piechart.cpp | 72 ++ .../extending/chapter5-listproperties/piechart.h | 75 ++ .../extending/chapter5-listproperties/pieslice.cpp | 86 ++ .../extending/chapter5-listproperties/pieslice.h | 76 ++ .../extending/chapter6-plugins/ChartsPlugin/qmldir | 1 + .../tutorials/extending/chapter6-plugins/app.qml | 69 ++ .../chapter6-plugins/chapter6-plugins.pro | 18 + .../extending/chapter6-plugins/chartsplugin.cpp | 53 ++ .../extending/chapter6-plugins/chartsplugin.h | 57 ++ .../extending/chapter6-plugins/piechart.cpp | 71 ++ .../extending/chapter6-plugins/piechart.h | 69 ++ .../extending/chapter6-plugins/pieslice.cpp | 86 ++ .../extending/chapter6-plugins/pieslice.h | 74 ++ examples/tutorials/extending/extending.pro | 10 + examples/tutorials/helloworld/Cell.qml | 72 ++ examples/tutorials/helloworld/tutorial1.qml | 63 ++ examples/tutorials/helloworld/tutorial2.qml | 72 ++ examples/tutorials/helloworld/tutorial3.qml | 91 +++ examples/tutorials/samegame/samegame1/Block.qml | 53 ++ examples/tutorials/samegame/samegame1/Button.qml | 83 ++ examples/tutorials/samegame/samegame1/samegame.qml | 82 ++ .../samegame/samegame1/samegame1.qmlproject | 16 + examples/tutorials/samegame/samegame2/Block.qml | 51 ++ examples/tutorials/samegame/samegame2/Button.qml | 81 ++ examples/tutorials/samegame/samegame2/samegame.js | 63 ++ examples/tutorials/samegame/samegame2/samegame.qml | 85 ++ .../samegame/samegame2/samegame2.qmlproject | 16 + examples/tutorials/samegame/samegame3/Block.qml | 63 ++ examples/tutorials/samegame/samegame3/Button.qml | 81 ++ examples/tutorials/samegame/samegame3/Dialog.qml | 71 ++ examples/tutorials/samegame/samegame3/samegame.js | 174 +++++ examples/tutorials/samegame/samegame3/samegame.qml | 109 +++ .../samegame/samegame3/samegame3.qmlproject | 16 + .../samegame/samegame4/content/BoomBlock.qml | 122 +++ .../samegame/samegame4/content/Button.qml | 81 ++ .../samegame/samegame4/content/Dialog.qml | 107 +++ .../samegame/samegame4/content/samegame.js | 226 ++++++ .../tutorials/samegame/samegame4/highscores/README | 1 + .../samegame/samegame4/highscores/score_data.xml | 2 + .../samegame/samegame4/highscores/score_style.xsl | 28 + .../samegame/samegame4/highscores/scores.php | 31 + examples/tutorials/samegame/samegame4/samegame.qml | 115 +++ .../samegame/samegame4/samegame4.qmlproject | 16 + .../tutorials/samegame/shared/pics/background.jpg | Bin 0 -> 36473 bytes .../tutorials/samegame/shared/pics/blueStar.png | Bin 0 -> 278 bytes .../tutorials/samegame/shared/pics/blueStone.png | Bin 0 -> 3054 bytes .../tutorials/samegame/shared/pics/greenStar.png | Bin 0 -> 273 bytes .../tutorials/samegame/shared/pics/greenStone.png | Bin 0 -> 2932 bytes .../tutorials/samegame/shared/pics/redStar.png | Bin 0 -> 274 bytes .../tutorials/samegame/shared/pics/redStone.png | Bin 0 -> 2902 bytes examples/tutorials/samegame/shared/pics/star.png | Bin 0 -> 262 bytes .../tutorials/samegame/shared/pics/yellowStone.png | Bin 0 -> 3056 bytes .../ui-components/dialcontrol/content/Dial.qml | 86 ++ .../dialcontrol/content/QuitButton.qml | 52 ++ .../dialcontrol/content/background.png | Bin 0 -> 35876 bytes .../ui-components/dialcontrol/content/needle.png | Bin 0 -> 342 bytes .../dialcontrol/content/needle_shadow.png | Bin 0 -> 632 bytes .../ui-components/dialcontrol/content/overlay.png | Bin 0 -> 3564 bytes .../ui-components/dialcontrol/content/quit.png | Bin 0 -> 583 bytes .../ui-components/dialcontrol/dialcontrol.qml | 98 +++ .../ui-components/flipable/content/5_heart.png | Bin 0 -> 3872 bytes .../ui-components/flipable/content/9_club.png | Bin 0 -> 6135 bytes .../ui-components/flipable/content/Card.qml | 80 ++ .../ui-components/flipable/content/back.png | Bin 0 -> 1418 bytes .../tutorials/ui-components/flipable/flipable.qml | 55 ++ .../progressbar/content/ProgressBar.qml | 83 ++ .../progressbar/content/background.png | Bin 0 -> 426 bytes .../tutorials/ui-components/progressbar/main.qml | 73 ++ .../ui-components/scrollbar/ScrollBar.qml | 74 ++ .../tutorials/ui-components/scrollbar/main.qml | 93 +++ .../ui-components/scrollbar/pics/niagara_falls.jpg | Bin 0 -> 142510 bytes .../ui-components/scrollbar/scrollbar.qmlproject | 16 + .../ui-components/searchbox/SearchBox.qml | 109 +++ .../ui-components/searchbox/images/clear.png | Bin 0 -> 429 bytes .../searchbox/images/lineedit-bg-focus.png | Bin 0 -> 526 bytes .../ui-components/searchbox/images/lineedit-bg.png | Bin 0 -> 426 bytes .../tutorials/ui-components/searchbox/main.qml | 60 ++ .../ui-components/searchbox/searchbox.qmlproject | 16 + .../ui-components/slideswitch/content/Switch.qml | 117 +++ .../slideswitch/content/background.png | Bin 0 -> 3091 bytes .../slideswitch/content/background.svg | 23 + .../ui-components/slideswitch/content/knob.png | Bin 0 -> 3101 bytes .../ui-components/slideswitch/content/knob.svg | 867 +++++++++++++++++++++ .../ui-components/slideswitch/slideswitch.qml | 51 ++ .../ui-components/spinner/content/Spinner.qml | 70 ++ .../ui-components/spinner/content/spinner-bg.png | Bin 0 -> 345 bytes .../spinner/content/spinner-select.png | Bin 0 -> 320 bytes examples/tutorials/ui-components/spinner/main.qml | 61 ++ .../ui-components/spinner/spinner.qmlproject | 16 + .../ui-components/tabwidget/TabWidget.qml | 102 +++ .../tutorials/ui-components/tabwidget/main.qml | 99 +++ examples/tutorials/ui-components/tabwidget/tab.png | Bin 0 -> 507 bytes .../ui-components/tabwidget/tabwidget.qmlproject | 16 + examples/window/Window.qml | 58 ++ examples/window/screen/screenInfo.qml | 90 +++ examples/window/standalone.qml | 71 ++ examples/window/window.cpp | 58 ++ examples/window/window.pro | 5 + tests/auto/qtquick2/examples/tst_examples.cpp | 25 +- 1727 files changed, 47784 insertions(+), 47796 deletions(-) create mode 100644 examples/HACKING create mode 100644 examples/README delete mode 100644 examples/declarative/README delete mode 100644 examples/declarative/accessibility/accessibility.qml delete mode 100644 examples/declarative/accessibility/widgets/Button.qml delete mode 100644 examples/declarative/animation/animation.qml delete mode 100644 examples/declarative/animation/animation.qmlproject delete mode 100644 examples/declarative/animation/basics/color-animation.qml delete mode 100644 examples/declarative/animation/basics/images/face-smile.png delete mode 100644 examples/declarative/animation/basics/images/moon.png delete mode 100644 examples/declarative/animation/basics/images/shadow.png delete mode 100644 examples/declarative/animation/basics/images/star.png delete mode 100644 examples/declarative/animation/basics/images/sun.png delete mode 100644 examples/declarative/animation/basics/property-animation.qml delete mode 100644 examples/declarative/animation/behaviors/SideRect.qml delete mode 100644 examples/declarative/animation/behaviors/behavior-example.qml delete mode 100644 examples/declarative/animation/behaviors/wigglytext.qml delete mode 100644 examples/declarative/animation/easing/content/QuitButton.qml delete mode 100644 examples/declarative/animation/easing/content/quit.png delete mode 100644 examples/declarative/animation/easing/easing.qml delete mode 100644 examples/declarative/animation/pathanimation/pathanimation.qml delete mode 100644 examples/declarative/animation/pathinterpolator/pathinterpolator.qml delete mode 100644 examples/declarative/animation/states/qt-logo.png delete mode 100644 examples/declarative/animation/states/states.qml delete mode 100644 examples/declarative/animation/states/transitions.qml delete mode 100644 examples/declarative/calculator/calculator.qml delete mode 100644 examples/declarative/calculator/content/Button.qml delete mode 100644 examples/declarative/calculator/content/Display.qml delete mode 100644 examples/declarative/calculator/content/calculator.js delete mode 100644 examples/declarative/calculator/content/images/button-.png delete mode 100644 examples/declarative/calculator/content/images/button-blue.png delete mode 100644 examples/declarative/calculator/content/images/button-green.png delete mode 100644 examples/declarative/calculator/content/images/button-purple.png delete mode 100644 examples/declarative/calculator/content/images/button-red.png delete mode 100644 examples/declarative/calculator/content/images/display.png delete mode 100644 examples/declarative/calculator/content/qmldir delete mode 100644 examples/declarative/canvas/bezierCurve/bezierCurve.qml delete mode 100644 examples/declarative/canvas/clip/clip.qml delete mode 100644 examples/declarative/canvas/contents/Button.qml delete mode 100644 examples/declarative/canvas/contents/ScrollBar.qml delete mode 100644 examples/declarative/canvas/contents/Slider.qml delete mode 100644 examples/declarative/canvas/contents/Stocks.qml delete mode 100644 examples/declarative/canvas/contents/TitleBar.qml delete mode 100644 examples/declarative/canvas/contents/ToolBar.qml delete mode 100644 examples/declarative/canvas/contents/images/button-pressed.png delete mode 100644 examples/declarative/canvas/contents/images/button.png delete mode 100644 examples/declarative/canvas/contents/images/default.svg delete mode 100755 examples/declarative/canvas/contents/images/gloss.png delete mode 100755 examples/declarative/canvas/contents/images/lineedit.png delete mode 100644 examples/declarative/canvas/contents/images/lineedit.sci delete mode 100755 examples/declarative/canvas/contents/images/quit.png delete mode 100755 examples/declarative/canvas/contents/images/stripes.png delete mode 100755 examples/declarative/canvas/contents/images/titlebar.png delete mode 100644 examples/declarative/canvas/contents/images/titlebar.sci delete mode 100755 examples/declarative/canvas/contents/images/toolbutton.png delete mode 100644 examples/declarative/canvas/contents/images/toolbutton.sci delete mode 100644 examples/declarative/canvas/contents/qt-logo.png delete mode 100644 examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml delete mode 100644 examples/declarative/canvas/roundedrect/roundedrect.qml delete mode 100644 examples/declarative/canvas/smile/smile.qml delete mode 100644 examples/declarative/canvas/squircle/squircle.png delete mode 100644 examples/declarative/canvas/squircle/squircle.qml delete mode 100644 examples/declarative/canvas/stockchart/README delete mode 100644 examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir delete mode 100644 examples/declarative/canvas/stockchart/model.cpp delete mode 100644 examples/declarative/canvas/stockchart/model.h delete mode 100644 examples/declarative/canvas/stockchart/plugin.cpp delete mode 100644 examples/declarative/canvas/stockchart/stock.qml delete mode 100644 examples/declarative/canvas/stockchart/stockchart.pro delete mode 100644 examples/declarative/canvas/tiger/tiger.js delete mode 100644 examples/declarative/canvas/tiger/tiger.qml delete mode 100644 examples/declarative/canvas/twitterfriends/TwitterUser.qml delete mode 100644 examples/declarative/canvas/twitterfriends/cache.js delete mode 100644 examples/declarative/canvas/twitterfriends/twitter.qml delete mode 100644 examples/declarative/cppextensions/cppextensions.pro delete mode 100644 examples/declarative/cppextensions/cppextensions.qmlproject delete mode 100644 examples/declarative/cppextensions/imageprovider/ImageProviderCore/qmldir delete mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider-example.qml delete mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.cpp delete mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.pro delete mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject delete mode 100644 examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp delete mode 100644 examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro delete mode 100644 examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject delete mode 100644 examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc delete mode 100644 examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml delete mode 100644 examples/declarative/cppextensions/plugins/README delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png delete mode 100644 examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir delete mode 100644 examples/declarative/cppextensions/plugins/plugin.cpp delete mode 100644 examples/declarative/cppextensions/plugins/plugins.pro delete mode 100644 examples/declarative/cppextensions/plugins/plugins.qml delete mode 100644 examples/declarative/cppextensions/plugins/plugins.qmlproject delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/adding.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/adding.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/adding/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/attached.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/attached.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/attached/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/binding.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/binding.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/binding/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/coercion/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/default.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/default.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/default/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/extended.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/extended.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/lineedit.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/extended/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/grouped/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/methods.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/methods.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/methods/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/properties.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/properties/properties.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/referenceexamples.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/signal.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/signal/signal.qrc delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/example.qml delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/person.h delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro delete mode 100644 examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc delete mode 100644 examples/declarative/declarative.pro delete mode 100644 examples/declarative/draganddrop/dragtarget.qmlproject delete mode 100644 examples/declarative/draganddrop/tiles/DragTile.qml delete mode 100644 examples/declarative/draganddrop/tiles/DropTile.qml delete mode 100644 examples/declarative/draganddrop/tiles/tiles.qml delete mode 100644 examples/declarative/draganddrop/views/gridview.qml delete mode 100644 examples/declarative/flickr/content/Button.qml delete mode 100644 examples/declarative/flickr/content/GridDelegate.qml delete mode 100644 examples/declarative/flickr/content/ImageDetails.qml delete mode 100644 examples/declarative/flickr/content/ListDelegate.qml delete mode 100644 examples/declarative/flickr/content/Progress.qml delete mode 100644 examples/declarative/flickr/content/RssModel.qml delete mode 100644 examples/declarative/flickr/content/ScrollBar.qml delete mode 100644 examples/declarative/flickr/content/Slider.qml delete mode 100644 examples/declarative/flickr/content/TitleBar.qml delete mode 100644 examples/declarative/flickr/content/ToolBar.qml delete mode 100644 examples/declarative/flickr/content/UnifiedDelegate.qml delete mode 100644 examples/declarative/flickr/content/images/gloss.png delete mode 100644 examples/declarative/flickr/content/images/lineedit.png delete mode 100644 examples/declarative/flickr/content/images/lineedit.sci delete mode 100644 examples/declarative/flickr/content/images/noise.png delete mode 100644 examples/declarative/flickr/content/images/particle.png delete mode 100644 examples/declarative/flickr/content/images/quit.png delete mode 100644 examples/declarative/flickr/content/images/squareParticle.png delete mode 100644 examples/declarative/flickr/content/images/stripes.png delete mode 100644 examples/declarative/flickr/content/images/titlebar.png delete mode 100644 examples/declarative/flickr/content/images/titlebar.sci delete mode 100644 examples/declarative/flickr/content/images/toolbutton.png delete mode 100644 examples/declarative/flickr/content/images/toolbutton.sci delete mode 100644 examples/declarative/flickr/content/qmldir delete mode 100644 examples/declarative/flickr/flickr-90.qml delete mode 100644 examples/declarative/flickr/flickr.qml delete mode 100644 examples/declarative/flickr/flickr.qmlproject delete mode 100644 examples/declarative/i18n/i18n.qml delete mode 100644 examples/declarative/i18n/i18n/base.ts delete mode 100644 examples/declarative/i18n/i18n/qml_en_AU.ts delete mode 100644 examples/declarative/i18n/i18n/qml_fr.ts delete mode 100644 examples/declarative/imageelements/borderimage.qml delete mode 100644 examples/declarative/imageelements/content/BearSheet.png delete mode 100644 examples/declarative/imageelements/content/ImageCell.qml delete mode 100644 examples/declarative/imageelements/content/MyBorderImage.qml delete mode 100644 examples/declarative/imageelements/content/ShadowRectangle.qml delete mode 100644 examples/declarative/imageelements/content/bw.png delete mode 100644 examples/declarative/imageelements/content/colors-round.sci delete mode 100644 examples/declarative/imageelements/content/colors-stretch.sci delete mode 100644 examples/declarative/imageelements/content/colors.png delete mode 100644 examples/declarative/imageelements/content/qt-logo.png delete mode 100644 examples/declarative/imageelements/content/shadow.png delete mode 100644 examples/declarative/imageelements/content/speaker.png delete mode 100644 examples/declarative/imageelements/image.qml delete mode 100644 examples/declarative/imageelements/imageelements.qml delete mode 100644 examples/declarative/imageelements/imageelements.qmlproject delete mode 100644 examples/declarative/imageelements/shadows.qml delete mode 100644 examples/declarative/imageelements/simplesprite.qml delete mode 100644 examples/declarative/imageelements/spriteimage.qml delete mode 100644 examples/declarative/keyinteraction/focus/Core/ContextMenu.qml delete mode 100644 examples/declarative/keyinteraction/focus/Core/GridMenu.qml delete mode 100644 examples/declarative/keyinteraction/focus/Core/ListMenu.qml delete mode 100644 examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml delete mode 100644 examples/declarative/keyinteraction/focus/Core/images/arrow.png delete mode 100644 examples/declarative/keyinteraction/focus/Core/images/qt-logo.png delete mode 100644 examples/declarative/keyinteraction/focus/focus.qml delete mode 100644 examples/declarative/locale/locale.qml delete mode 100644 examples/declarative/minehunt/MinehuntCore/Explosion.qml delete mode 100644 examples/declarative/minehunt/MinehuntCore/Tile.qml delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/back.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/background.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/bomb-color.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/bomb.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/face-sad.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/face-smile.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/flag-color.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/flag.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/front.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/quit.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/pics/star.png delete mode 100644 examples/declarative/minehunt/MinehuntCore/qmldir delete mode 100644 examples/declarative/minehunt/README delete mode 100644 examples/declarative/minehunt/main.cpp delete mode 100644 examples/declarative/minehunt/minehunt.cpp delete mode 100644 examples/declarative/minehunt/minehunt.h delete mode 100644 examples/declarative/minehunt/minehunt.pro delete mode 100644 examples/declarative/minehunt/minehunt.qml delete mode 100644 examples/declarative/minehunt/minehunt.qmlproject delete mode 100644 examples/declarative/minehunt/minehunt.qrc delete mode 100644 examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro delete mode 100644 examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc delete mode 100644 examples/declarative/modelviews/abstractitemmodel/main.cpp delete mode 100644 examples/declarative/modelviews/abstractitemmodel/model.cpp delete mode 100644 examples/declarative/modelviews/abstractitemmodel/model.h delete mode 100644 examples/declarative/modelviews/abstractitemmodel/view.qml delete mode 100644 examples/declarative/modelviews/gridview/gridview-example.qml delete mode 100644 examples/declarative/modelviews/gridview/pics/AddressBook_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/Camera_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/DateBook_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/EMail_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/TodoList_48.png delete mode 100644 examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png delete mode 100644 examples/declarative/modelviews/listview/content/PetsModel.qml delete mode 100644 examples/declarative/modelviews/listview/content/PressAndHoldButton.qml delete mode 100644 examples/declarative/modelviews/listview/content/RecipesModel.qml delete mode 100644 examples/declarative/modelviews/listview/content/TextButton.qml delete mode 100644 examples/declarative/modelviews/listview/content/ToggleButton.qml delete mode 100644 examples/declarative/modelviews/listview/content/pics/arrow-down.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/arrow-up.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg delete mode 100644 examples/declarative/modelviews/listview/content/pics/hamburger.jpg delete mode 100644 examples/declarative/modelviews/listview/content/pics/lemonade.jpg delete mode 100644 examples/declarative/modelviews/listview/content/pics/list-delete.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/minus-sign.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/moreDown.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/moreUp.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/pancakes.jpg delete mode 100644 examples/declarative/modelviews/listview/content/pics/plus-sign.png delete mode 100644 examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg delete mode 100644 examples/declarative/modelviews/listview/dynamiclist.qml delete mode 100644 examples/declarative/modelviews/listview/expandingdelegates.qml delete mode 100644 examples/declarative/modelviews/listview/highlight.qml delete mode 100644 examples/declarative/modelviews/listview/highlightranges.qml delete mode 100644 examples/declarative/modelviews/listview/sections.qml delete mode 100644 examples/declarative/modelviews/modelviews.pro delete mode 100644 examples/declarative/modelviews/modelviews.qml delete mode 100644 examples/declarative/modelviews/modelviews.qmlproject delete mode 100644 examples/declarative/modelviews/objectlistmodel/dataobject.cpp delete mode 100644 examples/declarative/modelviews/objectlistmodel/dataobject.h delete mode 100644 examples/declarative/modelviews/objectlistmodel/main.cpp delete mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro delete mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject delete mode 100644 examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc delete mode 100644 examples/declarative/modelviews/objectlistmodel/view.qml delete mode 100644 examples/declarative/modelviews/package/Delegate.qml delete mode 100644 examples/declarative/modelviews/package/view.qml delete mode 100644 examples/declarative/modelviews/parallax/content/ParallaxView.qml delete mode 100644 examples/declarative/modelviews/parallax/content/Smiley.qml delete mode 100644 examples/declarative/modelviews/parallax/content/pics/background.jpg delete mode 100644 examples/declarative/modelviews/parallax/content/pics/face-smile.png delete mode 100644 examples/declarative/modelviews/parallax/content/pics/home-page.png delete mode 100644 examples/declarative/modelviews/parallax/content/pics/home-page.svg delete mode 100644 examples/declarative/modelviews/parallax/content/pics/shadow.png delete mode 100644 examples/declarative/modelviews/parallax/content/pics/yast-joystick.png delete mode 100644 examples/declarative/modelviews/parallax/content/pics/yast-wol.png delete mode 100644 examples/declarative/modelviews/parallax/parallax.qml delete mode 100644 examples/declarative/modelviews/pathview/pathview-example.qml delete mode 100644 examples/declarative/modelviews/pathview/pics/AddressBook_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/Camera_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/DateBook_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/EMail_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/TodoList_48.png delete mode 100644 examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png delete mode 100644 examples/declarative/modelviews/stringlistmodel/main.cpp delete mode 100644 examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro delete mode 100644 examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc delete mode 100644 examples/declarative/modelviews/stringlistmodel/view.qml delete mode 100644 examples/declarative/modelviews/visualdatamodel/dragselection.qml delete mode 100644 examples/declarative/modelviews/visualdatamodel/slideshow.qml delete mode 100644 examples/declarative/modelviews/visualdatamodel/sortedmodel.qml delete mode 100644 examples/declarative/modelviews/visualdatamodel/visualdatamodel.qmlproject delete mode 100644 examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml delete mode 100644 examples/declarative/openglunderqml/main.cpp delete mode 100644 examples/declarative/openglunderqml/main.qml delete mode 100644 examples/declarative/openglunderqml/openglunderqml.pro delete mode 100644 examples/declarative/openglunderqml/squircle.cpp delete mode 100644 examples/declarative/openglunderqml/squircle.h delete mode 100644 examples/declarative/painteditem/painteditem.pro delete mode 100644 examples/declarative/painteditem/smile/main.cpp delete mode 100644 examples/declarative/painteditem/smile/smile.pro delete mode 100644 examples/declarative/painteditem/smile/smile.qml delete mode 100644 examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h delete mode 100644 examples/declarative/painteditem/textballoons/TextBalloonPlugin/qmldir delete mode 100644 examples/declarative/painteditem/textballoons/textballoon.cpp delete mode 100644 examples/declarative/painteditem/textballoons/textballoon.h delete mode 100644 examples/declarative/painteditem/textballoons/textballoons.pro delete mode 100644 examples/declarative/painteditem/textballoons/textballoons.qml delete mode 100644 examples/declarative/particles/affectors/age.qml delete mode 100644 examples/declarative/particles/affectors/attractor.qml delete mode 100644 examples/declarative/particles/affectors/customaffector.qml delete mode 100644 examples/declarative/particles/affectors/friction.qml delete mode 100644 examples/declarative/particles/affectors/gravity.qml delete mode 100644 examples/declarative/particles/affectors/groupgoal.qml delete mode 100644 examples/declarative/particles/affectors/move.qml delete mode 100644 examples/declarative/particles/affectors/spritegoal.qml delete mode 100644 examples/declarative/particles/affectors/turbulence.qml delete mode 100644 examples/declarative/particles/affectors/wander.qml delete mode 100644 examples/declarative/particles/customparticle/blurparticles.qml delete mode 100644 examples/declarative/particles/customparticle/fragmentshader.qml delete mode 100644 examples/declarative/particles/customparticle/imagecolors.qml delete mode 100644 examples/declarative/particles/emitters/burstandpulse.qml delete mode 100644 examples/declarative/particles/emitters/customemitter.qml delete mode 100644 examples/declarative/particles/emitters/emitmask.qml delete mode 100644 examples/declarative/particles/emitters/maximumemitted.qml delete mode 100644 examples/declarative/particles/emitters/shapeanddirection.qml delete mode 100644 examples/declarative/particles/emitters/timedgroupchanges.qml delete mode 100644 examples/declarative/particles/emitters/trailemitter.qml delete mode 100644 examples/declarative/particles/emitters/velocityfrommotion.qml delete mode 100644 examples/declarative/particles/exampleslauncher/content/Button.qml delete mode 100644 examples/declarative/particles/exampleslauncher/content/Shell.qml delete mode 100644 examples/declarative/particles/exampleslauncher/content/launcher.js delete mode 100644 examples/declarative/particles/exampleslauncher/exampleslauncher.qml delete mode 100644 examples/declarative/particles/imageparticle/allatonce.qml delete mode 100644 examples/declarative/particles/imageparticle/colored.qml delete mode 100644 examples/declarative/particles/imageparticle/colortable.qml delete mode 100644 examples/declarative/particles/imageparticle/deformation.qml delete mode 100644 examples/declarative/particles/imageparticle/rotation.qml delete mode 100644 examples/declarative/particles/imageparticle/sharing.qml delete mode 100644 examples/declarative/particles/imageparticle/sprites.qml delete mode 100644 examples/declarative/particles/images/_explo.png delete mode 100755 examples/declarative/particles/images/backgroundLeaves.jpg delete mode 100644 examples/declarative/particles/images/bear_tiles.png delete mode 100644 examples/declarative/particles/images/candle.png delete mode 100644 examples/declarative/particles/images/colortable.png delete mode 100644 examples/declarative/particles/images/finalfrontier.png delete mode 100644 examples/declarative/particles/images/flower.png delete mode 100644 examples/declarative/particles/images/launcherIcons/allatonce.png delete mode 100644 examples/declarative/particles/images/launcherIcons/attractor.png delete mode 100644 examples/declarative/particles/images/launcherIcons/blurparticles.png delete mode 100644 examples/declarative/particles/images/launcherIcons/close.png delete mode 100644 examples/declarative/particles/images/launcherIcons/colortable.png delete mode 100644 examples/declarative/particles/images/launcherIcons/customaffector.png delete mode 100644 examples/declarative/particles/images/launcherIcons/customemitter.png delete mode 100644 examples/declarative/particles/images/launcherIcons/deformation.png delete mode 100644 examples/declarative/particles/images/launcherIcons/delegates.png delete mode 100644 examples/declarative/particles/images/launcherIcons/dynamicemitters.png delete mode 100644 examples/declarative/particles/images/launcherIcons/emitmask.png delete mode 100644 examples/declarative/particles/images/launcherIcons/flickr.png delete mode 100644 examples/declarative/particles/images/launcherIcons/fragmentshader.png delete mode 100644 examples/declarative/particles/images/launcherIcons/gridsplosion.png delete mode 100644 examples/declarative/particles/images/launcherIcons/groupgoal.png delete mode 100644 examples/declarative/particles/images/launcherIcons/imagecolors.png delete mode 100644 examples/declarative/particles/images/launcherIcons/list.png delete mode 100644 examples/declarative/particles/images/launcherIcons/maximumemitted.png delete mode 100644 examples/declarative/particles/images/launcherIcons/multiplepainters.png delete mode 100644 examples/declarative/particles/images/launcherIcons/package.png delete mode 100644 examples/declarative/particles/images/launcherIcons/particleview.png delete mode 100644 examples/declarative/particles/images/launcherIcons/plasmapatrol.png delete mode 100644 examples/declarative/particles/images/launcherIcons/remove.png delete mode 100644 examples/declarative/particles/images/launcherIcons/rotation.png delete mode 100644 examples/declarative/particles/images/launcherIcons/samegame.png delete mode 100644 examples/declarative/particles/images/launcherIcons/shapeanddirection.png delete mode 100644 examples/declarative/particles/images/launcherIcons/spaceexplorer.png delete mode 100644 examples/declarative/particles/images/launcherIcons/spritegoal.png delete mode 100644 examples/declarative/particles/images/launcherIcons/sprites.png delete mode 100644 examples/declarative/particles/images/launcherIcons/spritevariedparticles.png delete mode 100644 examples/declarative/particles/images/launcherIcons/startstop.png delete mode 100644 examples/declarative/particles/images/launcherIcons/timedgroupchanges.png delete mode 100644 examples/declarative/particles/images/launcherIcons/trailemitter.png delete mode 100644 examples/declarative/particles/images/launcherIcons/trails.png delete mode 100644 examples/declarative/particles/images/launcherIcons/turbulence.png delete mode 100644 examples/declarative/particles/images/launcherIcons/velocityfrommotion.png delete mode 100644 examples/declarative/particles/images/launcherIcons/wander.png delete mode 100644 examples/declarative/particles/images/matchmask.png delete mode 100644 examples/declarative/particles/images/meteor.png delete mode 100644 examples/declarative/particles/images/meteor_explo.png delete mode 100644 examples/declarative/particles/images/meteors.png delete mode 100644 examples/declarative/particles/images/nullRock.png delete mode 100644 examples/declarative/particles/images/particle.png delete mode 100644 examples/declarative/particles/images/particle2.png delete mode 100644 examples/declarative/particles/images/particle3.png delete mode 100644 examples/declarative/particles/images/particle4.png delete mode 100644 examples/declarative/particles/images/particleA.png delete mode 100644 examples/declarative/particles/images/portal_bg.png delete mode 100644 examples/declarative/particles/images/realLeaf1.png delete mode 100644 examples/declarative/particles/images/realLeaf2.png delete mode 100644 examples/declarative/particles/images/realLeaf3.png delete mode 100644 examples/declarative/particles/images/realLeaf4.png delete mode 100644 examples/declarative/particles/images/rocket.png delete mode 100644 examples/declarative/particles/images/rocket2.png delete mode 100644 examples/declarative/particles/images/sizeInOut.png delete mode 100644 examples/declarative/particles/images/snowflake.png delete mode 100644 examples/declarative/particles/images/sparkleSize.png delete mode 100644 examples/declarative/particles/images/star.png delete mode 100644 examples/declarative/particles/images/starfish_0.png delete mode 100644 examples/declarative/particles/images/starfish_1.png delete mode 100644 examples/declarative/particles/images/starfish_2.png delete mode 100644 examples/declarative/particles/images/starfish_3.png delete mode 100644 examples/declarative/particles/images/starfish_4.png delete mode 100644 examples/declarative/particles/images/starfish_mask.png delete mode 100644 examples/declarative/particles/itemparticle/content/Delegate.qml delete mode 100644 examples/declarative/particles/itemparticle/content/Delegate2.qml delete mode 100644 examples/declarative/particles/itemparticle/content/ExpandingDelegate.qml delete mode 100644 examples/declarative/particles/itemparticle/content/RssModel.qml delete mode 100644 examples/declarative/particles/itemparticle/content/bubble.png delete mode 100644 examples/declarative/particles/itemparticle/content/script.js delete mode 100644 examples/declarative/particles/itemparticle/delegates.qml delete mode 100644 examples/declarative/particles/itemparticle/particleview.qml delete mode 100644 examples/declarative/particles/plasmapatrol/PlasmaPatrol.qmlproject delete mode 100644 examples/declarative/particles/plasmapatrol/TODO delete mode 100644 examples/declarative/particles/plasmapatrol/content/BlasterHardpoint.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Button.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/CannonHardpoint.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/ChoiceBox.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Cruiser.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Frigate.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Hardpoint.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/HelpScreens.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/LaserHardpoint.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/PlasmaPatrolParticles.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/SequentialLoader.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Ship.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/Sloop.qml delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/TitleText.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/blur-circle2.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/blur-circle3.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/finalfrontier.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/meteor.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/meteor_explo.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/nullRock.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/particle.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/star.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/star2.png delete mode 100644 examples/declarative/particles/plasmapatrol/content/pics/star3.png delete mode 100644 examples/declarative/particles/plasmapatrol/plasmapatrol.qml delete mode 100644 examples/declarative/particles/simple/dynamiccomparison.qml delete mode 100644 examples/declarative/particles/simple/dynamicemitters.qml delete mode 100644 examples/declarative/particles/simple/multiplepainters.qml delete mode 100644 examples/declarative/particles/simple/startstop.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/Button.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/Tag.qml delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/images/busy.png delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.png delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/qmldir delete mode 100644 examples/declarative/photoviewer/PhotoViewerCore/script/script.js delete mode 100644 examples/declarative/photoviewer/i18n/base.ts delete mode 100644 examples/declarative/photoviewer/i18n/qml_fr.qm delete mode 100644 examples/declarative/photoviewer/i18n/qml_fr.ts delete mode 100644 examples/declarative/photoviewer/photoviewer.qml delete mode 100644 examples/declarative/photoviewer/photoviewer.qmlproject delete mode 100644 examples/declarative/positioners/content/Button.qml delete mode 100644 examples/declarative/positioners/content/add.png delete mode 100644 examples/declarative/positioners/content/del.png delete mode 100644 examples/declarative/positioners/positioners-attachedproperties.qml delete mode 100644 examples/declarative/positioners/positioners.qml delete mode 100644 examples/declarative/righttoleft/layoutdirection/layoutdirection.qml delete mode 100644 examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject delete mode 100644 examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml delete mode 100644 examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject delete mode 100644 examples/declarative/righttoleft/textalignment/textalignment.qml delete mode 100644 examples/declarative/righttoleft/textalignment/textalignment.qmlproject delete mode 100644 examples/declarative/rssnews/content/BusyIndicator.qml delete mode 100644 examples/declarative/rssnews/content/CategoryDelegate.qml delete mode 100644 examples/declarative/rssnews/content/NewsDelegate.qml delete mode 100644 examples/declarative/rssnews/content/RssFeeds.qml delete mode 100644 examples/declarative/rssnews/content/ScrollBar.qml delete mode 100644 examples/declarative/rssnews/content/images/busy.png delete mode 100644 examples/declarative/rssnews/content/images/scrollbar.png delete mode 100644 examples/declarative/rssnews/rssnews.qml delete mode 100644 examples/declarative/rssnews/rssnews.qmlproject delete mode 100644 examples/declarative/samegame/content/BoomBlock.qml delete mode 100644 examples/declarative/samegame/content/Button.qml delete mode 100644 examples/declarative/samegame/content/Dialog.qml delete mode 100644 examples/declarative/samegame/content/GameArea.qml delete mode 100644 examples/declarative/samegame/content/NameInputDialog.qml delete mode 100644 examples/declarative/samegame/content/pics/background.png delete mode 100644 examples/declarative/samegame/content/pics/blueStone.png delete mode 100644 examples/declarative/samegame/content/pics/greenStone.png delete mode 100644 examples/declarative/samegame/content/pics/particle.png delete mode 100644 examples/declarative/samegame/content/pics/redStone.png delete mode 100644 examples/declarative/samegame/content/pics/yellowStone.png delete mode 100755 examples/declarative/samegame/content/samegame.js delete mode 100644 examples/declarative/samegame/samegame.qml delete mode 100644 examples/declarative/samegame/samegame.qmlproject delete mode 100644 examples/declarative/script/script.pro delete mode 100644 examples/declarative/script/shell/main.cpp delete mode 100644 examples/declarative/script/shell/shell.pro delete mode 100644 examples/declarative/shadereffects/content/Slider.qml delete mode 100644 examples/declarative/shadereffects/content/face-smile.png delete mode 100644 examples/declarative/shadereffects/content/qt-logo.png delete mode 100644 examples/declarative/shadereffects/shadereffects.qml delete mode 100644 examples/declarative/shared/Button.qml delete mode 100644 examples/declarative/shared/LauncherList.qml delete mode 100644 examples/declarative/shared/README delete mode 100644 examples/declarative/shared/SimpleLauncherDelegate.qml delete mode 100644 examples/declarative/shared/back.png delete mode 100644 examples/declarative/snake/content/Button.qml delete mode 100644 examples/declarative/snake/content/Cookie.qml delete mode 100644 examples/declarative/snake/content/HighScoreModel.qml delete mode 100644 examples/declarative/snake/content/Link.qml delete mode 100644 examples/declarative/snake/content/Skull.qml delete mode 100644 examples/declarative/snake/content/pics/README delete mode 100644 examples/declarative/snake/content/pics/background.png delete mode 100644 examples/declarative/snake/content/pics/blueStar.png delete mode 100644 examples/declarative/snake/content/pics/blueStone.png delete mode 100644 examples/declarative/snake/content/pics/cookie.png delete mode 100644 examples/declarative/snake/content/pics/eyes.svg delete mode 100644 examples/declarative/snake/content/pics/head.png delete mode 100644 examples/declarative/snake/content/pics/pause.png delete mode 100644 examples/declarative/snake/content/pics/redStar.png delete mode 100644 examples/declarative/snake/content/pics/redStone.png delete mode 100644 examples/declarative/snake/content/pics/skull.png delete mode 100644 examples/declarative/snake/content/pics/snake.jpg delete mode 100644 examples/declarative/snake/content/pics/star.png delete mode 100644 examples/declarative/snake/content/pics/stoneShadow.png delete mode 100644 examples/declarative/snake/content/pics/yellowStar.png delete mode 100644 examples/declarative/snake/content/pics/yellowStone.png delete mode 100644 examples/declarative/snake/content/snake.js delete mode 100644 examples/declarative/snake/snake.qml delete mode 100644 examples/declarative/snake/snake.qmlproject delete mode 100644 examples/declarative/sqllocalstorage/hello.qml delete mode 100644 examples/declarative/text/fonts/availableFonts.qml delete mode 100644 examples/declarative/text/fonts/banner.qml delete mode 100644 examples/declarative/text/fonts/content/fonts/tarzeau_ocr_a.ttf delete mode 100644 examples/declarative/text/fonts/fonts.qml delete mode 100644 examples/declarative/text/fonts/hello.qml delete mode 100644 examples/declarative/text/imgtag/TextWithImage.qml delete mode 100644 examples/declarative/text/imgtag/images/face-sad.png delete mode 100644 examples/declarative/text/imgtag/images/face-smile-big.png delete mode 100644 examples/declarative/text/imgtag/images/face-smile.png delete mode 100644 examples/declarative/text/imgtag/images/heart200.png delete mode 100644 examples/declarative/text/imgtag/images/qtlogo.png delete mode 100644 examples/declarative/text/imgtag/images/starfish_2.png delete mode 100644 examples/declarative/text/imgtag/imgtag.qml delete mode 100644 examples/declarative/text/styledtext-layout.qml delete mode 100644 examples/declarative/text/text.qml delete mode 100644 examples/declarative/text/text.qmlproject delete mode 100644 examples/declarative/text/textselection/pics/endHandle.png delete mode 100644 examples/declarative/text/textselection/pics/endHandle.sci delete mode 100644 examples/declarative/text/textselection/pics/startHandle.png delete mode 100644 examples/declarative/text/textselection/pics/startHandle.sci delete mode 100644 examples/declarative/text/textselection/textselection.qml delete mode 100644 examples/declarative/threading/threadedlistmodel/dataloader.js delete mode 100644 examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject delete mode 100644 examples/declarative/threading/threadedlistmodel/timedisplay.qml delete mode 100644 examples/declarative/threading/workerscript/workerscript.js delete mode 100644 examples/declarative/threading/workerscript/workerscript.qml delete mode 100644 examples/declarative/threading/workerscript/workerscript.qmlproject delete mode 100644 examples/declarative/touchinteraction/mousearea/mousearea-example.qml delete mode 100644 examples/declarative/touchinteraction/multipointtouch/bearwhack.qml delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/Bear0.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/Bear1.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/Bear2.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/Bear3.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/BearB.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/ParticleFlame.qml delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/blur-circle.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/blur-circle3.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/heart-blur.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/content/title.png delete mode 100644 examples/declarative/touchinteraction/multipointtouch/multiflame.qml delete mode 100644 examples/declarative/touchinteraction/pincharea/flickresize.qml delete mode 100644 examples/declarative/touchinteraction/pincharea/qt-logo.jpg delete mode 100644 examples/declarative/touchinteraction/touchinteraction.qml delete mode 100644 examples/declarative/touchinteraction/touchinteraction.qmlproject delete mode 100644 examples/declarative/toys/clocks/clocks.qml delete mode 100644 examples/declarative/toys/clocks/content/Clock.qml delete mode 100644 examples/declarative/toys/clocks/content/QuitButton.qml delete mode 100644 examples/declarative/toys/clocks/content/arrow.png delete mode 100644 examples/declarative/toys/clocks/content/background.png delete mode 100644 examples/declarative/toys/clocks/content/center.png delete mode 100644 examples/declarative/toys/clocks/content/clock-night.png delete mode 100644 examples/declarative/toys/clocks/content/clock.png delete mode 100644 examples/declarative/toys/clocks/content/hour.png delete mode 100644 examples/declarative/toys/clocks/content/minute.png delete mode 100644 examples/declarative/toys/clocks/content/quit.png delete mode 100644 examples/declarative/toys/clocks/content/second.png delete mode 100644 examples/declarative/toys/corkboards/content/Day.qml delete mode 100644 examples/declarative/toys/corkboards/content/cork.jpg delete mode 100644 examples/declarative/toys/corkboards/content/note-yellow.png delete mode 100644 examples/declarative/toys/corkboards/content/tack.png delete mode 100644 examples/declarative/toys/corkboards/corkboards.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/Button.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/GenericSceneItem.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/PaletteItem.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/PerspectiveItem.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/Sun.qml delete mode 100644 examples/declarative/toys/dynamicscene/content/images/NOTE delete mode 100644 examples/declarative/toys/dynamicscene/content/images/face-smile.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/moon.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/rabbit_brown.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/rabbit_bw.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/star.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/sun.png delete mode 100644 examples/declarative/toys/dynamicscene/content/images/tree_s.png delete mode 100644 examples/declarative/toys/dynamicscene/content/itemCreation.js delete mode 100644 examples/declarative/toys/dynamicscene/dynamicscene.qml delete mode 100644 examples/declarative/toys/tic-tac-toe/content/Button.qml delete mode 100644 examples/declarative/toys/tic-tac-toe/content/TicTac.qml delete mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/board.png delete mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/o.png delete mode 100644 examples/declarative/toys/tic-tac-toe/content/pics/x.png delete mode 100644 examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js delete mode 100644 examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml delete mode 100644 examples/declarative/toys/tvtennis/tvtennis.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview1/PetsModel.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview1/dynamicview.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview2/PetsModel.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview2/dynamicview.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview3/PetsModel.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview3/dynamicview.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview4/ListSelector.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview4/PetsModel.qml delete mode 100644 examples/declarative/tutorials/dynamicview/dynamicview4/dynamicview.qml delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/main.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter1-basics/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/main.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter2-methods/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/main.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter3-bindings/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/app.qml delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/piechart.h delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h delete mode 100644 examples/declarative/tutorials/extending/extending.pro delete mode 100644 examples/declarative/tutorials/helloworld/Cell.qml delete mode 100644 examples/declarative/tutorials/helloworld/tutorial1.qml delete mode 100644 examples/declarative/tutorials/helloworld/tutorial2.qml delete mode 100644 examples/declarative/tutorials/helloworld/tutorial3.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame1/Block.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame1/Button.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame1/samegame.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame1/samegame1.qmlproject delete mode 100644 examples/declarative/tutorials/samegame/samegame2/Block.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame2/Button.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame2/samegame.js delete mode 100644 examples/declarative/tutorials/samegame/samegame2/samegame.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame2/samegame2.qmlproject delete mode 100644 examples/declarative/tutorials/samegame/samegame3/Block.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame3/Button.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame3/Dialog.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame3/samegame.js delete mode 100644 examples/declarative/tutorials/samegame/samegame3/samegame.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame3/samegame3.qmlproject delete mode 100644 examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame4/content/Button.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml delete mode 100755 examples/declarative/tutorials/samegame/samegame4/content/samegame.js delete mode 100644 examples/declarative/tutorials/samegame/samegame4/highscores/README delete mode 100755 examples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml delete mode 100755 examples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl delete mode 100755 examples/declarative/tutorials/samegame/samegame4/highscores/scores.php delete mode 100644 examples/declarative/tutorials/samegame/samegame4/samegame.qml delete mode 100644 examples/declarative/tutorials/samegame/samegame4/samegame4.qmlproject delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/background.jpg delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/blueStar.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/blueStone.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/greenStar.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/greenStone.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/redStar.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/redStone.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/star.png delete mode 100644 examples/declarative/tutorials/samegame/shared/pics/yellowStone.png delete mode 100644 examples/declarative/tutorials/tutorials.pro delete mode 100644 examples/declarative/tutorials/tutorials.qmlproject delete mode 100644 examples/declarative/twitter/TwitterCore/Button.qml delete mode 100644 examples/declarative/twitter/TwitterCore/FatDelegate.qml delete mode 100644 examples/declarative/twitter/TwitterCore/Input.qml delete mode 100644 examples/declarative/twitter/TwitterCore/Loading.qml delete mode 100644 examples/declarative/twitter/TwitterCore/MultiTitleBar.qml delete mode 100644 examples/declarative/twitter/TwitterCore/RssModel.qml delete mode 100644 examples/declarative/twitter/TwitterCore/SearchView.qml delete mode 100644 examples/declarative/twitter/TwitterCore/TitleBar.qml delete mode 100644 examples/declarative/twitter/TwitterCore/ToolBar.qml delete mode 100644 examples/declarative/twitter/TwitterCore/UserModel.qml delete mode 100644 examples/declarative/twitter/TwitterCore/images/gloss.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/lineedit.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/lineedit.sci delete mode 100644 examples/declarative/twitter/TwitterCore/images/loading.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/quit.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/stripes.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/titlebar.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/titlebar.sci delete mode 100644 examples/declarative/twitter/TwitterCore/images/toolbutton.png delete mode 100644 examples/declarative/twitter/TwitterCore/images/toolbutton.sci delete mode 100644 examples/declarative/twitter/TwitterCore/qmldir delete mode 100644 examples/declarative/twitter/twitter.qml delete mode 100644 examples/declarative/twitter/twitter.qmlproject delete mode 100644 examples/declarative/ui-components/dialcontrol/content/Dial.qml delete mode 100644 examples/declarative/ui-components/dialcontrol/content/QuitButton.qml delete mode 100644 examples/declarative/ui-components/dialcontrol/content/background.png delete mode 100644 examples/declarative/ui-components/dialcontrol/content/needle.png delete mode 100644 examples/declarative/ui-components/dialcontrol/content/needle_shadow.png delete mode 100644 examples/declarative/ui-components/dialcontrol/content/overlay.png delete mode 100644 examples/declarative/ui-components/dialcontrol/content/quit.png delete mode 100644 examples/declarative/ui-components/dialcontrol/dialcontrol.qml delete mode 100644 examples/declarative/ui-components/flipable/content/5_heart.png delete mode 100644 examples/declarative/ui-components/flipable/content/9_club.png delete mode 100644 examples/declarative/ui-components/flipable/content/Card.qml delete mode 100644 examples/declarative/ui-components/flipable/content/back.png delete mode 100644 examples/declarative/ui-components/flipable/flipable.qml delete mode 100644 examples/declarative/ui-components/progressbar/content/ProgressBar.qml delete mode 100644 examples/declarative/ui-components/progressbar/content/background.png delete mode 100644 examples/declarative/ui-components/progressbar/main.qml delete mode 100644 examples/declarative/ui-components/scrollbar/ScrollBar.qml delete mode 100644 examples/declarative/ui-components/scrollbar/main.qml delete mode 100644 examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg delete mode 100644 examples/declarative/ui-components/scrollbar/scrollbar.qmlproject delete mode 100644 examples/declarative/ui-components/searchbox/SearchBox.qml delete mode 100644 examples/declarative/ui-components/searchbox/images/clear.png delete mode 100644 examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png delete mode 100644 examples/declarative/ui-components/searchbox/images/lineedit-bg.png delete mode 100644 examples/declarative/ui-components/searchbox/main.qml delete mode 100644 examples/declarative/ui-components/searchbox/searchbox.qmlproject delete mode 100644 examples/declarative/ui-components/slideswitch/content/Switch.qml delete mode 100644 examples/declarative/ui-components/slideswitch/content/background.png delete mode 100644 examples/declarative/ui-components/slideswitch/content/background.svg delete mode 100644 examples/declarative/ui-components/slideswitch/content/knob.png delete mode 100644 examples/declarative/ui-components/slideswitch/content/knob.svg delete mode 100644 examples/declarative/ui-components/slideswitch/slideswitch.qml delete mode 100644 examples/declarative/ui-components/spinner/content/Spinner.qml delete mode 100644 examples/declarative/ui-components/spinner/content/spinner-bg.png delete mode 100644 examples/declarative/ui-components/spinner/content/spinner-select.png delete mode 100644 examples/declarative/ui-components/spinner/main.qml delete mode 100644 examples/declarative/ui-components/spinner/spinner.qmlproject delete mode 100644 examples/declarative/ui-components/tabwidget/TabWidget.qml delete mode 100644 examples/declarative/ui-components/tabwidget/main.qml delete mode 100644 examples/declarative/ui-components/tabwidget/tab.png delete mode 100644 examples/declarative/ui-components/tabwidget/tabwidget.qmlproject delete mode 100644 examples/declarative/window/Window.qml delete mode 100644 examples/declarative/window/screen/screenInfo.qml delete mode 100644 examples/declarative/window/standalone.qml delete mode 100644 examples/declarative/window/window.cpp delete mode 100644 examples/declarative/window/window.pro delete mode 100644 examples/declarative/xml/xmlhttprequest/data.xml delete mode 100644 examples/declarative/xml/xmlhttprequest/xmlhttprequest-example.qml create mode 100644 examples/demos/calculator/CalculatorCore/Button.qml create mode 100644 examples/demos/calculator/CalculatorCore/Display.qml create mode 100644 examples/demos/calculator/CalculatorCore/calculator.js create mode 100644 examples/demos/calculator/CalculatorCore/images/button-.png create mode 100644 examples/demos/calculator/CalculatorCore/images/button-blue.png create mode 100644 examples/demos/calculator/CalculatorCore/images/button-green.png create mode 100644 examples/demos/calculator/CalculatorCore/images/button-purple.png create mode 100644 examples/demos/calculator/CalculatorCore/images/button-red.png create mode 100644 examples/demos/calculator/CalculatorCore/images/display.png create mode 100644 examples/demos/calculator/CalculatorCore/qmldir create mode 100644 examples/demos/calculator/calculator-desktop.qml create mode 100644 examples/demos/calculator/calculator-mobile.qml create mode 100644 examples/demos/calculator/calculator.pro create mode 100644 examples/demos/calculator/calculator.qdoc create mode 100644 examples/demos/calculator/main.cpp create mode 100644 examples/demos/clocks/clocks.qml create mode 100644 examples/demos/clocks/content/Clock.qml create mode 100644 examples/demos/clocks/content/QuitButton.qml create mode 100644 examples/demos/clocks/content/arrow.png create mode 100644 examples/demos/clocks/content/background.png create mode 100644 examples/demos/clocks/content/center.png create mode 100644 examples/demos/clocks/content/clock-night.png create mode 100644 examples/demos/clocks/content/clock.png create mode 100644 examples/demos/clocks/content/hour.png create mode 100644 examples/demos/clocks/content/minute.png create mode 100644 examples/demos/clocks/content/quit.png create mode 100644 examples/demos/clocks/content/second.png create mode 100644 examples/demos/corkboards/content/Day.qml create mode 100644 examples/demos/corkboards/content/cork.jpg create mode 100644 examples/demos/corkboards/content/note-yellow.png create mode 100644 examples/demos/corkboards/content/tack.png create mode 100644 examples/demos/corkboards/corkboards.qml create mode 100644 examples/demos/demos.pro create mode 100644 examples/demos/dynamicscene/content/Button.qml create mode 100644 examples/demos/dynamicscene/content/GenericSceneItem.qml create mode 100644 examples/demos/dynamicscene/content/PaletteItem.qml create mode 100644 examples/demos/dynamicscene/content/PerspectiveItem.qml create mode 100644 examples/demos/dynamicscene/content/Sun.qml create mode 100644 examples/demos/dynamicscene/content/images/NOTE create mode 100644 examples/demos/dynamicscene/content/images/face-smile.png create mode 100644 examples/demos/dynamicscene/content/images/moon.png create mode 100644 examples/demos/dynamicscene/content/images/rabbit_brown.png create mode 100644 examples/demos/dynamicscene/content/images/rabbit_bw.png create mode 100644 examples/demos/dynamicscene/content/images/star.png create mode 100644 examples/demos/dynamicscene/content/images/sun.png create mode 100644 examples/demos/dynamicscene/content/images/tree_s.png create mode 100644 examples/demos/dynamicscene/content/itemCreation.js create mode 100644 examples/demos/dynamicscene/dynamicscene.qml create mode 100644 examples/demos/flickr/content/Button.qml create mode 100644 examples/demos/flickr/content/GridDelegate.qml create mode 100644 examples/demos/flickr/content/ImageDetails.qml create mode 100644 examples/demos/flickr/content/ListDelegate.qml create mode 100644 examples/demos/flickr/content/Progress.qml create mode 100644 examples/demos/flickr/content/RssModel.qml create mode 100644 examples/demos/flickr/content/ScrollBar.qml create mode 100644 examples/demos/flickr/content/Slider.qml create mode 100644 examples/demos/flickr/content/TitleBar.qml create mode 100644 examples/demos/flickr/content/ToolBar.qml create mode 100644 examples/demos/flickr/content/UnifiedDelegate.qml create mode 100644 examples/demos/flickr/content/images/gloss.png create mode 100644 examples/demos/flickr/content/images/lineedit.png create mode 100644 examples/demos/flickr/content/images/lineedit.sci create mode 100644 examples/demos/flickr/content/images/noise.png create mode 100644 examples/demos/flickr/content/images/particle.png create mode 100644 examples/demos/flickr/content/images/quit.png create mode 100644 examples/demos/flickr/content/images/squareParticle.png create mode 100644 examples/demos/flickr/content/images/stripes.png create mode 100644 examples/demos/flickr/content/images/titlebar.png create mode 100644 examples/demos/flickr/content/images/titlebar.sci create mode 100644 examples/demos/flickr/content/images/toolbutton.png create mode 100644 examples/demos/flickr/content/images/toolbutton.sci create mode 100644 examples/demos/flickr/content/qmldir create mode 100644 examples/demos/flickr/flickr-90.qml create mode 100644 examples/demos/flickr/flickr.qml create mode 100644 examples/demos/flickr/flickr.qmlproject create mode 100644 examples/demos/minehunt/MinehuntCore/Explosion.qml create mode 100644 examples/demos/minehunt/MinehuntCore/Tile.qml create mode 100644 examples/demos/minehunt/MinehuntCore/pics/back.png create mode 100644 examples/demos/minehunt/MinehuntCore/pics/background.png create mode 100644 examples/demos/minehunt/MinehuntCore/pics/bomb-color.png create mode 100644 examples/demos/minehunt/MinehuntCore/pics/bomb.png create mode 100644 examples/demos/minehunt/MinehuntCore/pics/face-sad.png create mode 100644 examples/demos/minehunt/MinehuntCore/pics/face-smile-big.png create mode 100644 examples/demos/minehunt/MinehuntCore/pics/face-smile.png create mode 100644 examples/demos/minehunt/MinehuntCore/pics/flag-color.png create mode 100644 examples/demos/minehunt/MinehuntCore/pics/flag.png create mode 100644 examples/demos/minehunt/MinehuntCore/pics/front.png create mode 100644 examples/demos/minehunt/MinehuntCore/pics/quit.png create mode 100644 examples/demos/minehunt/MinehuntCore/pics/star.png create mode 100644 examples/demos/minehunt/MinehuntCore/qmldir create mode 100644 examples/demos/minehunt/README create mode 100644 examples/demos/minehunt/main.cpp create mode 100644 examples/demos/minehunt/minehunt.cpp create mode 100644 examples/demos/minehunt/minehunt.h create mode 100644 examples/demos/minehunt/minehunt.pro create mode 100644 examples/demos/minehunt/minehunt.qml create mode 100644 examples/demos/minehunt/minehunt.qmlproject create mode 100644 examples/demos/minehunt/minehunt.qrc create mode 100644 examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml create mode 100644 examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml create mode 100644 examples/demos/photoviewer/PhotoViewerCore/Button.qml create mode 100644 examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml create mode 100644 examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml create mode 100644 examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml create mode 100644 examples/demos/photoviewer/PhotoViewerCore/RssModel.qml create mode 100644 examples/demos/photoviewer/PhotoViewerCore/Tag.qml create mode 100644 examples/demos/photoviewer/PhotoViewerCore/images/box-shadow.png create mode 100644 examples/demos/photoviewer/PhotoViewerCore/images/busy.png create mode 100644 examples/demos/photoviewer/PhotoViewerCore/images/cardboard.png create mode 100644 examples/demos/photoviewer/PhotoViewerCore/qmldir create mode 100644 examples/demos/photoviewer/PhotoViewerCore/script/script.js create mode 100644 examples/demos/photoviewer/i18n/base.ts create mode 100644 examples/demos/photoviewer/i18n/qml_fr.qm create mode 100644 examples/demos/photoviewer/i18n/qml_fr.ts create mode 100644 examples/demos/photoviewer/photoviewer.qml create mode 100644 examples/demos/photoviewer/photoviewer.qmlproject create mode 100644 examples/demos/plasmapatrol/PlasmaPatrol.qmlproject create mode 100644 examples/demos/plasmapatrol/TODO create mode 100644 examples/demos/plasmapatrol/content/BlasterHardpoint.qml create mode 100644 examples/demos/plasmapatrol/content/Button.qml create mode 100644 examples/demos/plasmapatrol/content/CannonHardpoint.qml create mode 100644 examples/demos/plasmapatrol/content/ChoiceBox.qml create mode 100644 examples/demos/plasmapatrol/content/Cruiser.qml create mode 100644 examples/demos/plasmapatrol/content/Frigate.qml create mode 100644 examples/demos/plasmapatrol/content/Hardpoint.qml create mode 100644 examples/demos/plasmapatrol/content/HelpScreens.qml create mode 100644 examples/demos/plasmapatrol/content/LaserHardpoint.qml create mode 100644 examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml create mode 100644 examples/demos/plasmapatrol/content/SequentialLoader.qml create mode 100644 examples/demos/plasmapatrol/content/Ship.qml create mode 100644 examples/demos/plasmapatrol/content/Sloop.qml create mode 100644 examples/demos/plasmapatrol/content/pics/TitleText.png create mode 100644 examples/demos/plasmapatrol/content/pics/blur-circle2.png create mode 100644 examples/demos/plasmapatrol/content/pics/blur-circle3.png create mode 100644 examples/demos/plasmapatrol/content/pics/finalfrontier.png create mode 100644 examples/demos/plasmapatrol/content/pics/meteor.png create mode 100644 examples/demos/plasmapatrol/content/pics/meteor_explo.png create mode 100644 examples/demos/plasmapatrol/content/pics/nullRock.png create mode 100644 examples/demos/plasmapatrol/content/pics/particle.png create mode 100644 examples/demos/plasmapatrol/content/pics/star.png create mode 100644 examples/demos/plasmapatrol/content/pics/star2.png create mode 100644 examples/demos/plasmapatrol/content/pics/star3.png create mode 100644 examples/demos/plasmapatrol/plasmapatrol.qml create mode 100644 examples/demos/rssnews/content/BusyIndicator.qml create mode 100644 examples/demos/rssnews/content/CategoryDelegate.qml create mode 100644 examples/demos/rssnews/content/NewsDelegate.qml create mode 100644 examples/demos/rssnews/content/RssFeeds.qml create mode 100644 examples/demos/rssnews/content/ScrollBar.qml create mode 100644 examples/demos/rssnews/content/images/busy.png create mode 100644 examples/demos/rssnews/content/images/scrollbar.png create mode 100644 examples/demos/rssnews/rssnews.qml create mode 100644 examples/demos/rssnews/rssnews.qmlproject create mode 100644 examples/demos/samegame/content/BoomBlock.qml create mode 100644 examples/demos/samegame/content/Button.qml create mode 100644 examples/demos/samegame/content/Dialog.qml create mode 100644 examples/demos/samegame/content/GameArea.qml create mode 100644 examples/demos/samegame/content/NameInputDialog.qml create mode 100644 examples/demos/samegame/content/pics/background.png create mode 100644 examples/demos/samegame/content/pics/blueStone.png create mode 100644 examples/demos/samegame/content/pics/greenStone.png create mode 100644 examples/demos/samegame/content/pics/particle.png create mode 100644 examples/demos/samegame/content/pics/redStone.png create mode 100644 examples/demos/samegame/content/pics/yellowStone.png create mode 100755 examples/demos/samegame/content/samegame.js create mode 100644 examples/demos/samegame/samegame.qml create mode 100644 examples/demos/samegame/samegame.qmlproject create mode 100644 examples/demos/snake/content/Button.qml create mode 100644 examples/demos/snake/content/Cookie.qml create mode 100644 examples/demos/snake/content/HighScoreModel.qml create mode 100644 examples/demos/snake/content/Link.qml create mode 100644 examples/demos/snake/content/Skull.qml create mode 100644 examples/demos/snake/content/pics/README create mode 100644 examples/demos/snake/content/pics/background.png create mode 100644 examples/demos/snake/content/pics/blueStar.png create mode 100644 examples/demos/snake/content/pics/blueStone.png create mode 100644 examples/demos/snake/content/pics/cookie.png create mode 100644 examples/demos/snake/content/pics/eyes.svg create mode 100644 examples/demos/snake/content/pics/head.png create mode 100644 examples/demos/snake/content/pics/pause.png create mode 100644 examples/demos/snake/content/pics/redStar.png create mode 100644 examples/demos/snake/content/pics/redStone.png create mode 100644 examples/demos/snake/content/pics/skull.png create mode 100644 examples/demos/snake/content/pics/snake.jpg create mode 100644 examples/demos/snake/content/pics/star.png create mode 100644 examples/demos/snake/content/pics/stoneShadow.png create mode 100644 examples/demos/snake/content/pics/yellowStar.png create mode 100644 examples/demos/snake/content/pics/yellowStone.png create mode 100644 examples/demos/snake/content/snake.js create mode 100644 examples/demos/snake/snake.qml create mode 100644 examples/demos/snake/snake.qmlproject create mode 100644 examples/demos/tic-tac-toe/content/Button.qml create mode 100644 examples/demos/tic-tac-toe/content/TicTac.qml create mode 100644 examples/demos/tic-tac-toe/content/pics/board.png create mode 100644 examples/demos/tic-tac-toe/content/pics/o.png create mode 100644 examples/demos/tic-tac-toe/content/pics/x.png create mode 100644 examples/demos/tic-tac-toe/content/tic-tac-toe.js create mode 100644 examples/demos/tic-tac-toe/tic-tac-toe.qml create mode 100644 examples/demos/tvtennis/tvtennis.qml create mode 100644 examples/demos/twitter/TwitterCore/Button.qml create mode 100644 examples/demos/twitter/TwitterCore/FatDelegate.qml create mode 100644 examples/demos/twitter/TwitterCore/Input.qml create mode 100644 examples/demos/twitter/TwitterCore/Loading.qml create mode 100644 examples/demos/twitter/TwitterCore/MultiTitleBar.qml create mode 100644 examples/demos/twitter/TwitterCore/RssModel.qml create mode 100644 examples/demos/twitter/TwitterCore/SearchView.qml create mode 100644 examples/demos/twitter/TwitterCore/TitleBar.qml create mode 100644 examples/demos/twitter/TwitterCore/ToolBar.qml create mode 100644 examples/demos/twitter/TwitterCore/UserModel.qml create mode 100644 examples/demos/twitter/TwitterCore/images/gloss.png create mode 100644 examples/demos/twitter/TwitterCore/images/lineedit.png create mode 100644 examples/demos/twitter/TwitterCore/images/lineedit.sci create mode 100644 examples/demos/twitter/TwitterCore/images/loading.png create mode 100644 examples/demos/twitter/TwitterCore/images/quit.png create mode 100644 examples/demos/twitter/TwitterCore/images/stripes.png create mode 100644 examples/demos/twitter/TwitterCore/images/titlebar.png create mode 100644 examples/demos/twitter/TwitterCore/images/titlebar.sci create mode 100644 examples/demos/twitter/TwitterCore/images/toolbutton.png create mode 100644 examples/demos/twitter/TwitterCore/images/toolbutton.sci create mode 100644 examples/demos/twitter/TwitterCore/qmldir create mode 100644 examples/demos/twitter/twitter.qml create mode 100644 examples/demos/twitter/twitter.qmlproject delete mode 100644 examples/embedded/embedded.pro delete mode 100644 examples/embedded/qmlcalculator/deployment.pri delete mode 100644 examples/embedded/qmlcalculator/qmlcalculator.cpp delete mode 100644 examples/embedded/qmlcalculator/qmlcalculator.pro delete mode 100644 examples/embedded/qmlclocks/deployment.pri delete mode 100644 examples/embedded/qmlclocks/qmlclocks.cpp delete mode 100644 examples/embedded/qmlclocks/qmlclocks.pro delete mode 100644 examples/embedded/qmldialcontrol/deployment.pri delete mode 100644 examples/embedded/qmldialcontrol/qmldialcontrol.cpp delete mode 100644 examples/embedded/qmldialcontrol/qmldialcontrol.pro delete mode 100644 examples/embedded/qmleasing/deployment.pri delete mode 100644 examples/embedded/qmleasing/qmleasing.cpp delete mode 100644 examples/embedded/qmleasing/qmleasing.pro delete mode 100644 examples/embedded/qmlflickr/deployment.pri delete mode 100644 examples/embedded/qmlflickr/qmlflickr.cpp delete mode 100644 examples/embedded/qmlflickr/qmlflickr.pro delete mode 100644 examples/embedded/qmlphotoviewer/deployment.pri delete mode 100644 examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp delete mode 100644 examples/embedded/qmlphotoviewer/qmlphotoviewer.pro delete mode 100644 examples/embedded/qmltwitter/deployment.pri delete mode 100644 examples/embedded/qmltwitter/qmltwitter.cpp delete mode 100644 examples/embedded/qmltwitter/qmltwitter.pro create mode 100644 examples/localstorage/hello.qml create mode 100644 examples/localstorage/localstorage.pro create mode 100644 examples/particles/affectors/age.qml create mode 100644 examples/particles/affectors/attractor.qml create mode 100644 examples/particles/affectors/customaffector.qml create mode 100644 examples/particles/affectors/friction.qml create mode 100644 examples/particles/affectors/gravity.qml create mode 100644 examples/particles/affectors/groupgoal.qml create mode 100644 examples/particles/affectors/move.qml create mode 100644 examples/particles/affectors/spritegoal.qml create mode 100644 examples/particles/affectors/turbulence.qml create mode 100644 examples/particles/affectors/wander.qml create mode 100644 examples/particles/customparticle/blurparticles.qml create mode 100644 examples/particles/customparticle/fragmentshader.qml create mode 100644 examples/particles/customparticle/imagecolors.qml create mode 100644 examples/particles/emitters/burstandpulse.qml create mode 100644 examples/particles/emitters/customemitter.qml create mode 100644 examples/particles/emitters/emitmask.qml create mode 100644 examples/particles/emitters/maximumemitted.qml create mode 100644 examples/particles/emitters/shapeanddirection.qml create mode 100644 examples/particles/emitters/timedgroupchanges.qml create mode 100644 examples/particles/emitters/trailemitter.qml create mode 100644 examples/particles/emitters/velocityfrommotion.qml create mode 100644 examples/particles/exampleslauncher/content/Button.qml create mode 100644 examples/particles/exampleslauncher/content/Shell.qml create mode 100644 examples/particles/exampleslauncher/content/launcher.js create mode 100644 examples/particles/exampleslauncher/exampleslauncher.qml create mode 100644 examples/particles/imageparticle/allatonce.qml create mode 100644 examples/particles/imageparticle/colored.qml create mode 100644 examples/particles/imageparticle/colortable.qml create mode 100644 examples/particles/imageparticle/deformation.qml create mode 100644 examples/particles/imageparticle/rotation.qml create mode 100644 examples/particles/imageparticle/sharing.qml create mode 100644 examples/particles/imageparticle/sprites.qml create mode 100644 examples/particles/images/_explo.png create mode 100755 examples/particles/images/backgroundLeaves.jpg create mode 100644 examples/particles/images/bear_tiles.png create mode 100644 examples/particles/images/candle.png create mode 100644 examples/particles/images/colortable.png create mode 100644 examples/particles/images/finalfrontier.png create mode 100644 examples/particles/images/flower.png create mode 100644 examples/particles/images/launcherIcons/allatonce.png create mode 100644 examples/particles/images/launcherIcons/attractor.png create mode 100644 examples/particles/images/launcherIcons/blurparticles.png create mode 100644 examples/particles/images/launcherIcons/close.png create mode 100644 examples/particles/images/launcherIcons/colortable.png create mode 100644 examples/particles/images/launcherIcons/customaffector.png create mode 100644 examples/particles/images/launcherIcons/customemitter.png create mode 100644 examples/particles/images/launcherIcons/deformation.png create mode 100644 examples/particles/images/launcherIcons/delegates.png create mode 100644 examples/particles/images/launcherIcons/dynamicemitters.png create mode 100644 examples/particles/images/launcherIcons/emitmask.png create mode 100644 examples/particles/images/launcherIcons/flickr.png create mode 100644 examples/particles/images/launcherIcons/fragmentshader.png create mode 100644 examples/particles/images/launcherIcons/gridsplosion.png create mode 100644 examples/particles/images/launcherIcons/groupgoal.png create mode 100644 examples/particles/images/launcherIcons/imagecolors.png create mode 100644 examples/particles/images/launcherIcons/list.png create mode 100644 examples/particles/images/launcherIcons/maximumemitted.png create mode 100644 examples/particles/images/launcherIcons/multiplepainters.png create mode 100644 examples/particles/images/launcherIcons/package.png create mode 100644 examples/particles/images/launcherIcons/particleview.png create mode 100644 examples/particles/images/launcherIcons/plasmapatrol.png create mode 100644 examples/particles/images/launcherIcons/remove.png create mode 100644 examples/particles/images/launcherIcons/rotation.png create mode 100644 examples/particles/images/launcherIcons/samegame.png create mode 100644 examples/particles/images/launcherIcons/shapeanddirection.png create mode 100644 examples/particles/images/launcherIcons/spaceexplorer.png create mode 100644 examples/particles/images/launcherIcons/spritegoal.png create mode 100644 examples/particles/images/launcherIcons/sprites.png create mode 100644 examples/particles/images/launcherIcons/spritevariedparticles.png create mode 100644 examples/particles/images/launcherIcons/startstop.png create mode 100644 examples/particles/images/launcherIcons/timedgroupchanges.png create mode 100644 examples/particles/images/launcherIcons/trailemitter.png create mode 100644 examples/particles/images/launcherIcons/trails.png create mode 100644 examples/particles/images/launcherIcons/turbulence.png create mode 100644 examples/particles/images/launcherIcons/velocityfrommotion.png create mode 100644 examples/particles/images/launcherIcons/wander.png create mode 100644 examples/particles/images/matchmask.png create mode 100644 examples/particles/images/meteor.png create mode 100644 examples/particles/images/meteor_explo.png create mode 100644 examples/particles/images/meteors.png create mode 100644 examples/particles/images/nullRock.png create mode 100644 examples/particles/images/particle.png create mode 100644 examples/particles/images/particle2.png create mode 100644 examples/particles/images/particle3.png create mode 100644 examples/particles/images/particle4.png create mode 100644 examples/particles/images/particleA.png create mode 100644 examples/particles/images/portal_bg.png create mode 100644 examples/particles/images/realLeaf1.png create mode 100644 examples/particles/images/realLeaf2.png create mode 100644 examples/particles/images/realLeaf3.png create mode 100644 examples/particles/images/realLeaf4.png create mode 100644 examples/particles/images/rocket.png create mode 100644 examples/particles/images/rocket2.png create mode 100644 examples/particles/images/sizeInOut.png create mode 100644 examples/particles/images/snowflake.png create mode 100644 examples/particles/images/sparkleSize.png create mode 100644 examples/particles/images/star.png create mode 100644 examples/particles/images/starfish_0.png create mode 100644 examples/particles/images/starfish_1.png create mode 100644 examples/particles/images/starfish_2.png create mode 100644 examples/particles/images/starfish_3.png create mode 100644 examples/particles/images/starfish_4.png create mode 100644 examples/particles/images/starfish_mask.png create mode 100644 examples/particles/itemparticle/content/Delegate.qml create mode 100644 examples/particles/itemparticle/content/Delegate2.qml create mode 100644 examples/particles/itemparticle/content/ExpandingDelegate.qml create mode 100644 examples/particles/itemparticle/content/RssModel.qml create mode 100644 examples/particles/itemparticle/content/bubble.png create mode 100644 examples/particles/itemparticle/content/script.js create mode 100644 examples/particles/itemparticle/delegates.qml create mode 100644 examples/particles/itemparticle/particleview.qml create mode 100644 examples/particles/particles.pro create mode 100644 examples/particles/simple/dynamiccomparison.qml create mode 100644 examples/particles/simple/dynamicemitters.qml create mode 100644 examples/particles/simple/multiplepainters.qml create mode 100644 examples/particles/simple/startstop.qml create mode 100644 examples/qml/cppextensions/cppextensions.pro create mode 100644 examples/qml/cppextensions/cppextensions.qmlproject create mode 100644 examples/qml/cppextensions/imageprovider/ImageProviderCore/qmldir create mode 100644 examples/qml/cppextensions/imageprovider/imageprovider-example.qml create mode 100644 examples/qml/cppextensions/imageprovider/imageprovider.cpp create mode 100644 examples/qml/cppextensions/imageprovider/imageprovider.pro create mode 100644 examples/qml/cppextensions/imageprovider/imageprovider.qmlproject create mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp create mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro create mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject create mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc create mode 100644 examples/qml/cppextensions/networkaccessmanagerfactory/view.qml create mode 100644 examples/qml/cppextensions/plugins/README create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/center.png create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png create mode 100644 examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir create mode 100644 examples/qml/cppextensions/plugins/plugin.cpp create mode 100644 examples/qml/cppextensions/plugins/plugins.pro create mode 100644 examples/qml/cppextensions/plugins/plugins.qml create mode 100644 examples/qml/cppextensions/plugins/plugins.qmlproject create mode 100644 examples/qml/cppextensions/referenceexamples/adding/adding.pro create mode 100644 examples/qml/cppextensions/referenceexamples/adding/adding.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/adding/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/adding/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/adding/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/adding/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/attached/attached.pro create mode 100644 examples/qml/cppextensions/referenceexamples/attached/attached.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/attached/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/attached/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/attached/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/attached/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/binding/binding.pro create mode 100644 examples/qml/cppextensions/referenceexamples/binding/binding.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/binding/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h create mode 100644 examples/qml/cppextensions/referenceexamples/binding/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/binding/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/binding/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/coercion.pro create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/coercion/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/default/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/default/default.pro create mode 100644 examples/qml/cppextensions/referenceexamples/default/default.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/default/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/default/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/default/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/default/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/extended/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/extended/extended.pro create mode 100644 examples/qml/cppextensions/referenceexamples/extended/extended.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/extended/lineedit.h create mode 100644 examples/qml/cppextensions/referenceexamples/extended/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/grouped.pro create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/grouped/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/methods/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/methods/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/methods/methods.pro create mode 100644 examples/qml/cppextensions/referenceexamples/methods/methods.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/methods/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/methods/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/properties/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/properties/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/properties/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/properties/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/properties/properties.pro create mode 100644 examples/qml/cppextensions/referenceexamples/properties/properties.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/referenceexamples.pro create mode 100644 examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject create mode 100644 examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/signal/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/signal/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/signal/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/signal/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/signal/signal.pro create mode 100644 examples/qml/cppextensions/referenceexamples/signal/signal.qrc create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/example.qml create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/main.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/person.cpp create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/person.h create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro create mode 100644 examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc create mode 100644 examples/qml/i18n/i18n.qml create mode 100644 examples/qml/i18n/i18n/base.ts create mode 100644 examples/qml/i18n/i18n/qml_en_AU.ts create mode 100644 examples/qml/i18n/i18n/qml_fr.ts create mode 100644 examples/qml/locale/locale.qml create mode 100644 examples/qml/qml.pro create mode 100644 examples/qml/script/script.pro create mode 100644 examples/qml/script/shell/main.cpp create mode 100644 examples/qml/script/shell/shell.pro create mode 100644 examples/qml/xmlhttprequest/data.xml create mode 100644 examples/qml/xmlhttprequest/xmlhttprequest-example.qml create mode 100644 examples/qtquick/accessibility/accessibility.pro create mode 100644 examples/qtquick/accessibility/accessibility.qml create mode 100644 examples/qtquick/accessibility/accessibility.qmlproject create mode 100644 examples/qtquick/accessibility/content/Button.qml create mode 100644 examples/qtquick/accessibility/main.cpp create mode 100644 examples/qtquick/animation/animation.pro create mode 100644 examples/qtquick/animation/animation.qml create mode 100644 examples/qtquick/animation/animation.qmlproject create mode 100644 examples/qtquick/animation/basics/color-animation.qml create mode 100644 examples/qtquick/animation/basics/images/face-smile.png create mode 100644 examples/qtquick/animation/basics/images/moon.png create mode 100644 examples/qtquick/animation/basics/images/shadow.png create mode 100644 examples/qtquick/animation/basics/images/star.png create mode 100644 examples/qtquick/animation/basics/images/sun.png create mode 100644 examples/qtquick/animation/basics/property-animation.qml create mode 100644 examples/qtquick/animation/behaviors/SideRect.qml create mode 100644 examples/qtquick/animation/behaviors/behavior-example.qml create mode 100644 examples/qtquick/animation/behaviors/wigglytext.qml create mode 100644 examples/qtquick/animation/easing/content/QuitButton.qml create mode 100644 examples/qtquick/animation/easing/content/quit.png create mode 100644 examples/qtquick/animation/easing/easing.qml create mode 100644 examples/qtquick/animation/main.cpp create mode 100644 examples/qtquick/animation/pathanimation/pathanimation.qml create mode 100644 examples/qtquick/animation/pathinterpolator/pathinterpolator.qml create mode 100644 examples/qtquick/animation/states/qt-logo.png create mode 100644 examples/qtquick/animation/states/states.qml create mode 100644 examples/qtquick/animation/states/transitions.qml create mode 100644 examples/qtquick/canvas/bezierCurve/bezierCurve.qml create mode 100644 examples/qtquick/canvas/clip/clip.qml create mode 100644 examples/qtquick/canvas/contents/Button.qml create mode 100644 examples/qtquick/canvas/contents/ScrollBar.qml create mode 100644 examples/qtquick/canvas/contents/Slider.qml create mode 100644 examples/qtquick/canvas/contents/Stocks.qml create mode 100644 examples/qtquick/canvas/contents/TitleBar.qml create mode 100644 examples/qtquick/canvas/contents/ToolBar.qml create mode 100644 examples/qtquick/canvas/contents/images/button-pressed.png create mode 100644 examples/qtquick/canvas/contents/images/button.png create mode 100644 examples/qtquick/canvas/contents/images/default.svg create mode 100755 examples/qtquick/canvas/contents/images/gloss.png create mode 100755 examples/qtquick/canvas/contents/images/lineedit.png create mode 100644 examples/qtquick/canvas/contents/images/lineedit.sci create mode 100755 examples/qtquick/canvas/contents/images/quit.png create mode 100755 examples/qtquick/canvas/contents/images/stripes.png create mode 100755 examples/qtquick/canvas/contents/images/titlebar.png create mode 100644 examples/qtquick/canvas/contents/images/titlebar.sci create mode 100755 examples/qtquick/canvas/contents/images/toolbutton.png create mode 100644 examples/qtquick/canvas/contents/images/toolbutton.sci create mode 100644 examples/qtquick/canvas/contents/qt-logo.png create mode 100644 examples/qtquick/canvas/quadraticCurveTo/quadraticCurveTo.qml create mode 100644 examples/qtquick/canvas/roundedrect/roundedrect.qml create mode 100644 examples/qtquick/canvas/smile/smile.qml create mode 100644 examples/qtquick/canvas/squircle/squircle.png create mode 100644 examples/qtquick/canvas/squircle/squircle.qml create mode 100644 examples/qtquick/canvas/stockchart/README create mode 100644 examples/qtquick/canvas/stockchart/com/nokia/StockChartExample/qmldir create mode 100644 examples/qtquick/canvas/stockchart/model.cpp create mode 100644 examples/qtquick/canvas/stockchart/model.h create mode 100644 examples/qtquick/canvas/stockchart/plugin.cpp create mode 100644 examples/qtquick/canvas/stockchart/stock.qml create mode 100644 examples/qtquick/canvas/stockchart/stockchart.pro create mode 100644 examples/qtquick/canvas/tiger/tiger.js create mode 100644 examples/qtquick/canvas/tiger/tiger.qml create mode 100644 examples/qtquick/canvas/twitterfriends/TwitterUser.qml create mode 100644 examples/qtquick/canvas/twitterfriends/cache.js create mode 100644 examples/qtquick/canvas/twitterfriends/twitter.qml create mode 100644 examples/qtquick/draganddrop/dragtarget.qmlproject create mode 100644 examples/qtquick/draganddrop/tiles/DragTile.qml create mode 100644 examples/qtquick/draganddrop/tiles/DropTile.qml create mode 100644 examples/qtquick/draganddrop/tiles/tiles.qml create mode 100644 examples/qtquick/draganddrop/views/gridview.qml create mode 100644 examples/qtquick/imageelements/borderimage.qml create mode 100644 examples/qtquick/imageelements/content/BearSheet.png create mode 100644 examples/qtquick/imageelements/content/ImageCell.qml create mode 100644 examples/qtquick/imageelements/content/MyBorderImage.qml create mode 100644 examples/qtquick/imageelements/content/ShadowRectangle.qml create mode 100644 examples/qtquick/imageelements/content/bw.png create mode 100644 examples/qtquick/imageelements/content/colors-round.sci create mode 100644 examples/qtquick/imageelements/content/colors-stretch.sci create mode 100644 examples/qtquick/imageelements/content/colors.png create mode 100644 examples/qtquick/imageelements/content/qt-logo.png create mode 100644 examples/qtquick/imageelements/content/shadow.png create mode 100644 examples/qtquick/imageelements/content/speaker.png create mode 100644 examples/qtquick/imageelements/image.qml create mode 100644 examples/qtquick/imageelements/imageelements.qml create mode 100644 examples/qtquick/imageelements/imageelements.qmlproject create mode 100644 examples/qtquick/imageelements/shadows.qml create mode 100644 examples/qtquick/imageelements/simplesprite.qml create mode 100644 examples/qtquick/imageelements/spriteimage.qml create mode 100644 examples/qtquick/keyinteraction/focus/Core/ContextMenu.qml create mode 100644 examples/qtquick/keyinteraction/focus/Core/GridMenu.qml create mode 100644 examples/qtquick/keyinteraction/focus/Core/ListMenu.qml create mode 100644 examples/qtquick/keyinteraction/focus/Core/ListViewDelegate.qml create mode 100644 examples/qtquick/keyinteraction/focus/Core/images/arrow.png create mode 100644 examples/qtquick/keyinteraction/focus/Core/images/qt-logo.png create mode 100644 examples/qtquick/keyinteraction/focus/focus.qml create mode 100644 examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.pro create mode 100644 examples/qtquick/modelviews/abstractitemmodel/abstractitemmodel.qrc create mode 100644 examples/qtquick/modelviews/abstractitemmodel/main.cpp create mode 100644 examples/qtquick/modelviews/abstractitemmodel/model.cpp create mode 100644 examples/qtquick/modelviews/abstractitemmodel/model.h create mode 100644 examples/qtquick/modelviews/abstractitemmodel/view.qml create mode 100644 examples/qtquick/modelviews/gridview/gridview-example.qml create mode 100644 examples/qtquick/modelviews/gridview/pics/AddressBook_48.png create mode 100644 examples/qtquick/modelviews/gridview/pics/AudioPlayer_48.png create mode 100644 examples/qtquick/modelviews/gridview/pics/Camera_48.png create mode 100644 examples/qtquick/modelviews/gridview/pics/DateBook_48.png create mode 100644 examples/qtquick/modelviews/gridview/pics/EMail_48.png create mode 100644 examples/qtquick/modelviews/gridview/pics/TodoList_48.png create mode 100644 examples/qtquick/modelviews/gridview/pics/VideoPlayer_48.png create mode 100644 examples/qtquick/modelviews/listview/content/PetsModel.qml create mode 100644 examples/qtquick/modelviews/listview/content/PressAndHoldButton.qml create mode 100644 examples/qtquick/modelviews/listview/content/RecipesModel.qml create mode 100644 examples/qtquick/modelviews/listview/content/TextButton.qml create mode 100644 examples/qtquick/modelviews/listview/content/ToggleButton.qml create mode 100644 examples/qtquick/modelviews/listview/content/pics/arrow-down.png create mode 100644 examples/qtquick/modelviews/listview/content/pics/arrow-up.png create mode 100644 examples/qtquick/modelviews/listview/content/pics/fruit-salad.jpg create mode 100644 examples/qtquick/modelviews/listview/content/pics/hamburger.jpg create mode 100644 examples/qtquick/modelviews/listview/content/pics/lemonade.jpg create mode 100644 examples/qtquick/modelviews/listview/content/pics/list-delete.png create mode 100644 examples/qtquick/modelviews/listview/content/pics/minus-sign.png create mode 100644 examples/qtquick/modelviews/listview/content/pics/moreDown.png create mode 100644 examples/qtquick/modelviews/listview/content/pics/moreUp.png create mode 100644 examples/qtquick/modelviews/listview/content/pics/pancakes.jpg create mode 100644 examples/qtquick/modelviews/listview/content/pics/plus-sign.png create mode 100644 examples/qtquick/modelviews/listview/content/pics/vegetable-soup.jpg create mode 100644 examples/qtquick/modelviews/listview/dynamiclist.qml create mode 100644 examples/qtquick/modelviews/listview/expandingdelegates.qml create mode 100644 examples/qtquick/modelviews/listview/highlight.qml create mode 100644 examples/qtquick/modelviews/listview/highlightranges.qml create mode 100644 examples/qtquick/modelviews/listview/sections.qml create mode 100644 examples/qtquick/modelviews/modelviews.pro create mode 100644 examples/qtquick/modelviews/modelviews.qml create mode 100644 examples/qtquick/modelviews/modelviews.qmlproject create mode 100644 examples/qtquick/modelviews/objectlistmodel/dataobject.cpp create mode 100644 examples/qtquick/modelviews/objectlistmodel/dataobject.h create mode 100644 examples/qtquick/modelviews/objectlistmodel/main.cpp create mode 100644 examples/qtquick/modelviews/objectlistmodel/objectlistmodel.pro create mode 100644 examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qmlproject create mode 100644 examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qrc create mode 100644 examples/qtquick/modelviews/objectlistmodel/view.qml create mode 100644 examples/qtquick/modelviews/package/Delegate.qml create mode 100644 examples/qtquick/modelviews/package/view.qml create mode 100644 examples/qtquick/modelviews/parallax/content/Clock.qml create mode 100644 examples/qtquick/modelviews/parallax/content/ParallaxView.qml create mode 100644 examples/qtquick/modelviews/parallax/content/QuitButton.qml create mode 100644 examples/qtquick/modelviews/parallax/content/Smiley.qml create mode 100644 examples/qtquick/modelviews/parallax/content/background.png create mode 100644 examples/qtquick/modelviews/parallax/content/center.png create mode 100644 examples/qtquick/modelviews/parallax/content/clock-night.png create mode 100644 examples/qtquick/modelviews/parallax/content/clock.png create mode 100644 examples/qtquick/modelviews/parallax/content/hour.png create mode 100644 examples/qtquick/modelviews/parallax/content/minute.png create mode 100644 examples/qtquick/modelviews/parallax/content/pics/background.jpg create mode 100644 examples/qtquick/modelviews/parallax/content/pics/face-smile.png create mode 100644 examples/qtquick/modelviews/parallax/content/pics/home-page.png create mode 100644 examples/qtquick/modelviews/parallax/content/pics/home-page.svg create mode 100644 examples/qtquick/modelviews/parallax/content/pics/shadow.png create mode 100644 examples/qtquick/modelviews/parallax/content/pics/yast-joystick.png create mode 100644 examples/qtquick/modelviews/parallax/content/pics/yast-wol.png create mode 100644 examples/qtquick/modelviews/parallax/content/quit.png create mode 100644 examples/qtquick/modelviews/parallax/content/second.png create mode 100644 examples/qtquick/modelviews/parallax/parallax.qml create mode 100644 examples/qtquick/modelviews/pathview/pathview-example.qml create mode 100644 examples/qtquick/modelviews/pathview/pics/AddressBook_48.png create mode 100644 examples/qtquick/modelviews/pathview/pics/AudioPlayer_48.png create mode 100644 examples/qtquick/modelviews/pathview/pics/Camera_48.png create mode 100644 examples/qtquick/modelviews/pathview/pics/DateBook_48.png create mode 100644 examples/qtquick/modelviews/pathview/pics/EMail_48.png create mode 100644 examples/qtquick/modelviews/pathview/pics/TodoList_48.png create mode 100644 examples/qtquick/modelviews/pathview/pics/VideoPlayer_48.png create mode 100644 examples/qtquick/modelviews/stringlistmodel/main.cpp create mode 100644 examples/qtquick/modelviews/stringlistmodel/stringlistmodel.pro create mode 100644 examples/qtquick/modelviews/stringlistmodel/stringlistmodel.qrc create mode 100644 examples/qtquick/modelviews/stringlistmodel/view.qml create mode 100644 examples/qtquick/modelviews/visualdatamodel/dragselection.qml create mode 100644 examples/qtquick/modelviews/visualdatamodel/slideshow.qml create mode 100644 examples/qtquick/modelviews/visualdatamodel/sortedmodel.qml create mode 100644 examples/qtquick/modelviews/visualdatamodel/visualdatamodel.qmlproject create mode 100644 examples/qtquick/modelviews/visualitemmodel/visualitemmodel.qml create mode 100644 examples/qtquick/mousearea/mousearea-example.qml create mode 100644 examples/qtquick/openglunderqml/main.cpp create mode 100644 examples/qtquick/openglunderqml/main.qml create mode 100644 examples/qtquick/openglunderqml/openglunderqml.pro create mode 100644 examples/qtquick/openglunderqml/squircle.cpp create mode 100644 examples/qtquick/openglunderqml/squircle.h create mode 100644 examples/qtquick/painteditem/painteditem.pro create mode 100644 examples/qtquick/painteditem/smile/main.cpp create mode 100644 examples/qtquick/painteditem/smile/smile.pro create mode 100644 examples/qtquick/painteditem/smile/smile.qml create mode 100644 examples/qtquick/painteditem/textballoons/TextBalloonPlugin/plugin.h create mode 100644 examples/qtquick/painteditem/textballoons/TextBalloonPlugin/qmldir create mode 100644 examples/qtquick/painteditem/textballoons/textballoon.cpp create mode 100644 examples/qtquick/painteditem/textballoons/textballoon.h create mode 100644 examples/qtquick/painteditem/textballoons/textballoons.pro create mode 100644 examples/qtquick/painteditem/textballoons/textballoons.qml create mode 100644 examples/qtquick/positioners/content/Button.qml create mode 100644 examples/qtquick/positioners/content/add.png create mode 100644 examples/qtquick/positioners/content/del.png create mode 100644 examples/qtquick/positioners/positioners-attachedproperties.qml create mode 100644 examples/qtquick/positioners/positioners.qml create mode 100644 examples/qtquick/qtquick.pro create mode 100644 examples/qtquick/righttoleft/layoutdirection/layoutdirection.qml create mode 100644 examples/qtquick/righttoleft/layoutdirection/layoutdirection.qmlproject create mode 100644 examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qml create mode 100644 examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qmlproject create mode 100644 examples/qtquick/righttoleft/textalignment/textalignment.qml create mode 100644 examples/qtquick/righttoleft/textalignment/textalignment.qmlproject create mode 100644 examples/qtquick/shadereffects/content/Slider.qml create mode 100644 examples/qtquick/shadereffects/content/face-smile.png create mode 100644 examples/qtquick/shadereffects/content/qt-logo.png create mode 100644 examples/qtquick/shadereffects/shadereffects.qml create mode 100644 examples/qtquick/text/fonts/availableFonts.qml create mode 100644 examples/qtquick/text/fonts/banner.qml create mode 100644 examples/qtquick/text/fonts/content/fonts/tarzeau_ocr_a.ttf create mode 100644 examples/qtquick/text/fonts/fonts.qml create mode 100644 examples/qtquick/text/fonts/hello.qml create mode 100644 examples/qtquick/text/imgtag/TextWithImage.qml create mode 100644 examples/qtquick/text/imgtag/images/face-sad.png create mode 100644 examples/qtquick/text/imgtag/images/face-smile-big.png create mode 100644 examples/qtquick/text/imgtag/images/face-smile.png create mode 100644 examples/qtquick/text/imgtag/images/heart200.png create mode 100644 examples/qtquick/text/imgtag/images/qtlogo.png create mode 100644 examples/qtquick/text/imgtag/images/starfish_2.png create mode 100644 examples/qtquick/text/imgtag/imgtag.qml create mode 100644 examples/qtquick/text/styledtext-layout.qml create mode 100644 examples/qtquick/text/text.qml create mode 100644 examples/qtquick/text/text.qmlproject create mode 100644 examples/qtquick/text/textselection/pics/endHandle.png create mode 100644 examples/qtquick/text/textselection/pics/endHandle.sci create mode 100644 examples/qtquick/text/textselection/pics/startHandle.png create mode 100644 examples/qtquick/text/textselection/pics/startHandle.sci create mode 100644 examples/qtquick/text/textselection/textselection.qml create mode 100644 examples/qtquick/threading/threadedlistmodel/dataloader.js create mode 100644 examples/qtquick/threading/threadedlistmodel/threadedlistmodel.qmlproject create mode 100644 examples/qtquick/threading/threadedlistmodel/timedisplay.qml create mode 100644 examples/qtquick/threading/workerscript/workerscript.js create mode 100644 examples/qtquick/threading/workerscript/workerscript.qml create mode 100644 examples/qtquick/threading/workerscript/workerscript.qmlproject create mode 100644 examples/qtquick/touchinteraction/multipointtouch/bearwhack.qml create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/Bear0.png create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/Bear1.png create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/Bear2.png create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/Bear3.png create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/BearB.png create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/ParticleFlame.qml create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/blur-circle.png create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/blur-circle3.png create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/heart-blur.png create mode 100644 examples/qtquick/touchinteraction/multipointtouch/content/title.png create mode 100644 examples/qtquick/touchinteraction/multipointtouch/multiflame.qml create mode 100644 examples/qtquick/touchinteraction/pincharea/flickresize.qml create mode 100644 examples/qtquick/touchinteraction/pincharea/qt-logo.jpg create mode 100644 examples/qtquick/touchinteraction/touchinteraction.qml create mode 100644 examples/qtquick/touchinteraction/touchinteraction.qmlproject create mode 100644 examples/shared/Button.qml create mode 100644 examples/shared/LauncherList.qml create mode 100644 examples/shared/README create mode 100644 examples/shared/SimpleLauncherDelegate.qml create mode 100644 examples/shared/images/back.png create mode 100644 examples/shared/qmldir create mode 100644 examples/shared/shared.h create mode 100644 examples/shared/shared.pro create mode 100644 examples/tutorials/dynamicview/dynamicview1/PetsModel.qml create mode 100644 examples/tutorials/dynamicview/dynamicview1/dynamicview.qml create mode 100644 examples/tutorials/dynamicview/dynamicview2/PetsModel.qml create mode 100644 examples/tutorials/dynamicview/dynamicview2/dynamicview.qml create mode 100644 examples/tutorials/dynamicview/dynamicview3/PetsModel.qml create mode 100644 examples/tutorials/dynamicview/dynamicview3/dynamicview.qml create mode 100644 examples/tutorials/dynamicview/dynamicview4/ListSelector.qml create mode 100644 examples/tutorials/dynamicview/dynamicview4/PetsModel.qml create mode 100644 examples/tutorials/dynamicview/dynamicview4/dynamicview.qml create mode 100644 examples/tutorials/extending/chapter1-basics/app.qml create mode 100644 examples/tutorials/extending/chapter1-basics/chapter1-basics.pro create mode 100644 examples/tutorials/extending/chapter1-basics/main.cpp create mode 100644 examples/tutorials/extending/chapter1-basics/piechart.cpp create mode 100644 examples/tutorials/extending/chapter1-basics/piechart.h create mode 100644 examples/tutorials/extending/chapter2-methods/app.qml create mode 100644 examples/tutorials/extending/chapter2-methods/chapter2-methods.pro create mode 100644 examples/tutorials/extending/chapter2-methods/main.cpp create mode 100644 examples/tutorials/extending/chapter2-methods/piechart.cpp create mode 100644 examples/tutorials/extending/chapter2-methods/piechart.h create mode 100644 examples/tutorials/extending/chapter3-bindings/app.qml create mode 100644 examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro create mode 100644 examples/tutorials/extending/chapter3-bindings/main.cpp create mode 100644 examples/tutorials/extending/chapter3-bindings/piechart.cpp create mode 100644 examples/tutorials/extending/chapter3-bindings/piechart.h create mode 100644 examples/tutorials/extending/chapter4-customPropertyTypes/app.qml create mode 100644 examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro create mode 100644 examples/tutorials/extending/chapter4-customPropertyTypes/main.cpp create mode 100644 examples/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp create mode 100644 examples/tutorials/extending/chapter4-customPropertyTypes/piechart.h create mode 100644 examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp create mode 100644 examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.h create mode 100644 examples/tutorials/extending/chapter5-listproperties/app.qml create mode 100644 examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro create mode 100644 examples/tutorials/extending/chapter5-listproperties/main.cpp create mode 100644 examples/tutorials/extending/chapter5-listproperties/piechart.cpp create mode 100644 examples/tutorials/extending/chapter5-listproperties/piechart.h create mode 100644 examples/tutorials/extending/chapter5-listproperties/pieslice.cpp create mode 100644 examples/tutorials/extending/chapter5-listproperties/pieslice.h create mode 100644 examples/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir create mode 100644 examples/tutorials/extending/chapter6-plugins/app.qml create mode 100644 examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro create mode 100644 examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp create mode 100644 examples/tutorials/extending/chapter6-plugins/chartsplugin.h create mode 100644 examples/tutorials/extending/chapter6-plugins/piechart.cpp create mode 100644 examples/tutorials/extending/chapter6-plugins/piechart.h create mode 100644 examples/tutorials/extending/chapter6-plugins/pieslice.cpp create mode 100644 examples/tutorials/extending/chapter6-plugins/pieslice.h create mode 100644 examples/tutorials/extending/extending.pro create mode 100644 examples/tutorials/helloworld/Cell.qml create mode 100644 examples/tutorials/helloworld/tutorial1.qml create mode 100644 examples/tutorials/helloworld/tutorial2.qml create mode 100644 examples/tutorials/helloworld/tutorial3.qml create mode 100644 examples/tutorials/samegame/samegame1/Block.qml create mode 100644 examples/tutorials/samegame/samegame1/Button.qml create mode 100644 examples/tutorials/samegame/samegame1/samegame.qml create mode 100644 examples/tutorials/samegame/samegame1/samegame1.qmlproject create mode 100644 examples/tutorials/samegame/samegame2/Block.qml create mode 100644 examples/tutorials/samegame/samegame2/Button.qml create mode 100644 examples/tutorials/samegame/samegame2/samegame.js create mode 100644 examples/tutorials/samegame/samegame2/samegame.qml create mode 100644 examples/tutorials/samegame/samegame2/samegame2.qmlproject create mode 100644 examples/tutorials/samegame/samegame3/Block.qml create mode 100644 examples/tutorials/samegame/samegame3/Button.qml create mode 100644 examples/tutorials/samegame/samegame3/Dialog.qml create mode 100644 examples/tutorials/samegame/samegame3/samegame.js create mode 100644 examples/tutorials/samegame/samegame3/samegame.qml create mode 100644 examples/tutorials/samegame/samegame3/samegame3.qmlproject create mode 100644 examples/tutorials/samegame/samegame4/content/BoomBlock.qml create mode 100644 examples/tutorials/samegame/samegame4/content/Button.qml create mode 100644 examples/tutorials/samegame/samegame4/content/Dialog.qml create mode 100755 examples/tutorials/samegame/samegame4/content/samegame.js create mode 100644 examples/tutorials/samegame/samegame4/highscores/README create mode 100755 examples/tutorials/samegame/samegame4/highscores/score_data.xml create mode 100755 examples/tutorials/samegame/samegame4/highscores/score_style.xsl create mode 100755 examples/tutorials/samegame/samegame4/highscores/scores.php create mode 100644 examples/tutorials/samegame/samegame4/samegame.qml create mode 100644 examples/tutorials/samegame/samegame4/samegame4.qmlproject create mode 100644 examples/tutorials/samegame/shared/pics/background.jpg create mode 100644 examples/tutorials/samegame/shared/pics/blueStar.png create mode 100644 examples/tutorials/samegame/shared/pics/blueStone.png create mode 100644 examples/tutorials/samegame/shared/pics/greenStar.png create mode 100644 examples/tutorials/samegame/shared/pics/greenStone.png create mode 100644 examples/tutorials/samegame/shared/pics/redStar.png create mode 100644 examples/tutorials/samegame/shared/pics/redStone.png create mode 100644 examples/tutorials/samegame/shared/pics/star.png create mode 100644 examples/tutorials/samegame/shared/pics/yellowStone.png create mode 100644 examples/tutorials/ui-components/dialcontrol/content/Dial.qml create mode 100644 examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml create mode 100644 examples/tutorials/ui-components/dialcontrol/content/background.png create mode 100644 examples/tutorials/ui-components/dialcontrol/content/needle.png create mode 100644 examples/tutorials/ui-components/dialcontrol/content/needle_shadow.png create mode 100644 examples/tutorials/ui-components/dialcontrol/content/overlay.png create mode 100644 examples/tutorials/ui-components/dialcontrol/content/quit.png create mode 100644 examples/tutorials/ui-components/dialcontrol/dialcontrol.qml create mode 100644 examples/tutorials/ui-components/flipable/content/5_heart.png create mode 100644 examples/tutorials/ui-components/flipable/content/9_club.png create mode 100644 examples/tutorials/ui-components/flipable/content/Card.qml create mode 100644 examples/tutorials/ui-components/flipable/content/back.png create mode 100644 examples/tutorials/ui-components/flipable/flipable.qml create mode 100644 examples/tutorials/ui-components/progressbar/content/ProgressBar.qml create mode 100644 examples/tutorials/ui-components/progressbar/content/background.png create mode 100644 examples/tutorials/ui-components/progressbar/main.qml create mode 100644 examples/tutorials/ui-components/scrollbar/ScrollBar.qml create mode 100644 examples/tutorials/ui-components/scrollbar/main.qml create mode 100644 examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpg create mode 100644 examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject create mode 100644 examples/tutorials/ui-components/searchbox/SearchBox.qml create mode 100644 examples/tutorials/ui-components/searchbox/images/clear.png create mode 100644 examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.png create mode 100644 examples/tutorials/ui-components/searchbox/images/lineedit-bg.png create mode 100644 examples/tutorials/ui-components/searchbox/main.qml create mode 100644 examples/tutorials/ui-components/searchbox/searchbox.qmlproject create mode 100644 examples/tutorials/ui-components/slideswitch/content/Switch.qml create mode 100644 examples/tutorials/ui-components/slideswitch/content/background.png create mode 100644 examples/tutorials/ui-components/slideswitch/content/background.svg create mode 100644 examples/tutorials/ui-components/slideswitch/content/knob.png create mode 100644 examples/tutorials/ui-components/slideswitch/content/knob.svg create mode 100644 examples/tutorials/ui-components/slideswitch/slideswitch.qml create mode 100644 examples/tutorials/ui-components/spinner/content/Spinner.qml create mode 100644 examples/tutorials/ui-components/spinner/content/spinner-bg.png create mode 100644 examples/tutorials/ui-components/spinner/content/spinner-select.png create mode 100644 examples/tutorials/ui-components/spinner/main.qml create mode 100644 examples/tutorials/ui-components/spinner/spinner.qmlproject create mode 100644 examples/tutorials/ui-components/tabwidget/TabWidget.qml create mode 100644 examples/tutorials/ui-components/tabwidget/main.qml create mode 100644 examples/tutorials/ui-components/tabwidget/tab.png create mode 100644 examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject create mode 100644 examples/window/Window.qml create mode 100644 examples/window/screen/screenInfo.qml create mode 100644 examples/window/standalone.qml create mode 100644 examples/window/window.cpp create mode 100644 examples/window/window.pro diff --git a/.gitignore b/.gitignore index e1bf85aa29..4c8776bc5d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,6 @@ # This file is used to ignore files which are generated in the Qt build system # ---------------------------------------------------------------------------- -examples/*/*/* -!examples/*/*/*[.]* -!examples/*/*/README -examples/*/*/*[.]app -!examples/declarative/* -!examples/tutorials/* -!examples/tutorials/*/* -!examples/ja_JP/*/* -demos/*/* -!demos/spectrum/* -demos/spectrum/bin -!demos/*/*[.]* -demos/*/*[.]app -!demos/declarative/* config.tests/*/*/* !config.tests/*/*/*[.]* config.tests/*/*/*[.]app @@ -273,4 +259,4 @@ tests/auto/*/*.o tests/auto/*/*.moc tests/auto/*/*/*.o tests/auto/*/*/*.moc -src/declarative/generated/ \ No newline at end of file +src/declarative/generated/ diff --git a/doc/config/qtquick.qdocconf b/doc/config/qtquick.qdocconf index 69e860919e..3f4645aeaa 100644 --- a/doc/config/qtquick.qdocconf +++ b/doc/config/qtquick.qdocconf @@ -19,7 +19,8 @@ headerdirs += ../src \ imagedirs += ../src/images \ sourcedirs += ../src \ - ../../src + ../../src \ + ../../examples #indexes = $QT5DOC/doc/html/qt.index diff --git a/doc/src/examples/examples-groups.qdoc b/doc/src/examples/examples-groups.qdoc index 9a6dafa435..a346794b96 100644 --- a/doc/src/examples/examples-groups.qdoc +++ b/doc/src/examples/examples-groups.qdoc @@ -31,15 +31,6 @@ \image qml-i18n-example.png \brief This is an internationalization example */ -/*! - \title QML Examples - Shader Effects - \example declarative/shadereffects - \image qml-shadereffects-example.png - \brief This is a shader effects example - - This example demonstrates a couple of visual effects that you can perform - with shaders in QtQuick 2.0 -*/ /*! \title QML Examples - Positioners \example declarative/positioners @@ -48,16 +39,6 @@ This example demonstrates the positioners and some of their animations. */ -/*! - \title QML Examples - Animation - \example declarative/animation - \brief This is a collection of QML examples - \image qml-animations-example.png - - This is a collection of small QML examples relating to animation. Each example is - a small QML file, usually containing or emphasizing a particular element or - feature. You can run and observe the behavior of each example. -*/ /*! \title QML Examples - Image Elements \example declarative/imageelements diff --git a/doc/src/examples/examples-toys.qdoc b/doc/src/examples/examples-toys.qdoc index f076c1de6c..7414579e19 100644 --- a/doc/src/examples/examples-toys.qdoc +++ b/doc/src/examples/examples-toys.qdoc @@ -26,13 +26,6 @@ ****************************************************************************/ -/*! - \title QML Example - Calculator - \example declarative/calculator - \brief This is an example application written in QML. - \image qml-calculator-demo-small.png -*/ - /*! \title QML Example - Samegame \example declarative/samegame diff --git a/examples/HACKING b/examples/HACKING new file mode 100644 index 0000000000..a3aa3e9a77 --- /dev/null +++ b/examples/HACKING @@ -0,0 +1,23 @@ +Some guidelines for QtDeclarative examples + +Snippets +--- +Snippets are snatches of QML code that won't even run on their own. They don't belong here, they belong in doc/src/snippets. They should be contained in files that will compile on their own, for automated syntax validation, but don't have to look like anything. + +Examples +--- + +Examples are large blocks of QML code that demonstrate a feature. You should be able to launch an example and visually see the feature take effect. Examples should be written in a small form, and should automatically activate any features. Ideally, when you run an example, you see the feature demonstrate itself over and over until you get bored and close the application using your platform's close window mechanism. Examples shouldn't contain their own close buttons or start screen, explanatory text should be kept to a minimum (show, not tell), and reserve interaction for demonstrating interactive elements). The code should be held to a high level of quality, and should be understandable by people new to QML. + +Unless the demonstrated feature uses it, assume no interface devices other than a screen that can show a 320x480 rectangle and a generic pointing device (with the shared subset of mouse/touch functionality). + +Groups of similar examples should be placed in one folder with a single launcher application, which uses the QtQuick.Examples module for common components. + +The example, or launcher application in case of groups, should contain a qdoc comment explaining the example. The example or launcher should be buildable as a full C++ application and runnable with the standard qml file launcher. + +Demos +--- + +Demos are examples of creating full applications using QML. They should fit both a desktop and a mobile form factor, they should have their own start screen and method of exiting the application. They should be at a level of quality that you'd be comfortable submitting them to an app store for a platform of the appropriate hardware (screen size, input methods, etc.). The code should be written to a level that is easily understood and modified by a QML expert. + +Demos should have a qdoc file in their directory explaining the demo at a high level. The demo should be buildable as a full C++ application and preferably runnable with the standard qml file launcher. diff --git a/examples/README b/examples/README new file mode 100644 index 0000000000..aba1e2cc0d --- /dev/null +++ b/examples/README @@ -0,0 +1,12 @@ +The Qt Declarative module provides the ability to specify and implement +your user interface declaratively, using the Qt Meta-Object Language (QML). This +language is very expressive and human readable, and can be used by +designers to actually implement their UI vision. QML UIs can integrate +with C++ code in many ways, including being loaded as a part of a C++ UI +and loading data models from C++ and interacting with them. + +Mostof these examples can be viewed directly with the +QML viewer utility, without requiring compilation. + +Documentation for these examples can be found via the Examples +link in the main Qt documentation. diff --git a/examples/declarative/README b/examples/declarative/README deleted file mode 100644 index 56c48d71fb..0000000000 --- a/examples/declarative/README +++ /dev/null @@ -1,13 +0,0 @@ -The Qt Declarative module provides the ability to specify and implement -your user interface declaratively, using the Qt Meta-Object Language (QML). This -language is very expressive and human readable, and can be used by -designers to actually implement their UI vision. QML UIs can integrate -with C++ code in many ways, including being loaded as a part of a C++ UI -and loading data models from C++ and interacting with them. - -Mostof these examples can be viewed directly with the -QML viewer utility, without requiring compilation. - - -Documentation for these examples can be found via the Examples -link in the main Qt documentation. diff --git a/examples/declarative/accessibility/accessibility.qml b/examples/declarative/accessibility/accessibility.qml deleted file mode 100644 index 6fdcd38ac6..0000000000 --- a/examples/declarative/accessibility/accessibility.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 -import "widgets" - -Rectangle { - id: window - - width: 360; height: 300 - color: "white" - - Column { - id: column - spacing: 6 - anchors.fill: parent - width: parent.width - Row { - spacing: 6 - width: column.width - Button { width: 100; height: column.h + 20; text: "Send" } - Button { width: 100; height: column.h + 20; text: "Discard" } - } - - Row { - spacing: 6 - width: column.width - height: column.h - Text { - id: subjectLabel - Accessible.role: Accessible.StaticText - Accessible.name: text - text: "Subject:" - width: 50 - } - Rectangle { - id: subjectBorder - Accessible.role: Accessible.EditableText - Accessible.name: subjectEdit.text - border.width: 1 - border.color: "black" - height: subjectEdit.height - width: 304 - TextInput { - id: subjectEdit - text: "Vacation plans" - } - } - } - Rectangle { - id: textBorder - Accessible.role: Accessible.EditableText - property alias text : textEdit.text - border.width: 1 - border.color: "black" - width: parent.width - height: textEdit.height - TextEdit { - id: textEdit - text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke" - width: parent.width - wrapMode: TextEdit.WordWrap - } - } - } -} diff --git a/examples/declarative/accessibility/widgets/Button.qml b/examples/declarative/accessibility/widgets/Button.qml deleted file mode 100644 index 4a076fa428..0000000000 --- a/examples/declarative/accessibility/widgets/Button.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: button - - property alias text : buttonText.text - Accessible.name: text - Accessible.description: "This button does " + text - Accessible.role: Accessible.Button - - signal clicked - - width: buttonText.width + 20 - height: 30 - gradient: Gradient { - GradientStop { position: 0.0; color: "lightsteelblue" } - GradientStop { position: 1.0; color: "blue" } - } - border.width: 2 - border.color: "black"; - radius: 10 - - Text { - id: buttonText - text: parent.description - anchors.centerIn: parent - font.pixelSize: parent.height * .5 - style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - checked = !checked; - } - } -} diff --git a/examples/declarative/animation/animation.qml b/examples/declarative/animation/animation.qml deleted file mode 100644 index 7c5829e790..0000000000 --- a/examples/declarative/animation/animation.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../shared" - -Item { - height: 480 - width: 320 - LauncherList { - id: ll - anchors.fill: parent - Component.onCompleted: { - addExample("ColorAnimation", "Interpolates between colors", Qt.resolvedUrl("basics/color-animation.qml")); - addExample("PropertyAnimation", "Interpolates between numbers", Qt.resolvedUrl("basics/property-animation.qml")); - addExample("Behaviors", "Animates procedural movement", Qt.resolvedUrl("behaviors/behavior-example.qml")); - addExample("WigglyText", "Text that wiggles as you drag it", Qt.resolvedUrl("behaviors/wigglytext.qml")); - addExample("Easing Curves", "Compare available easing curves", Qt.resolvedUrl("easing/easing.qml")); - addExample("States", "Simple states", Qt.resolvedUrl("states/states.qml")); - addExample("Transitions", "Simple states with animated transitions", Qt.resolvedUrl("states/transitions.qml")); - addExample("PathAnimation", "Animate along a path", Qt.resolvedUrl("pathanimation/pathanimation.qml")); - addExample("PathInterpolator", "Interpolates along a path", Qt.resolvedUrl("pathinterpolator/pathinterpolator.qml")); - } - } -} diff --git a/examples/declarative/animation/animation.qmlproject b/examples/declarative/animation/animation.qmlproject deleted file mode 100644 index 2e96daa881..0000000000 --- a/examples/declarative/animation/animation.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "animation.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/animation/basics/color-animation.qml b/examples/declarative/animation/basics/color-animation.qml deleted file mode 100644 index a54091d7dd..0000000000 --- a/examples/declarative/animation/basics/color-animation.qml +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: window - width: 640; height: 480 - - // Let's draw the sky... - Rectangle { - anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { - position: 0.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 } - ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 } - } - } - GradientStop { - position: 1.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 } - ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 } - } - } - } - } - - // the sun, moon, and stars - Item { - width: parent.width; height: 2 * parent.height - NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite } - Image { - source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter - rotation: -3 * parent.rotation - } - Image { - source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter - rotation: -parent.rotation - } - ParticleSystem { - id: particlesystem - x: 0; y: parent.height/2 - width: parent.width; height: parent.height/2 - ImageParticle { - source: "images/star.png" - groups: ["star"] - color: "#00333333" - SequentialAnimation on opacity { - loops: Animation.Infinite - NumberAnimation { from: 0; to: 1; duration: 5000 } - NumberAnimation { from: 1; to: 0; duration: 5000 } - } - } - Emitter { - group: "star" - anchors.fill: parent - emitRate: parent.width / 50 - lifeSpan: 5000 - } - } - } - - // ...and the ground. - Rectangle { - anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { - position: 0.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 } - ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 } - } - } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } -} diff --git a/examples/declarative/animation/basics/images/face-smile.png b/examples/declarative/animation/basics/images/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/animation/basics/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/animation/basics/images/moon.png b/examples/declarative/animation/basics/images/moon.png deleted file mode 100644 index 9407b2b4f0..0000000000 Binary files a/examples/declarative/animation/basics/images/moon.png and /dev/null differ diff --git a/examples/declarative/animation/basics/images/shadow.png b/examples/declarative/animation/basics/images/shadow.png deleted file mode 100644 index 8270565e87..0000000000 Binary files a/examples/declarative/animation/basics/images/shadow.png and /dev/null differ diff --git a/examples/declarative/animation/basics/images/star.png b/examples/declarative/animation/basics/images/star.png deleted file mode 100644 index 27ef924267..0000000000 Binary files a/examples/declarative/animation/basics/images/star.png and /dev/null differ diff --git a/examples/declarative/animation/basics/images/sun.png b/examples/declarative/animation/basics/images/sun.png deleted file mode 100644 index 7713ca5ce7..0000000000 Binary files a/examples/declarative/animation/basics/images/sun.png and /dev/null differ diff --git a/examples/declarative/animation/basics/property-animation.qml b/examples/declarative/animation/basics/property-animation.qml deleted file mode 100644 index 4a4d3e3b2a..0000000000 --- a/examples/declarative/animation/basics/property-animation.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: window - width: 320; height: 480 - - // Let's draw the sky... - Rectangle { - anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { position: 0.0; color: "DeepSkyBlue" } - GradientStop { position: 1.0; color: "LightSkyBlue" } - } - } - - // ...and the ground. - Rectangle { - anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - // The shadow for the smiley face - Image { - anchors.horizontalCenter: parent.horizontalCenter - y: smiley.minHeight + 58 - source: "images/shadow.png" - - // The scale property depends on the y position of the smiley face. - scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) - } - - Image { - id: smiley - property int maxHeight: window.height / 3 - property int minHeight: 2 * window.height / 3 - - anchors.horizontalCenter: parent.horizontalCenter - y: minHeight - source: "images/face-smile.png" - - // Animate the y property. Setting loops to Animation.Infinite makes the - // animation repeat indefinitely, otherwise it would only run once. - SequentialAnimation on y { - loops: Animation.Infinite - - // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function - NumberAnimation { - from: smiley.minHeight; to: smiley.maxHeight - easing.type: Easing.OutExpo; duration: 300 - } - - // Then move back to minHeight in 1 second, using the OutBounce easing function - NumberAnimation { - from: smiley.maxHeight; to: smiley.minHeight - easing.type: Easing.OutBounce; duration: 1000 - } - - // Then pause for 500ms - PauseAnimation { duration: 500 } - } - } -} diff --git a/examples/declarative/animation/behaviors/SideRect.qml b/examples/declarative/animation/behaviors/SideRect.qml deleted file mode 100644 index 623c6965d8..0000000000 --- a/examples/declarative/animation/behaviors/SideRect.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: myRect - - property string text - - width: 75; height: 50 - radius: 6 - color: "#646464" - border.width: 4; border.color: "white" - - MouseArea { - anchors.fill: parent - hoverEnabled: true - onEntered: { - focusRect.x = myRect.x; - focusRect.y = myRect.y; - focusRect.text = myRect.text; - } - } -} diff --git a/examples/declarative/animation/behaviors/behavior-example.qml b/examples/declarative/animation/behaviors/behavior-example.qml deleted file mode 100644 index 89fc9992b6..0000000000 --- a/examples/declarative/animation/behaviors/behavior-example.qml +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 600; height: 400 - color: "#343434" - - Rectangle { - anchors.centerIn: parent - width: 200; height: 200 - radius: 30 - color: "transparent" - border.width: 4; border.color: "white" - - - SideRect { - id: leftRect - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left } - text: "Left" - } - - SideRect { - id: rightRect - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right } - text: "Right" - } - - SideRect { - id: topRect - anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter } - text: "Top" - } - - SideRect { - id: bottomRect - anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter } - text: "Bottom" - } - - - Rectangle { - id: focusRect - - property string text - - x: 62; y: 75; width: 75; height: 50 - radius: 6 - border.width: 4; border.color: "white" - color: "firebrick" - - // Set an 'elastic' behavior on the focusRect's x property. - Behavior on x { - NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } - } - - // Set an 'elastic' behavior on the focusRect's y property. - Behavior on y { - NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } - } - - Text { - id: focusText - text: focusRect.text - anchors.centerIn: parent - color: "white" - font.pixelSize: 16; font.bold: true - - // Set a behavior on the focusText's x property: - // Set the opacity to 0, set the new text value, then set the opacity back to 1. - Behavior on text { - SequentialAnimation { - NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } - NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } - } - } - } - } - } -} diff --git a/examples/declarative/animation/behaviors/wigglytext.qml b/examples/declarative/animation/behaviors/wigglytext.qml deleted file mode 100644 index e2ed472088..0000000000 --- a/examples/declarative/animation/behaviors/wigglytext.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Drag this text..." - property bool animated: true - - width: 640; height: 480; color: "#474747"; focus: true - - Keys.onPressed: { - if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace) - container.remove() - else if (event.text != "") { - container.append(event.text) - } - } - - function append(text) { - container.animated = false - var lastLetter = container.children[container.children.length - 1] - var newLetter = letterComponent.createObject(container) - newLetter.text = text - newLetter.follow = lastLetter - container.animated = true - } - - function remove() { - if (container.children.length) - container.children[container.children.length - 1].destroy() - } - - function doLayout() { - var follow = null - for (var i = 0; i < container.text.length; ++i) { - var newLetter = letterComponent.createObject(container) - newLetter.text = container.text[i] - newLetter.follow = follow - follow = newLetter - } - } - - Component { - id: letterComponent - Text { - id: letter - property variant follow - - x: follow ? follow.x + follow.width : container.width / 3 - y: follow ? follow.y : container.height / 2 - - font.pixelSize: 40; font.bold: true - color: "#999999"; styleColor: "#222222"; style: Text.Raised - - MouseArea { - anchors.fill: parent - drag.target: letter; drag.axis: Drag.XandYAxis - onPressed: letter.color = "#dddddd" - onReleased: letter.color = "#999999" - } - - Behavior on x { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } - Behavior on y { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } - } - } - - Component.onCompleted: doLayout() -} diff --git a/examples/declarative/animation/easing/content/QuitButton.qml b/examples/declarative/animation/easing/content/QuitButton.qml deleted file mode 100644 index 702b892d23..0000000000 --- a/examples/declarative/animation/easing/content/QuitButton.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -Image { - source: "quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -10 - onClicked: Qt.quit() - } -} diff --git a/examples/declarative/animation/easing/content/quit.png b/examples/declarative/animation/easing/content/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/declarative/animation/easing/content/quit.png and /dev/null differ diff --git a/examples/declarative/animation/easing/easing.qml b/examples/declarative/animation/easing/easing.qml deleted file mode 100644 index 207b653d6e..0000000000 --- a/examples/declarative/animation/easing/easing.qml +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: window - width: 600; height: 460; color: "#232323" - - property var easingCurve: [ 0.2, 0.2, 0.13, 0.65, 0.2, 0.8, - 0.624, 0.98, 0.93, 0.95, 1, 1 ] - - ListModel { - id: easingTypes - ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" } - ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" } - ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" } - ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" } - ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" } - ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" } - ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" } - ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" } - ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" } - ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" } - ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" } - ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" } - ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" } - ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" } - ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" } - ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" } - ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" } - ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" } - ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" } - ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" } - ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" } - ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" } - ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" } - ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" } - ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" } - ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" } - ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" } - ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" } - ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" } - ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" } - ListElement { name: "Easing.OutElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } - ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" } - ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" } - ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" } - ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" } - ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" } - ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" } - ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" } - ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" } - ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" } - ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" } - ListElement { name: "Easing.Bezier"; type: Easing.Bezier; ballColor: "Chartreuse"; } - } - - Component { - id: delegate - - Item { - height: 56; width: window.width - - Text { text: name; anchors.centerIn: parent; color: "White" } - - Rectangle { - id: slot1; color: "#121212"; x: 30; height: 46; width: 46 - border.color: "#343434"; border.width: 1; radius: 12 - anchors.verticalCenter: parent.verticalCenter - } - - Rectangle { - id: slot2; color: "#121212"; x: window.width - 76; height: 46; width: 46 - border.color: "#343434"; border.width: 1; radius: 12 - anchors.verticalCenter: parent.verticalCenter - } - - Rectangle { - id: rect; x: 30; color: "#454545" - border.color: "White"; border.width: 2 - height: 46; width: 46; radius: 12 - anchors.verticalCenter: parent.verticalCenter - - MouseArea { - onClicked: if (rect.state == '') rect.state = "right"; else rect.state = '' - anchors.fill: parent - anchors.margins: -5 // Make MouseArea bigger than the rectangle, itself - } - - states : State { - name: "right" - PropertyChanges { target: rect; x: window.width - 76; color: ballColor } - } - - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 } - ColorAnimation { properties: "color"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 } - } - } - } - } - - Flickable { - anchors.fill: parent - contentHeight: layout.height+50 - Rectangle { - id: titlePane - color: "#444444" - height: 35 - anchors { top: parent.top; left: parent.left; right: parent.right } - QuitButton { - id: quitButton - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: 10 - } - } - Column { - id: layout - anchors { top: titlePane.bottom; topMargin: 10; left: parent.left; right: parent.right } - Repeater { model: easingTypes; delegate: delegate } - } - } - - function getBezierCurve(name) - { - if (name === "Easing.Bezier") - return easingCurve; - return []; - } -} diff --git a/examples/declarative/animation/pathanimation/pathanimation.qml b/examples/declarative/animation/pathanimation/pathanimation.qml deleted file mode 100644 index 4d0a31bdf8..0000000000 --- a/examples/declarative/animation/pathanimation/pathanimation.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: window - width: 400 - height: 400 - - Canvas { - id: canvas - anchors.fill: parent - smooth: true - - onPaint: { - context.clearRect(0, 0, width, height) - context.strokeStyle = "black" - context.path = pathAnim.path - context.stroke() - } - } - - PathAnimation { - id: pathAnim - - duration: 2000 - easing.type: Easing.InQuad - - target: box - orientation: PathAnimation.RightFirst - anchorPoint: Qt.point(box.width/2, box.height/2) - path: Path { - startX: 50; startY: 50 - - PathCubic { - x: window.width - 50 - y: window.height - 50 - - control1X: x; control1Y: 50 - control2X: 50; control2Y: y - } - - onChanged: canvas.requestPaint() - } - } - - Rectangle { - id: box - - x: 25; y: 25 - width: 50; height: 50 - border.width: 1 - smooth: true - - Text { - anchors.centerIn: parent - text: "Box" - } - } - - MouseArea { - anchors.fill: parent - onClicked: pathAnim.restart() - } - - Text { - text: "Click anywhere to animate along the path" - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/examples/declarative/animation/pathinterpolator/pathinterpolator.qml b/examples/declarative/animation/pathinterpolator/pathinterpolator.qml deleted file mode 100644 index 67a34ce582..0000000000 --- a/examples/declarative/animation/pathinterpolator/pathinterpolator.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: window - width: 400 - height: 400 - - Canvas { - id: canvas - anchors.fill: parent - smooth: true - - onPaint: { - context.clearRect(0, 0, width, height) - context.strokeStyle = "black" - context.path = motionPath.path - context.stroke() - } - } - - PathInterpolator { - id: motionPath - - path: Path { - startX: 50; startY: 50 - - PathCubic { - x: window.width - 50 - y: window.height - 50 - - control1X: x; control1Y: 50 - control2X: 50; control2Y: y - } - - onChanged: canvas.requestPaint() - } - - NumberAnimation on progress { - id: progressAnim - running: false - from: 0; to: 1 - duration: 2000 - easing.type: Easing.InQuad - } - } - - Rectangle { - id: box - - width: 50; height: 50 - border.width: 1 - smooth: true - - //bind our attributes to follow the path as progress changes - x: motionPath.x - y: motionPath.y - rotation: motionPath.angle - transform: Translate { x: -box.width/2; y: -box.height/2 } - - Text { - anchors.centerIn: parent - text: "Box" - } - } - - MouseArea { - anchors.fill: parent - onClicked: progressAnim.restart() - } - - Text { - text: "Click anywhere to animate along the path" - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/examples/declarative/animation/states/qt-logo.png b/examples/declarative/animation/states/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/examples/declarative/animation/states/qt-logo.png and /dev/null differ diff --git a/examples/declarative/animation/states/states.qml b/examples/declarative/animation/states/states.qml deleted file mode 100644 index 7ca56a9295..0000000000 --- a/examples/declarative/animation/states/states.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - width: 640; height: 480 - color: "#343434" - - Image { - id: userIcon - x: topLeftRect.x; y: topLeftRect.y - source: "qt-logo.png" - } - - Rectangle { - id: topLeftRect - - anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to the default state, returning the image to - // its initial position - MouseArea { anchors.fill: parent; onClicked: page.state = '' } - } - - Rectangle { - id: middleRightRect - - anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'middleRight' - MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } - } - - Rectangle { - id: bottomLeftRect - - anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'bottomLeft' - MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } - } - - states: [ - // In state 'middleRight', move the image to middleRightRect - State { - name: "middleRight" - PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } - }, - - // In state 'bottomLeft', move the image to bottomLeftRect - State { - name: "bottomLeft" - PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } - } - ] -} diff --git a/examples/declarative/animation/states/transitions.qml b/examples/declarative/animation/states/transitions.qml deleted file mode 100644 index d57924d6d2..0000000000 --- a/examples/declarative/animation/states/transitions.qml +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -/* - This is exactly the same as states.qml, except that we have appended - a set of transitions to apply animations when the item changes - between each state. -*/ - -Rectangle { - id: page - width: 640; height: 480 - color: "#343434" - - Image { - id: userIcon - x: topLeftRect.x; y: topLeftRect.y - source: "qt-logo.png" - } - - Rectangle { - id: topLeftRect - - anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to the default state, returning the image to - // its initial position - MouseArea { anchors.fill: parent; onClicked: page.state = '' } - } - - Rectangle { - id: middleRightRect - - anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'middleRight' - MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } - } - - Rectangle { - id: bottomLeftRect - - anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'bottomLeft' - MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } - } - - states: [ - // In state 'middleRight', move the image to middleRightRect - State { - name: "middleRight" - PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } - }, - - // In state 'bottomLeft', move the image to bottomLeftRect - State { - name: "bottomLeft" - PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } - } - ] - - // Transitions define how the properties change when the item moves between each state - transitions: [ - - // When transitioning to 'middleRight' move x,y over a duration of 1 second, - // with OutBounce easing function. - Transition { - from: "*"; to: "middleRight" - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 } - }, - - // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds, - // with InOutQuad easing function. - Transition { - from: "*"; to: "bottomLeft" - NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 } - }, - - // For any other state changes move x,y linearly over duration of 200ms. - Transition { - NumberAnimation { properties: "x,y"; duration: 200 } - } - ] -} diff --git a/examples/declarative/calculator/calculator.qml b/examples/declarative/calculator/calculator.qml deleted file mode 100644 index e2d6679b89..0000000000 --- a/examples/declarative/calculator/calculator.qml +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 -import "content" -import "content/calculator.js" as CalcEngine - -Rectangle { - id: window - - width: 360; height: 480 - color: "#282828" - - property string rotateLeft: "\u2939" - property string rotateRight: "\u2935" - property string leftArrow: "\u2190" - property string division : "\u00f7" - property string multiplication : "\u00d7" - property string squareRoot : "\u221a" - property string plusminus : "\u00b1" - - function doOp(operation) { CalcEngine.doOperation(operation) } - - Item { - id: main - state: "orientation " + Screen.orientation - - property bool landscapeWindow: window.width > window.height - property real baseWidth: landscapeWindow ? window.height : window.width - property real baseHeight: landscapeWindow ? window.width : window.height - property real rotationDelta: landscapeWindow ? -90 : 0 - - rotation: rotationDelta - width: main.baseWidth - height: main.baseHeight - anchors.centerIn: parent - - Column { - id: box; spacing: 8 - - anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 } - - Display { - id: display - width: box.width-3 - height: 64 - } - - Column { - id: column; spacing: 6 - - property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6) - property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) - - Row { - spacing: 6 - Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" } - Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow } - Button { width: column.w; height: column.h; color: 'purple'; operation: "C" } - Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" } - } - - Row { - spacing: 6 - property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) - - Button { width: column.w; height: column.h; color: 'green'; operation: "mc" } - Button { width: column.w; height: column.h; color: 'green'; operation: "m+" } - Button { width: column.w; height: column.h; color: 'green'; operation: "m-" } - Button { width: column.w; height: column.h; color: 'green'; operation: "mr" } - } - - Grid { - id: grid; rows: 5; columns: 5; spacing: 6 - - property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns) - - Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: division } - Button { width: grid.w; height: column.h; operation: squareRoot } - Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: multiplication } - Button { width: grid.w; height: column.h; operation: "x^2" } - Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "-" } - Button { width: grid.w; height: column.h; operation: "1/x" } - Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' } - Button { width: grid.w; height: column.h; operation: "." } - Button { width: grid.w; height: column.h; operation: plusminus } - Button { width: grid.w; height: column.h; operation: "+" } - Button { width: grid.w; height: column.h; operation: "="; color: 'red' } - } - } - } - - states: [ - State { - name: "orientation " + Qt.LandscapeOrientation - PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - }, - State { - name: "orientation " + Qt.InvertedPortraitOrientation - PropertyChanges { target: main; rotation: 180 + rotationDelta; } - }, - State { - name: "orientation " + Qt.InvertedLandscapeOrientation - PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - } - ] - - transitions: Transition { - SequentialAnimation { - RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } - NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } - } - } - } -} diff --git a/examples/declarative/calculator/content/Button.qml b/examples/declarative/calculator/content/Button.qml deleted file mode 100644 index 6b480eb9b8..0000000000 --- a/examples/declarative/calculator/content/Button.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -BorderImage { - id: button - - property alias operation: buttonText.text - property string color: "" - - Accessible.name: operation - Accessible.description: "This button does " + operation - Accessible.role: Accessible.Button - - signal clicked - - source: "images/button-" + color + ".png"; clip: true - border { left: 10; top: 10; right: 10; bottom: 10 } - - Rectangle { - id: shade - anchors.fill: button; radius: 10; color: "black"; opacity: 0 - } - - Text { - id: buttonText - anchors.centerIn: parent; anchors.verticalCenterOffset: -1 - font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5 - style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - doOp(operation) - button.clicked() - } - } - - states: State { - name: "pressed"; when: mouseArea.pressed == true - PropertyChanges { target: shade; opacity: .4 } - } -} diff --git a/examples/declarative/calculator/content/Display.qml b/examples/declarative/calculator/content/Display.qml deleted file mode 100644 index 3333484971..0000000000 --- a/examples/declarative/calculator/content/Display.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -BorderImage { - id: image - - property alias text : displayText.text - property alias currentOperation : operationText - - source: "images/display.png" - border { left: 10; top: 10; right: 10; bottom: 10 } - - Text { - id: displayText - anchors { - right: parent.right; verticalCenter: parent.verticalCenter; verticalCenterOffset: -1 - rightMargin: 6; left: operationText.right - } - font.pixelSize: parent.height * .6; text: "0"; horizontalAlignment: Text.AlignRight; elide: Text.ElideRight - color: "#343434"; smooth: true; font.bold: true - } - Text { - id: operationText - font.bold: true; font.pixelSize: parent.height * .7 - color: "#343434"; smooth: true - anchors { left: parent.left; leftMargin: 6; verticalCenterOffset: -3; verticalCenter: parent.verticalCenter } - } -} diff --git a/examples/declarative/calculator/content/calculator.js b/examples/declarative/calculator/content/calculator.js deleted file mode 100644 index 7c363c7f30..0000000000 --- a/examples/declarative/calculator/content/calculator.js +++ /dev/null @@ -1,91 +0,0 @@ - -var curVal = 0 -var memory = 0 -var lastOp = "" -var timer = 0 - -function disabled(op) { - if (op == "." && display.text.toString().search(/\./) != -1) { - return true - } else if (op == squareRoot && display.text.toString().search(/-/) != -1) { - return true - } else { - return false - } -} - -function doOperation(op) { - if (disabled(op)) { - return - } - - if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) { - if (display.text.toString().length >= 14) - return; // No arbitrary length numbers - if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) { - display.text = display.text + op.toString() - } else { - display.text = op - } - lastOp = op - return - } - lastOp = op - - if (display.currentOperation.text == "+") { - display.text = Number(display.text.valueOf()) + Number(curVal.valueOf()) - } else if (display.currentOperation.text == "-") { - display.text = Number(curVal) - Number(display.text.valueOf()) - } else if (display.currentOperation.text == multiplication) { - display.text = Number(curVal) * Number(display.text.valueOf()) - } else if (display.currentOperation.text == division) { - display.text = Number(Number(curVal) / Number(display.text.valueOf())).toString() - } else if (display.currentOperation.text == "=") { - } - - if (op == "+" || op == "-" || op == multiplication || op == division) { - display.currentOperation.text = op - curVal = display.text.valueOf() - return - } - - curVal = 0 - display.currentOperation.text = "" - - if (op == "1/x") { - display.text = (1 / display.text.valueOf()).toString() - } else if (op == "x^2") { - display.text = (display.text.valueOf() * display.text.valueOf()).toString() - } else if (op == "Abs") { - display.text = (Math.abs(display.text.valueOf())).toString() - } else if (op == "Int") { - display.text = (Math.floor(display.text.valueOf())).toString() - } else if (op == plusminus) { - display.text = (display.text.valueOf() * -1).toString() - } else if (op == squareRoot) { - display.text = (Math.sqrt(display.text.valueOf())).toString() - } else if (op == "mc") { - memory = 0; - } else if (op == "m+") { - memory += display.text.valueOf() - } else if (op == "mr") { - display.text = memory.toString() - } else if (op == "m-") { - memory = display.text.valueOf() - } else if (op == leftArrow) { - display.text = display.text.toString().slice(0, -1) - if (display.text.length == 0) { - display.text = "0" - } - } else if (op == "Off") { - Qt.quit(); - } else if (op == "C") { - display.text = "0" - } else if (op == "AC") { - curVal = 0 - memory = 0 - lastOp = "" - display.text ="0" - } -} - diff --git a/examples/declarative/calculator/content/images/button-.png b/examples/declarative/calculator/content/images/button-.png deleted file mode 100644 index 544e514536..0000000000 Binary files a/examples/declarative/calculator/content/images/button-.png and /dev/null differ diff --git a/examples/declarative/calculator/content/images/button-blue.png b/examples/declarative/calculator/content/images/button-blue.png deleted file mode 100644 index 5f92de32d0..0000000000 Binary files a/examples/declarative/calculator/content/images/button-blue.png and /dev/null differ diff --git a/examples/declarative/calculator/content/images/button-green.png b/examples/declarative/calculator/content/images/button-green.png deleted file mode 100644 index 36c93914c7..0000000000 Binary files a/examples/declarative/calculator/content/images/button-green.png and /dev/null differ diff --git a/examples/declarative/calculator/content/images/button-purple.png b/examples/declarative/calculator/content/images/button-purple.png deleted file mode 100644 index 347cbbea9d..0000000000 Binary files a/examples/declarative/calculator/content/images/button-purple.png and /dev/null differ diff --git a/examples/declarative/calculator/content/images/button-red.png b/examples/declarative/calculator/content/images/button-red.png deleted file mode 100644 index 3b335891ae..0000000000 Binary files a/examples/declarative/calculator/content/images/button-red.png and /dev/null differ diff --git a/examples/declarative/calculator/content/images/display.png b/examples/declarative/calculator/content/images/display.png deleted file mode 100644 index 9507f4382e..0000000000 Binary files a/examples/declarative/calculator/content/images/display.png and /dev/null differ diff --git a/examples/declarative/calculator/content/qmldir b/examples/declarative/calculator/content/qmldir deleted file mode 100644 index a926b93fac..0000000000 --- a/examples/declarative/calculator/content/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Button Button.qml -Display Display.qml diff --git a/examples/declarative/canvas/bezierCurve/bezierCurve.qml b/examples/declarative/canvas/bezierCurve/bezierCurve.qml deleted file mode 100644 index f57839b0a5..0000000000 --- a/examples/declarative/canvas/bezierCurve/bezierCurve.qml +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Bezier Curve"; anchors.horizontalCenter:parent.horizontalCenter} - - Canvas { - id:canvas - width:360 - height:360 - property string strokeStyle:"red" - property string fillStyle:"red" - property int lineWidth:lineWidthCtrl.value - property bool fill:true - property bool stroke:true - property real alpha:alphaCtrl.value - property real scaleX : scaleXCtrl.value - property real scaleY : scaleYCtrl.value - property real rotate : rotateCtrl.value - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - - - Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } - Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - - onLineWidthChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onAlphaChanged:requestPaint(); - onScaleXChanged:requestPaint(); - onScaleYChanged:requestPaint(); - onRotateChanged:requestPaint(); - - onPaint: { - var ctx = canvas.getContext('2d'); - ctx.save(); - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.globalAlpha = canvas.alpha; - ctx.strokeStyle = canvas.strokeStyle; - ctx.fillStyle = canvas.fillStyle; - ctx.lineWidth = canvas.lineWidth; - ctx.scale(canvas.scaleX, canvas.scaleY); - ctx.rotate(canvas.rotate); - ctx.beginPath(); - ctx.moveTo(75,40); - ctx.bezierCurveTo(75,37,70,25,50,25); - ctx.bezierCurveTo(20,25,20,62.5,20,62.5); - ctx.bezierCurveTo(20,80,40,102,75,120); - ctx.bezierCurveTo(110,102,130,80,130,62.5); - ctx.bezierCurveTo(130,62.5,130,25,100,25); - ctx.bezierCurveTo(85,25,75,37,75,40); - ctx.closePath(); - if (canvas.fill) - ctx.fill(); - if (canvas.stroke) - ctx.stroke(); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} - Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} - Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} - Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/clip/clip.qml b/examples/declarative/canvas/clip/clip.qml deleted file mode 100644 index d861ff0a46..0000000000 --- a/examples/declarative/canvas/clip/clip.qml +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Makes squircle icon with clip"; anchors.horizontalCenter:parent.horizontalCenter} - Canvas { - id:canvas - width:360 - height:360 - property string strokeStyle:"blue" - property string fillStyle:"steelblue" - property int lineWidth:2 - property int nSize:nCtrl.value - property real radius:rCtrl.value - property bool fill:true - property bool stroke:false - property real px:xCtrl.value - property real py:yCtrl.value - property real alpha:alphaCtrl.value - property string imagefile:"../contents/qt-logo.png" - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - Component.onCompleted:loadImage(canvas.imagefile); - - onAlphaChanged:requestPaint(); - onRadiusChanged:requestPaint(); - onLineWidthChanged:requestPaint(); - onNSizeChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onPxChanged:requestPaint(); - onPyChanged:requestPaint(); - - onImageLoaded : requestPaint(); - - onPaint: squcirle(); - - function squcirle() { - var ctx = canvas.getContext("2d"); - var N = canvas.nSize; - var R = canvas.radius; - - N=Math.abs(N); - var M=N; - if (N>100) M=100; - if (N<0.00000000001) M=0.00000000001; - - ctx.save(); - ctx.globalAlpha =canvas.alpha; - ctx.fillStyle = "gray"; - ctx.fillRect(0, 0, canvas.width, canvas.height); - - ctx.strokeStyle = canvas.strokeStyle; - ctx.fillStyle = canvas.fillStyle; - ctx.lineWidth = canvas.lineWidth; - - ctx.beginPath(); - var i = 0, x, y; - for (i=0; i<(2*R+1); i++){ - x = Math.round(i-R) + canvas.px; - y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py; - - if (i == 0) - ctx.moveTo(x, y); - else - ctx.lineTo(x, y); - } - - for (i=(2*R); i<(4*R+1); i++){ - x =Math.round(3*R-i)+canvas.px; - y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py; - ctx.lineTo(x, y); - } - ctx.closePath(); - if (canvas.stroke) { - ctx.stroke(); - } - - if (canvas.fill) { - ctx.fill(); - } - ctx.clip(); - - ctx.drawImage(canvas.imagefile, 0, 0); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"} - Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"} - Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"} - Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/contents/Button.qml b/examples/declarative/canvas/contents/Button.qml deleted file mode 100644 index 1413cdb9fa..0000000000 --- a/examples/declarative/canvas/contents/Button.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - signal clicked - - property string text - width: buttonText.width + 28 - height: buttonText.height + 14 - - BorderImage { - id: buttonImage - source: "images/toolbutton.sci" - width: container.width - 10 - height: container.height - } - BorderImage { - id: pressed - opacity: 0 - source: "images/toolbutton.sci" - width: container.width - 10 - height: container.height - } - MouseArea { - id: mouseRegion - anchors.fill: buttonImage - onClicked: { container.clicked(); } - } - Text { - id: buttonText - color: "white" - anchors.centerIn: buttonImage - font.bold: true - font.pointSize: 15 - text: container.text - style: Text.Raised - styleColor: "black" - } - states: [ - State { - name: "Pressed" - when: mouseRegion.pressed == true - PropertyChanges { target: pressed; opacity: 1 } - } - ] -} \ No newline at end of file diff --git a/examples/declarative/canvas/contents/ScrollBar.qml b/examples/declarative/canvas/contents/ScrollBar.qml deleted file mode 100644 index 98b8efee4a..0000000000 --- a/examples/declarative/canvas/contents/ScrollBar.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Qt Mobility Components. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: scrollBar - // The properties that define the scrollbar's state. - // position and pageSize are in the range 0.0 - 1.0. They are relative to the - // height of the page, i.e. a pageSize of 0.5 means that you can see 50% - // of the height of the view. - // orientation can be either 'Vertical' or 'Horizontal' - property real position - property real pageSize - property string orientation : "Vertical" - property alias bgColor: background.color - property alias fgColor: thumb.color - - // A light, semi-transparent background - Rectangle { - id: background - radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) - color: "white"; opacity: 0.3 - anchors.fill: parent - } - // Size the bar to the required size, depending upon the orientation. - Rectangle { - id: thumb - opacity: 0.7 - color: "black" - radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) - x: orientation == 'Vertical' ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) - y: orientation == 'Vertical' ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 - width: orientation == 'Vertical' ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) - height: orientation == 'Vertical' ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) - } -} diff --git a/examples/declarative/canvas/contents/Slider.qml b/examples/declarative/canvas/contents/Slider.qml deleted file mode 100644 index 1050e307f6..0000000000 --- a/examples/declarative/canvas/contents/Slider.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id:slider - property real min:0 - property real max:1 - property real value: min + (max - min) * (bar.x / (foo.width - bar.width)) - property real init:min+(max-min)/2 - property string name:"Slider" - - Component.onCompleted: setValue(init) - function setValue(v) { - if (min < max) - bar.x = v/(max - min) * (foo.width - bar.width); - } - Rectangle { - id:sliderName - anchors.left:parent.left - height: childrenRect.height - width:childrenRect.width - anchors.verticalCenter:parent.verticalCenter - Text { - text:slider.name - font.pointSize:12 - } - } - Item { - id: foo - height: 6 - width: parent.width - 4 - sliderName.width - anchors.verticalCenter:parent.verticalCenter - anchors.left:sliderName.right - anchors.leftMargin:5 - Rectangle { - height: parent.height - anchors.left: parent.left - anchors.right: bar.horizontalCenter - color: "blue" - radius: 3 - } - Rectangle { - height: parent.height - anchors.left: bar.horizontalCenter - anchors.right: parent.right - color: "gray" - radius: 3 - } - Rectangle { - anchors.fill: parent - color: "transparent" - radius: 3 - border.width: 2 - border.color: "black" - } - - Rectangle { - id: bar - y: -7 - width: 20 - height: 20 - radius: 15 - color: "white" - border.width: 2 - border.color: "black" - MouseArea { - anchors.fill: parent - drag.target: parent - drag.axis: Drag.XAxis - drag.minimumX: 0 - drag.maximumX: foo.width - parent.width - } - } - } -} diff --git a/examples/declarative/canvas/contents/Stocks.qml b/examples/declarative/canvas/contents/Stocks.qml deleted file mode 100644 index 043bca132e..0000000000 --- a/examples/declarative/canvas/contents/Stocks.qml +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - id:stocks - //Data from : http://en.wikipedia.org/wiki/NASDAQ-100 - - ListElement {name:"Activision Blizzard"; stockId:"ATVI"} - ListElement {name:"Adobe Systems Incorporated"; stockId:"ADBE"} - ListElement {name:"Akamai Technologies, Inc"; stockId:"AKAM"} - ListElement {name:"Alexion Pharmaceuticals"; stockId:"ALXN"} - ListElement {name:"Altera Corporation"; stockId:"ALTR"} - ListElement {name:"Amazon.com, Inc."; stockId:"AMZN"} - ListElement {name:"Amgen Inc."; stockId:"AMGN"} - ListElement {name:"Apollo Group, Inc."; stockId:"APOL"} - ListElement {name:"Apple Inc."; stockId:"AAPL"} - ListElement {name:"Applied Materials, Inc."; stockId:"AMAT"} - ListElement {name:"Autodesk, Inc."; stockId:"ADSK"} - ListElement {name:"Automatic Data Processing, Inc."; stockId:"ADP"} - ListElement {name:"Baidu.com, Inc."; stockId:"BIDU"} - ListElement {name:"Bed Bath & Beyond Inc."; stockId:"BBBY"} - ListElement {name:"Biogen Idec, Inc"; stockId:"BIIB"} - ListElement {name:"BMC Software, Inc."; stockId:"BMC"} - ListElement {name:"Broadcom Corporation"; stockId:"BRCM"} - ListElement {name:"C. H. Robinson Worldwide, Inc."; stockId:"CHRW"} - ListElement {name:"CA, Inc."; stockId:"CA"} - ListElement {name:"Celgene Corporation"; stockId:"CELG"} - ListElement {name:"Cephalon, Inc."; stockId:"CEPH"} - ListElement {name:"Cerner Corporation"; stockId:"CERN"} - ListElement {name:"Check Point Software Technologies Ltd."; stockId:"CHKP"} - ListElement {name:"Cisco Systems, Inc."; stockId:"CSCO"} - ListElement {name:"Citrix Systems, Inc."; stockId:"CTXS"} - ListElement {name:"Cognizant Technology Solutions Corporation"; stockId:"CTSH"} - ListElement {name:"Comcast Corporation"; stockId:"CMCSA"} - ListElement {name:"Costco Wholesale Corporation"; stockId:"COST"} - ListElement {name:"Ctrip.com International, Ltd."; stockId:"CTRP"} - ListElement {name:"Dell Inc."; stockId:"DELL"} - ListElement {name:"DENTSPLY International Inc."; stockId:"XRAY"} - ListElement {name:"DirecTV"; stockId:"DTV"} - ListElement {name:"Dollar Tree, Inc."; stockId:"DLTR"} - ListElement {name:"eBay Inc."; stockId:"EBAY"} - ListElement {name:"Electronic Arts Inc."; stockId:"ERTS"} - ListElement {name:"Expedia, Inc."; stockId:"EXPE"} - ListElement {name:"Expeditors International of Washington, Inc."; stockId:"EXPD"} - ListElement {name:"Express Scripts, Inc."; stockId:"ESRX"} - ListElement {name:"F5 Networks, Inc."; stockId:"FFIV"} - ListElement {name:"Fastenal Company"; stockId:"FAST"} - ListElement {name:"First Solar, Inc."; stockId:"FSLR"} - ListElement {name:"Fiserv, Inc."; stockId:"FISV"} - ListElement {name:"Flextronics International Ltd."; stockId:"FLEX"} - ListElement {name:"FLIR Systems, Inc."; stockId:"FLIR"} - ListElement {name:"Garmin Ltd."; stockId:"GRMN"} - ListElement {name:"Gilead Sciences, Inc."; stockId:"GILD"} - ListElement {name:"Google Inc."; stockId:"GOOG"} - ListElement {name:"Green Mountain Coffee Roasters, Inc."; stockId:"GMCR"} - ListElement {name:"Henry Schein, Inc."; stockId:"HSIC"} - ListElement {name:"Illumina, Inc."; stockId:"ILMN"} - ListElement {name:"Infosys Technologies"; stockId:"INFY"} - ListElement {name:"Intel Corporation"; stockId:"INTC"} - ListElement {name:"Intuit, Inc."; stockId:"INTU"} - ListElement {name:"Intuitive Surgical Inc."; stockId:"ISRG"} - ListElement {name:"Joy Global Inc."; stockId:"JOYG"} - ListElement {name:"KLA Tencor Corporation"; stockId:"KLAC"} - ListElement {name:"Lam Research Corporation"; stockId:"LRCX"} - ListElement {name:"Liberty Media Corporation, Interactive Series A"; stockId:"LINTA"} - ListElement {name:"Life Technologies Corporation"; stockId:"LIFE"} - ListElement {name:"Linear Technology Corporation"; stockId:"LLTC"} - ListElement {name:"Marvell Technology Group, Ltd."; stockId:"MRVL"} - ListElement {name:"Mattel, Inc."; stockId:"MAT"} - ListElement {name:"Maxim Integrated Products"; stockId:"MXIM"} - ListElement {name:"Microchip Technology Incorporated"; stockId:"MCHP"} - ListElement {name:"Micron Technology, Inc."; stockId:"MU"} - ListElement {name:"Microsoft Corporation"; stockId:"MSFT"} - ListElement {name:"Mylan, Inc."; stockId:"MYL"} - ListElement {name:"NetApp, Inc."; stockId:"NTAP"} - ListElement {name:"Netflix, Inc."; stockId:"NFLX"} - ListElement {name:"News Corporation, Ltd."; stockId:"NWSA"} - ListElement {name:"NII Holdings, Inc."; stockId:"NIHD"} - ListElement {name:"NVIDIA Corporation"; stockId:"NVDA"} - ListElement {name:"O'Reilly Automotive, Inc."; stockId:"ORLY"} - ListElement {name:"Oracle Corporation"; stockId:"ORCL"} - ListElement {name:"PACCAR Inc."; stockId:"PCAR"} - ListElement {name:"Paychex, Inc."; stockId:"PAYX"} - ListElement {name:"Priceline.com, Incorporated"; stockId:"PCLN"} - ListElement {name:"Qiagen N.V."; stockId:"QGEN"} - ListElement {name:"QUALCOMM Incorporated"; stockId:"QCOM"} - ListElement {name:"Research in Motion Limited"; stockId:"RIMM"} - ListElement {name:"Ross Stores Inc."; stockId:"ROST"} - ListElement {name:"SanDisk Corporation"; stockId:"SNDK"} - ListElement {name:"Seagate Technology Holdings"; stockId:"STX"} - ListElement {name:"Sears Holdings Corporation"; stockId:"SHLD"} - ListElement {name:"Sigma-Aldrich Corporation"; stockId:"SIAL"} - ListElement {name:"Staples Inc."; stockId:"SPLS"} - ListElement {name:"Starbucks Corporation"; stockId:"SBUX"} - ListElement {name:"Stericycle, Inc"; stockId:"SRCL"} - ListElement {name:"Symantec Corporation"; stockId:"SYMC"} - ListElement {name:"Teva Pharmaceutical Industries Ltd."; stockId:"TEVA"} - ListElement {name:"Urban Outfitters, Inc."; stockId:"URBN"} - ListElement {name:"VeriSign, Inc."; stockId:"VRSN"} - ListElement {name:"Vertex Pharmaceuticals"; stockId:"VRTX"} - ListElement {name:"Virgin Media, Inc."; stockId:"VMED"} - ListElement {name:"Vodafone Group, plc."; stockId:"VOD"} - ListElement {name:"Warner Chilcott, Ltd."; stockId:"WCRX"} - ListElement {name:"Whole Foods Market, Inc."; stockId:"WFM"} - ListElement {name:"Wynn Resorts Ltd."; stockId:"WYNN"} - ListElement {name:"Xilinx, Inc."; stockId:"XLNX"} - ListElement {name:"Yahoo! Inc."; stockId:"YHOO"} -} diff --git a/examples/declarative/canvas/contents/TitleBar.qml b/examples/declarative/canvas/contents/TitleBar.qml deleted file mode 100644 index 28edda2ae7..0000000000 --- a/examples/declarative/canvas/contents/TitleBar.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: titleBar - property string title: "" - - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - - Image { - id: quitButton - anchors.left: parent.left//; anchors.leftMargin: 0 - anchors.verticalCenter: parent.verticalCenter - source: "images/quit.png" - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - } - - Text { - id: categoryText - anchors { - left: quitButton.right; right: parent.right; //leftMargin: 10; rightMargin: 10 - verticalCenter: parent.verticalCenter - } - elide: Text.ElideLeft - text: title - font.bold: true; font.pointSize: 20; color: "White"; style: Text.Raised; styleColor: "Black" - } -} diff --git a/examples/declarative/canvas/contents/ToolBar.qml b/examples/declarative/canvas/contents/ToolBar.qml deleted file mode 100644 index 7ae7391ddf..0000000000 --- a/examples/declarative/canvas/contents/ToolBar.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: toolbar - - property variant labels - signal buttonClicked(int index) - - BorderImage { - source: "images/titlebar.sci" - width: parent.width - height: parent.height + 14 - y: -7 - } - - Row { - y: 3 - anchors.horizontalCenter: parent.horizontalCenter - Repeater { - model: toolbar.labels - delegate: - Button { - text: modelData - onClicked: toolbar.buttonClicked(model.index) - } - } - } - -} diff --git a/examples/declarative/canvas/contents/images/button-pressed.png b/examples/declarative/canvas/contents/images/button-pressed.png deleted file mode 100644 index e434d327f2..0000000000 Binary files a/examples/declarative/canvas/contents/images/button-pressed.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/button.png b/examples/declarative/canvas/contents/images/button.png deleted file mode 100644 index 56a63ce641..0000000000 Binary files a/examples/declarative/canvas/contents/images/button.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/default.svg b/examples/declarative/canvas/contents/images/default.svg deleted file mode 100644 index 248199cc4e..0000000000 --- a/examples/declarative/canvas/contents/images/default.svg +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - weather-clear - January 2006 - - - Ryan Collier (pseudo) - - - - - http://www.tango-project.org - - - http://www.pseudocode.org - - - weather - applet - notification - - - - - - Garrett LeSage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/declarative/canvas/contents/images/gloss.png b/examples/declarative/canvas/contents/images/gloss.png deleted file mode 100755 index 5d370cd93d..0000000000 Binary files a/examples/declarative/canvas/contents/images/gloss.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/lineedit.png b/examples/declarative/canvas/contents/images/lineedit.png deleted file mode 100755 index 2cc38dc35b..0000000000 Binary files a/examples/declarative/canvas/contents/images/lineedit.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/lineedit.sci b/examples/declarative/canvas/contents/images/lineedit.sci deleted file mode 100644 index 054bff78be..0000000000 --- a/examples/declarative/canvas/contents/images/lineedit.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 10 -border.bottom: 10 -border.right: 10 -source: lineedit.png diff --git a/examples/declarative/canvas/contents/images/quit.png b/examples/declarative/canvas/contents/images/quit.png deleted file mode 100755 index 5bda1b6e0d..0000000000 Binary files a/examples/declarative/canvas/contents/images/quit.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/stripes.png b/examples/declarative/canvas/contents/images/stripes.png deleted file mode 100755 index 9f36727ea4..0000000000 Binary files a/examples/declarative/canvas/contents/images/stripes.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/titlebar.png b/examples/declarative/canvas/contents/images/titlebar.png deleted file mode 100755 index 51c90082d0..0000000000 Binary files a/examples/declarative/canvas/contents/images/titlebar.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/titlebar.sci b/examples/declarative/canvas/contents/images/titlebar.sci deleted file mode 100644 index 0418d94cd6..0000000000 --- a/examples/declarative/canvas/contents/images/titlebar.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 12 -border.bottom: 12 -border.right: 10 -source: titlebar.png diff --git a/examples/declarative/canvas/contents/images/toolbutton.png b/examples/declarative/canvas/contents/images/toolbutton.png deleted file mode 100755 index 11310013ee..0000000000 Binary files a/examples/declarative/canvas/contents/images/toolbutton.png and /dev/null differ diff --git a/examples/declarative/canvas/contents/images/toolbutton.sci b/examples/declarative/canvas/contents/images/toolbutton.sci deleted file mode 100644 index 9e4f965307..0000000000 --- a/examples/declarative/canvas/contents/images/toolbutton.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 15 -border.top: 4 -border.bottom: 4 -border.right: 15 -source: toolbutton.png diff --git a/examples/declarative/canvas/contents/qt-logo.png b/examples/declarative/canvas/contents/qt-logo.png deleted file mode 100644 index 5ab3a1b0c4..0000000000 Binary files a/examples/declarative/canvas/contents/qt-logo.png and /dev/null differ diff --git a/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml deleted file mode 100644 index bc3ca0071a..0000000000 --- a/examples/declarative/canvas/quadraticCurveTo/quadraticCurveTo.qml +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Quadratic Curve"; anchors.horizontalCenter:parent.horizontalCenter} - - Canvas { - id:canvas - width:360 - height:360 - property string strokeStyle:"steelblue" - property string fillStyle:"yellow" - property int lineWidth:lineWidthCtrl.value - property bool fill:true - property bool stroke:true - property real alpha:alphaCtrl.value - property real scaleX : scaleXCtrl.value - property real scaleY : scaleYCtrl.value - property real rotate : rotateCtrl.value - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - - onLineWidthChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onAlphaChanged:requestPaint(); - onScaleXChanged:requestPaint(); - onScaleYChanged:requestPaint(); - onRotateChanged:requestPaint(); - Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } - Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - - onPaint: { - var ctx = canvas.getContext('2d'); - ctx.save(); - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.globalAlpha = canvas.alpha; - ctx.strokeStyle = canvas.strokeStyle; - ctx.fillStyle = canvas.fillStyle; - ctx.lineWidth = canvas.lineWidth; - ctx.scale(canvas.scaleX, canvas.scaleY); - ctx.rotate(canvas.rotate); - ctx.beginPath(); - ctx.moveTo(75,25); - ctx.quadraticCurveTo(25,25,25,62.5); - ctx.quadraticCurveTo(25,100,50,100); - ctx.quadraticCurveTo(50,120,30,125); - ctx.quadraticCurveTo(60,120,65,100); - ctx.quadraticCurveTo(125,100,125,62.5); - ctx.quadraticCurveTo(125,25,75,25); - ctx.closePath(); - if (canvas.fill) - ctx.fill(); - if (canvas.stroke) - ctx.stroke(); - - - ctx.fillStyle="green"; - ctx.font = "Bold 15px"; - - ctx.fillText("QML酷毙了", 30, 60); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} - Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} - Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} - Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/roundedrect/roundedrect.qml b/examples/declarative/canvas/roundedrect/roundedrect.qml deleted file mode 100644 index fd86c63a3b..0000000000 --- a/examples/declarative/canvas/roundedrect/roundedrect.qml +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Rounded rectangle"; anchors.horizontalCenter:parent.horizontalCenter} - Canvas { - id:canvas - width:360 - height:360 - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - - property int radius: rCtrl.value - property int rectx: rxCtrl.value - property int recty: ryCtrl.value - property int rectWidth: width - 2*rectx - property int rectHeight: height - 2*recty - property string strokeStyle:"blue" - property string fillStyle:"steelblue" - property int lineWidth:lineWidthCtrl.value - property bool fill:true - property bool stroke:true - property real alpha:alphaCtrl.value - - onLineWidthChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onRadiusChanged:requestPaint(); - onRectxChanged:requestPaint(); - onRectyChanged:requestPaint(); - onAlphaChanged:requestPaint(); - - onPaint: { - var ctx = getContext("2d"); - ctx.save(); - ctx.clearRect(0,0,canvas.width, canvas.height); - ctx.strokeStyle = canvas.strokeStyle; - ctx.lineWidth = canvas.lineWidth - ctx.fillStyle = canvas.fillStyle - ctx.globalAlpha = canvas.alpha - ctx.beginPath(); - ctx.moveTo(rectx+radius,recty); // top side - ctx.lineTo(rectx+rectWidth-radius,recty); - // draw top right corner - ctx.arcTo(rectx+rectWidth,recty,rectx+rectWidth,recty+radius,radius); - ctx.lineTo(rectx+rectWidth,recty+rectHeight-radius); // right side - // draw bottom right corner - ctx.arcTo(rectx+rectWidth,recty+rectHeight,rectx+rectWidth-radius,recty+rectHeight,radius); - ctx.lineTo(rectx+radius,recty+rectHeight); // bottom side - // draw bottom left corner - ctx.arcTo(rectx,recty+rectHeight,rectx,recty+rectHeight-radius,radius); - ctx.lineTo(rectx,recty+radius); // left side - // draw top left corner - ctx.arcTo(rectx,recty,rectx+radius,recty,radius); - ctx.closePath(); - if (canvas.fill) - ctx.fill(); - if (canvas.stroke) - ctx.stroke(); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} - Slider {id:rxCtrl; width:300; height:30; min:5; max:30; init:10; name:"rectx"} - Slider {id:ryCtrl; width:300; height:30; min:5; max:30; init:10; name:"recty"} - Slider {id:rCtrl; width:300; height:30; min:10; max:100; init:40; name:"Radius"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/smile/smile.qml b/examples/declarative/canvas/smile/smile.qml deleted file mode 100644 index 28a48a6c81..0000000000 --- a/examples/declarative/canvas/smile/smile.qml +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Smile with arcs"; anchors.horizontalCenter:parent.horizontalCenter} - - Canvas { - id:canvas - width:360 - height:360 - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - - property string strokeStyle:"green" - property string fillStyle:"yellow" - property int lineWidth:lineWidthCtrl.value - property bool fill:true - property bool stroke:true - property real alpha:alphaCtrl.value - property real scaleX : scaleXCtrl.value - property real scaleY : scaleYCtrl.value - property real rotate : rotateCtrl.value - - onLineWidthChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onAlphaChanged:requestPaint(); - onScaleXChanged:requestPaint(); - onScaleYChanged:requestPaint(); - onRotateChanged:requestPaint(); - - Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } - Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } - - onPaint: { - var ctx = canvas.getContext('2d'); - ctx.save(); - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.globalAlpha = canvas.alpha; - ctx.strokeStyle = canvas.strokeStyle; - ctx.fillStyle = canvas.fillStyle; - ctx.lineWidth = canvas.lineWidth; - ctx.scale(canvas.scaleX, canvas.scaleY); - ctx.rotate(canvas.rotate); - ctx.beginPath(); - ctx.moveTo(75 + 50 * Math.cos(0), - 75 - 50 * Math.sin(Math.PI*2)); - ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle - ctx.moveTo(75,70); - ctx.arc(75,70,35,0,Math.PI,false); // Mouth (clockwise) - ctx.moveTo(60,65); - ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye - ctx.moveTo(90 + 5 * Math.cos(0), - 65 - 5 * Math.sin(Math.PI*2)); - ctx.moveTo(90,65); - ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye - ctx.closePath(); - if (canvas.fill) - ctx.fill(); - if (canvas.stroke) - ctx.stroke(); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} - Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} - Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} - Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/squircle/squircle.png b/examples/declarative/canvas/squircle/squircle.png deleted file mode 100644 index 86c69d945f..0000000000 Binary files a/examples/declarative/canvas/squircle/squircle.png and /dev/null differ diff --git a/examples/declarative/canvas/squircle/squircle.qml b/examples/declarative/canvas/squircle/squircle.qml deleted file mode 100644 index 2fc65b67b3..0000000000 --- a/examples/declarative/canvas/squircle/squircle.qml +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Squircles"; anchors.horizontalCenter:parent.horizontalCenter} - Image { - anchors.horizontalCenter:parent.horizontalCenter - source:"squircle.png" - width:250 - height:25 - } - Canvas { - id:canvas - width:360 - height:360 - smooth:true - renderTarget:Canvas.Image - renderStrategy: Canvas.Immediate - - property string strokeStyle:"blue" - property string fillStyle:"steelblue" - property int lineWidth:2 - property int nSize:nCtrl.value - property real radius:rCtrl.value - property bool fill:true - property bool stroke:false - property real px:xCtrl.value - property real py:yCtrl.value - property real alpha:alphaCtrl.value - - onAlphaChanged:requestPaint(); - onRadiusChanged:requestPaint(); - onLineWidthChanged:requestPaint(); - onNSizeChanged:requestPaint(); - onFillChanged:requestPaint(); - onStrokeChanged:requestPaint(); - onPxChanged:requestPaint(); - onPyChanged:requestPaint(); - - - onPaint: squcirle(); - - function squcirle() { - var ctx = canvas.getContext("2d"); - var N = canvas.nSize; - var R = canvas.radius; - - N=Math.abs(N); - var M=N; - if (N>100) M=100; - if (N<0.00000000001) M=0.00000000001; - - ctx.save(); - ctx.globalAlpha =canvas.alpha; - ctx.fillStyle = "gray"; - ctx.fillRect(0, 0, canvas.width, canvas.height); - - ctx.strokeStyle = canvas.strokeStyle; - ctx.fillStyle = canvas.fillStyle; - ctx.lineWidth = canvas.lineWidth; - - ctx.beginPath(); - var i = 0, x, y; - for (i=0; i<(2*R+1); i++){ - x = Math.round(i-R) + canvas.px; - y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py; - - if (i == 0) - ctx.moveTo(x, y); - else - ctx.lineTo(x, y); - } - - for (i=(2*R); i<(4*R+1); i++){ - x =Math.round(3*R-i)+canvas.px; - y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py; - ctx.lineTo(x, y); - } - ctx.closePath(); - if (canvas.stroke) { - ctx.stroke(); - } - - if (canvas.fill) { - ctx.fill(); - } - - ctx.fillStyle = "yellow"; - ctx.font = "Helvetica 16px"; - ctx.fillText("|X-" + Math.round(canvas.px) + "|^" + N + " + |Y-"+Math.round(canvas.py)+"|^" + N + " = |" + Math.round(R) + "|^" + N, canvas.px - 125, canvas.py); - ctx.restore(); - } - } - - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"} - Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"} - Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"} - Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/stockchart/README b/examples/declarative/canvas/stockchart/README deleted file mode 100644 index 2652866ed6..0000000000 --- a/examples/declarative/canvas/stockchart/README +++ /dev/null @@ -1,5 +0,0 @@ -To run: - - make install - QML_IMPORT_PATH=$PWD qmlscene stock.qml - diff --git a/examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir b/examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir deleted file mode 100644 index 4c60e556d4..0000000000 --- a/examples/declarative/canvas/stockchart/com/nokia/StockChartExample/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmlstockchartexampleplugin diff --git a/examples/declarative/canvas/stockchart/model.cpp b/examples/declarative/canvas/stockchart/model.cpp deleted file mode 100644 index 42eb2d592f..0000000000 --- a/examples/declarative/canvas/stockchart/model.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "model.h" - -#include -#include -#include -#include -#include - -#include -#include - -StockModel::StockModel(QObject *parent) - : QAbstractListModel(parent) - , _startDate(QDate(1995, 4, 25)) - , _endDate(QDate::currentDate()) - , _dataCycle(StockModel::Daily) - , _manager(0) - , _updating(false) -{ - QHash roles; - roles[StockModel::DateRole] = "date"; - roles[StockModel::SectionRole] = "year"; - roles[StockModel::OpenPriceRole] = "openPrice"; - roles[StockModel::ClosePriceRole] = "closePrice"; - roles[StockModel::HighPriceRole] = "highPrice"; - roles[StockModel::LowPriceRole] = "lowPrice"; - roles[StockModel::VolumeRole] = "volume"; - roles[StockModel::AdjustedPriceRole] = "adjustedPrice"; - setRoleNames(roles); - - connect(this, SIGNAL(stockNameChanged()), SLOT(requestData())); - connect(this, SIGNAL(startDateChanged()), SLOT(requestData())); - connect(this, SIGNAL(endDateChanged()), SLOT(requestData())); - connect(this, SIGNAL(dataCycleChanged()), SLOT(requestData())); - - _manager = new QNetworkAccessManager(this); - connect(_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(update(QNetworkReply*))); - -} - -int StockModel::rowCount(const QModelIndex & parent) const { - Q_UNUSED(parent); - return _prices.count(); -} - -StockPrice* StockModel::stockPriceAtIndex(int idx) const -{ - if (idx >=0 && idx < _prices.size()) { - return _prices[idx]; - } - return 0; -} - - -void StockModel::requestData() -{ - if (!_updating) { - _updating = true; - QMetaObject::invokeMethod(this, "doRequest", Qt::QueuedConnection); - } -} - -void StockModel::doRequest() -{ - /* - Fetch stock data from yahoo finance: - url: http://ichart.finance.yahoo.com/table.csv?s=NOK&a=5&b=11&c=2010&d=7&e=23&f=2010&g=d&ignore=.csv - s:stock name/id, a:start day, b:start month, c:start year default: 25 April 1995, oldest c= 1962 - d:end day, e:end month, f:end year, default:today (data only available 3 days before today) - g:data cycle(d daily, w weekly, m monthly, v Dividend) - */ - if (_manager && !_stockName.isEmpty() && _endDate > _startDate) { - QString query("http://ichart.finance.yahoo.com/table.csv?s=%1&a=%2&b=%3&c=%4&d=%5&e=%6&f=%7&g=%8&ignore=.csv"); - query = query.arg(_stockName) - .arg(_startDate.day()).arg(_startDate.month()).arg(_startDate.year()) - .arg(_endDate.day()).arg(_endDate.month()).arg(_endDate.year()) - .arg(dataCycleString()); - - qDebug() << "request stock data:" << query; - QNetworkReply* reply = _manager->get(QNetworkRequest(QUrl(query))); - connect(reply, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(downloadProgress(qint64,qint64))); - } -} - -void StockModel::update(QNetworkReply *reply) -{ - _updating = false; - - if (reply) { - if (reply->error() == QNetworkReply::NoError) { - beginResetModel(); - - foreach (StockPrice* p, _prices) { - p->deleteLater(); - } - - _prices.clear(); - - while (!reply->atEnd()) { - QString line = reply->readLine(); - QStringList fields = line.split(','); - - //data format:Date,Open,High,Low,Close,Volume,Adjusted close price - //example: 2011-06-24,6.03,6.04,5.88,5.88,20465200,5.88 - if (fields.size() == 7) { - StockPrice* price = new StockPrice(this); - price->setDate(QDate::fromString(fields[0], Qt::ISODate)); - price->setOpenPrice(fields[1].toFloat()); - price->setHighPrice(fields[2].toFloat()); - price->setLowPrice(fields[3].toFloat()); - price->setClosePrice(fields[4].toFloat()); - price->setVolume(fields[5].toInt()); - price->setAdjustedPrice(fields[6].toFloat()); - _prices.prepend(price); - } - } - qDebug() << "get stock data successfully, total:" << _prices.count() << "records."; - } else { - qDebug() << "get stock data failed:" << reply->errorString(); - } - reply->deleteLater(); - endResetModel(); - emit dataChanged(QModelIndex(), QModelIndex()); - } -} - -QVariant StockModel::data(const QModelIndex & index, int role) const { - if (index.row() < 0 || index.row() > _prices.count()) - return QVariant(); - - const StockPrice* price = _prices[index.row()]; - if (role == StockModel::DateRole) - return price->date(); - else if (role == StockModel::OpenPriceRole) - return price->openPrice(); - else if (role == StockModel::ClosePriceRole) - return price->closePrice(); - else if (role == StockModel::HighPriceRole) - return price->highPrice(); - else if (role == StockModel::LowPriceRole) - return price->lowPrice(); - else if (role == StockModel::AdjustedPriceRole) - return price->adjustedPrice(); - else if (role == StockModel::VolumeRole) - return price->volume(); - else if (role == StockModel::SectionRole) - return price->date().year(); - return QVariant(); -} - -QString StockModel::stockName() const -{ - return _stockName; -} -void StockModel::setStockName(const QString& name) -{ - if (_stockName != name) { - _stockName = name; - emit stockNameChanged(); - } -} - -QDate StockModel::startDate() const -{ - return _startDate; -} -void StockModel::setStartDate(const QDate& date) -{ - if (_startDate.isValid() && _startDate != date) { - _startDate = date; - emit startDateChanged(); - } -} - -QDate StockModel::endDate() const -{ - return _endDate; -} -void StockModel::setEndDate(const QDate& date) -{ - if (_endDate.isValid() && _endDate != date) { - _endDate = date; - emit endDateChanged(); - } -} - -StockModel::StockDataCycle StockModel::dataCycle() const -{ - return _dataCycle; -} - -QString StockModel::dataCycleString() const -{ - switch (_dataCycle) { - case StockModel::Daily: - return QString('d'); - break; - case StockModel::Weekly: - return QString('w'); - case StockModel::Monthly: - return QString('m'); - case StockModel::Dividend: - return QString('v'); - } - - return QString('d'); -} - - -void StockModel::setDataCycle(StockModel::StockDataCycle cycle) -{ - if (_dataCycle != cycle) { - _dataCycle = cycle; - emit dataCycleChanged(); - } -} diff --git a/examples/declarative/canvas/stockchart/model.h b/examples/declarative/canvas/stockchart/model.h deleted file mode 100644 index 95e6f4891c..0000000000 --- a/examples/declarative/canvas/stockchart/model.h +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -class StockPrice : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate date READ date) - Q_PROPERTY(qreal openPrice READ openPrice) - Q_PROPERTY(qreal closePrice READ closePrice) - Q_PROPERTY(qreal highPrice READ highPrice) - Q_PROPERTY(qreal lowPrice READ lowPrice) - Q_PROPERTY(qint32 volume READ volume) - Q_PROPERTY(qreal adjustedPrice READ adjustedPrice) -public: - - StockPrice(QObject *parent = 0) - : QObject(parent) - , _openPrice(-1) - , _closePrice(-1) - , _highPrice(-1) - , _lowPrice(-1) - , _volume(-1) - , _adjustedPrice(-1) - { - } - QDate date() const {return _date;} - qreal openPrice() const {return _openPrice; } - qreal closePrice() const {return _closePrice;} - qreal highPrice() const {return _highPrice;} - qreal lowPrice() const{return _lowPrice;} - qreal adjustedPrice() const{return _adjustedPrice;} - qint32 volume() const{return _volume;} - - void setDate(const QDate& date){_date = date;} - void setOpenPrice(qreal price){_openPrice = price;} - void setClosePrice(qreal price){_closePrice = price;} - void setHighPrice(qreal price){_highPrice = price;} - void setLowPrice(qreal price){_lowPrice = price;} - void setAdjustedPrice(qreal price) {_adjustedPrice = price;} - void setVolume(qint32 volume) {_volume = volume;} - -private: - QDate _date; - qreal _openPrice; - qreal _closePrice; - qreal _highPrice; - qreal _lowPrice; - qint32 _volume; - qreal _adjustedPrice; -}; - -class QNetworkReply; -class QNetworkAccessManager; -class StockModel : public QAbstractListModel -{ - Q_OBJECT - - Q_PROPERTY(QString stockName READ stockName WRITE setStockName NOTIFY stockNameChanged) - Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate NOTIFY startDateChanged) - Q_PROPERTY(QDate endDate READ endDate WRITE setEndDate NOTIFY endDateChanged) - Q_PROPERTY(StockDataCycle dataCycle READ dataCycle WRITE setDataCycle NOTIFY dataCycleChanged) - - Q_ENUMS(StockDataCycle) -public: - enum StockDataCycle { - Daily, - Weekly, - Monthly, - Dividend - }; - - enum StockModelRoles { - DateRole = Qt::UserRole + 1, - SectionRole, - OpenPriceRole, - ClosePriceRole, - HighPriceRole, - LowPriceRole, - VolumeRole, - AdjustedPriceRole - }; - - StockModel(QObject *parent = 0); - - QString stockName() const; - void setStockName(const QString& name); - - QDate startDate() const; - void setStartDate(const QDate& date); - - QDate endDate() const; - void setEndDate(const QDate& date); - - StockDataCycle dataCycle() const; - void setDataCycle(StockDataCycle cycle); - - int rowCount(const QModelIndex & parent = QModelIndex()) const; - - QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; - -signals: - void stockNameChanged(); - void startDateChanged(); - void endDateChanged(); - void dataCycleChanged(); - void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); - -public slots: - void requestData(); - StockPrice* stockPriceAtIndex(int idx) const; -private slots: - void doRequest(); - void update(QNetworkReply* reply); -private: - QString dataCycleString() const; - QList _prices; - QString _stockName; - QDate _startDate; - QDate _endDate; - StockDataCycle _dataCycle; - QNetworkAccessManager* _manager; - bool _updating; -}; - - - - diff --git a/examples/declarative/canvas/stockchart/plugin.cpp b/examples/declarative/canvas/stockchart/plugin.cpp deleted file mode 100644 index af64af4da8..0000000000 --- a/examples/declarative/canvas/stockchart/plugin.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include "model.h" - -class QStockChartExampleQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample")); - qmlRegisterType(uri, 1, 0, "StockModel"); - qmlRegisterType(uri, 1, 0, "StockPrice"); - } -}; - -#include "plugin.moc" - -Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin); diff --git a/examples/declarative/canvas/stockchart/stock.qml b/examples/declarative/canvas/stockchart/stock.qml deleted file mode 100644 index 1c95fde2ce..0000000000 --- a/examples/declarative/canvas/stockchart/stock.qml +++ /dev/null @@ -1,726 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import com.nokia.StockChartExample 1.0 -import "../contents" - -Rectangle { - id:container - width: 360; height: 600 - color: "#343434"; - Image { source: "contents/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 1 } - - - TitleBar { - id: titleBar - width: parent.width - anchors.top : container.top - height: 40 - opacity: 0.9 - } - - StockModel { - id:stockModel - dataCycle: StockModel.Daily - function dataCycleName() { - if (dataCycle === StockModel.Weekly) - return "Weekly"; - else if (dataCycle === StockModel.Monthly) - return "Monthly"; - return "Daily"; - } - - onDataChanged: { - if (view.viewType == "chart") { - canvas.requestPaint(); - } - } - onDownloadProgress: { - if (bytesReceived == bytesTotal && bytesTotal != -1) { - progress.opacity = 0; - } else { - progress.opacity = 0.8; - progress.text = "downloading " + stockModel.dataCycleName() + " data ..."+ Math.round(bytesReceived/1000) + " KB"; - } - } - - property string description:""; - } - - Stocks {id:stocks} - - Rectangle { - id: header - width: parent.width - height: 20 - color: "steelblue" - opacity: 0 - Row { - spacing: 2 - Text { - id:t - font.pointSize:15 - horizontalAlignment:Text.AlignHCenter - font.bold: true - font.underline:true - } - Rectangle { - height:20 - width:50 - Text {text:"Stock list"; font.pointSize:15; font.bold: true} - } - } - } - - ListView { - id:stockList - width: parent.width - anchors.bottom: container.bottom - anchors.top : titleBar.bottom - focus: true - keyNavigationWraps: true - spacing:1 - opacity: 1 - model: stocks - - Component.onCompleted: opacity = 0.9; - onOpacityChanged: { - titleBar.title = "Top 100 NASDAQ stocks" - } - - - delegate : Rectangle { - height: 30 - width: view.width - color: { - if (ListView.isCurrentItem) - return focus ? "lightyellow" : "pink"; - return index % 2 == 0 ? "lightblue" : "lightsteelblue" - } - Text { - font.pointSize:20 - text: index + ". " + stockId + " \t(" + name + ")"; - } - MouseArea { - anchors.fill: parent; - onDoubleClicked: { - stockList.opacity = 0; - stockModel.stockName = stockId; - stockModel.description = "NASDAQ:" + stockId + " (" + name + ")"; - view.opacity = 1; - view.viewType = "chart"; - canvas.opacity = 0.7; - } - onClicked: stockList.currentIndex = index - }//mousearea - }//delegate - } - - ListView { - id:view - width: container.width - height: container.height - 50 - anchors.bottom: container.bottom - focus: true - keyNavigationWraps: true - - spacing:1 - opacity: 0 - model: stockModel - highlightFollowsCurrentItem: false - highlightRangeMode: ListView.StrictlyEnforceRange - preferredHighlightBegin:50 - preferredHighlightEnd : height - 50 - highlight: listHighlight - - //header : Text {} - delegate: listDelegate - snapMode: ListView.SnapToItem - - property string viewType : "list" - property int topIndex:indexAt(0,contentY); - property int bottomIndex:indexAt(0, contentY+height); - - onCountChanged: { - - titleBar.title = stockModel.description + " " + Qt.formatDate(stockModel.startDate, "yyyy-MM-dd") + " - " + - Qt.formatDate(stockModel.endDate, "yyyy-MM-dd") + " " + stockModel.dataCycleName() + - " records:" + view.count; - - } - - Component { - id: listDelegate - Rectangle { - height: 20 - width: view.width - border.color: "lightsteelblue" - border.width: 1 - color: { - if (ListView.isCurrentItem) - return focus ? "lightyellow" : "pink"; - - return index % 2 == 0 ? "lightblue" : "lightsteelblue" - } - Text { - font.pointSize:13 - text: index + ". " + Qt.formatDate(date, "yyyy-MM-dd") - + "\t " + Math.round(openPrice*100)/100 - + "\t " + Math.round(highPrice*100)/100 - + "\t " + Math.round(lowPrice*100)/100 - + "\t " + Math.round(closePrice*100)/100 - + "\t " + volume + "\t " - + Math.round(adjustedPrice*100)/100; - } - MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index} - } - } - - Component { - id: chartDelegate - Rectangle { - height: 20 - width: view.width/view.count * canvas.scaleX - border.color: "lightsteelblue" - border.width: 1 - color: { - if (ListView.isCurrentItem) - return focus ? "lightyellow" : "pink"; - - return index % 2 == 0 ? "lightblue" : "lightsteelblue" - } - - Text { - anchors.bottom: parent.bottom - font.pointSize: { - if (parent.width <= 4) - return 1; - if (parent.width <= 50) - return parent.width/4; - return 15; - } - horizontalAlignment:Text.AlignHCenter - verticalAlignment:Text.AlignBottom - text:font.pointSize > 1 ? Qt.formatDate(date, "d/M/yy") : "" - } - MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index} - } - } - - Component { - id:chartHighlight - Rectangle { radius: 5; width:40; height: 20; color: "lightsteelblue" } - } - - Component { - id:listHighlight - Rectangle { radius: 5; width:container.width; height: 20; color: "lightsteelblue" } - } - - - - - onViewTypeChanged : { - if (viewType == "list") { - view.orientation = ListView.Vertical; - view.delegate = listDelegate; -// view.section.property = "year"; -// view.section.criteria = ViewSection.FullString; -// view.section.delegate = sectionHeading; - view.highlight = listHighlight; - view.opacity = 1; - canvas.opacity = 0; - // comment.opacity = 0; - - } else if (viewType == "chart") { - view.orientation = ListView.Horizontal; - view.delegate = chartDelegate; - //comment.opacity = 0.6; - - view.opacity = 1; - view.height = 30 - - canvas.opacity = 0.7; - canvas.requestPaint(); - } else { - viewType = "list"; - } - } - - - onCurrentIndexChanged: { - //header.updateCurrent(stockModel.stockPriceAtIndex(view.currentIndex)); - if (viewType == "chart") { - canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX); - canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX); - - canvas.requestPaint(); - } - } - onContentYChanged: { // keep "current" item visible - topIndex = indexAt(0,contentY); - bottomIndex = indexAt(0, contentY+height); - - if (topIndex != -1 && currentIndex <= topIndex) - currentIndex = topIndex+1; - else if (bottomIndex != -1 && currentIndex >= bottomIndex) - currentIndex = bottomIndex-1; - if (viewType == "chart") - canvas.requestPaint(); - } - - onContentXChanged: { // keep "current" item visible - topIndex = indexAt(contentX,0); - bottomIndex = indexAt(contentX+width, 0); - - if (topIndex != -1 && currentIndex <= topIndex) - currentIndex = topIndex+1; - else if (bottomIndex != -1 && currentIndex >= bottomIndex) - currentIndex = bottomIndex-1; - if (viewType == "chart") - canvas.requestPaint(); - } - - MouseArea { - anchors.fill: parent - onDoubleClicked: { - if (view.viewType == "list") - view.viewType = "chart"; - else - view.viewType = "list"; - } - } - } - - - - Canvas { - id:canvas - anchors.top : titleBar.bottom - anchors.bottom : view.top - width:container.width; - opacity:0 - renderTarget: Canvas.Image - renderStrategy: Canvas.Immediate - property bool running:false - property int frames:first - property int mouseX:0; - property int mouseY:0; - property int mousePressedX:0; - property int mousePressedY:0; - property int movedY:0 - property real scaleX:1.0; - property real scaleY:1.0; - property int first:0; - property int last:view.count - 1; - - onOpacityChanged: { - if (opacity > 0) - requestPaint(); - } - Text { - id:comment - x:100 - y:50 - font.pointSize: 20 - color:"white" - opacity: 0.7 - focus:false - text: stockModel.description - function updateCurrent(price) - { - if (price !== undefined) { - text =stockModel.description + "\n" - + Qt.formatDate(price.date, "yyyy-MM-dd") + " OPEN:" - + Math.round(price.openPrice*100)/100 + " HIGH:" - + Math.round(price.highPrice*100)/100 + " LOW:" - + Math.round(price.lowPrice*100)/100 + " CLOSE:" - + Math.round(price.closePrice*100)/100 + " VOLUME:" - + price.volume; - } - } - } - - Text { - id:priceAxis - x:25 - y:25 - font.pointSize: 15 - color:"yellow" - opacity: 0.7 - focus: false - } - Text { - id:volumeAxis - x:canvas.width - 200 - y:25 - font.pointSize: 15 - color:"yellow" - opacity: 0.7 - } - - Rectangle { - id:progress - x:canvas.width/2 - 100 - y:canvas.height/2 - width:childrenRect.width - height: childrenRect.height - opacity: 0 - color:"white" - property string text; - Text { - text:parent.text - font.pointSize: 20 - } - } - - Button { - id:runButton - text:"Run this chart" - y:0 - x:canvas.width/2 - 50 - opacity: 0.5 - onClicked: { - if (canvas.running) { - canvas.running = false; - canvas.frames = canvas.first; - canvas.requestPaint(); - text = "Run this chart"; - comment.text = stockModel.description; - } else { - text = " Stop running "; - canvas.runChart(); - } - } - } - Button { - id:returnButton - text:"Stocks" - y:0 - anchors.left : runButton.right - anchors.leftMargin : 20 - opacity: 0.5 - onClicked: { - stockList.opacity = 1; - canvas.opacity = 0; - } - } - PinchArea { - anchors.fill: parent - onPinchUpdated : { - var current = pinch.center; - var scale = pinch.scale; - console.log("center:" + pinch.center + " scale:" + pinch.scale); - //canvas.requestPaint(); - } - } - - MouseArea { - anchors.fill: parent - - onDoubleClicked: { - if (stockModel.dataCycle == StockModel.Daily) - stockModel.dataCycle = StockModel.Weekly; - else if (stockModel.dataCycle == StockModel.Weekly) - stockModel.dataCycle = StockModel.Monthly; - else - stockModel.dataCycle = StockModel.Daily; - } - - onPositionChanged: { - if (mouse.modifiers & Qt.ControlModifier) { - if (canvas.mouseX == 0 && canvas.mouseY == 0) { - canvas.mouseX = mouse.x; - canvas.mouseY = mouse.y; - } - } else{ - var w = (view.width/view.count)*canvas.scaleX; - - //canvas.movedY += Math.round((canvas.mousePressedY - mouse.y)/2); - - var movedX = Math.round((canvas.mousePressedX - mouse.x)/w); - if (movedX != 0 || canvas.movedY != 0) { - if (canvas.first + movedX >= 0 && canvas.last + movedX < view.count) { - canvas.first += movedX; - canvas.last += movedX; - } - canvas.requestPaint(); - } - } - } - - onPressed: { - canvas.mousePressedX = mouse.x; - canvas.mousePressedY = mouse.y; - } - - onReleased : { - if (mouse.modifiers & Qt.ControlModifier) { - var sx = mouse.x - canvas.mouseX; - var sy = canvas.mouseY - mouse.y; - - if (Math.abs(sx) < 50) sx = 0; - if (Math.abs(sy) < 50) sy = 0; - - if (sx > 0) - canvas.scaleX *= sx/100 +1; - else - canvas.scaleX *= 1/(-sx/100 + 1); - - if (sy > 0) - canvas.scaleY *= sy/100 +1; - else - canvas.scaleY *= 1/(-sy/100 + 1); - - if (canvas.scaleX < 1) - canvas.scaleX = 1; - - //console.log("scaleX:" + canvas.scaleX + ", scaleY:" + canvas.scaleY); - - canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX); - canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX); - - canvas.mouseX = 0; - canvas.mouseY = 0; - canvas.mousePressedX = 0; - canvas.mousePressedY = 0; - canvas.requestPaint(); - } - } - } - - function runChart() { - canvas.running = true; - requestPaint(); - } - - function showPriceAt(x) { - var w = (view.width/view.count)*canvas.scaleX; - //header.updateCurrent(stockModel.stockPriceAtIndex(canvas.first + Math.round(x/w))); - //console.log("x:" + x + " w:" + w + " index:" + (canvas.first + Math.round(x/w))); - } - - function drawPrice(ctx, from, to, color, price, points, highest) - { - ctx.globalAlpha = 0.7; - ctx.strokeStyle = color; - ctx.lineWidth = 1; - ctx.beginPath(); - - //price x axis - priceAxis.text = "price:" + Math.round(highest); - ctx.font = "bold 12px sans-serif"; - - ctx.strokeText("price", 25, 25); - for (var j = 1; j < 30; j++) { - var val = (highest * j) / 30; - val = canvas.height * (1 - val/highest); - ctx.beginPath(); - - ctx.moveTo(10, val); - if (j % 5) - ctx.lineTo(15, val); - else - ctx.lineTo(20, val); - ctx.stroke(); - } - - ctx.beginPath(); - ctx.moveTo(10, 0); - ctx.lineTo(10, canvas.height); - ctx.stroke(); - - - var w = canvas.width/points.length; - var end = canvas.running? canvas.frames - canvas.first :points.length; - for (var i = 0; i < end; i++) { - var x = points[i].x; - var y = points[i][price]; - y += canvas.movedY; - - y = canvas.height * (1 - y/highest); - if (i == 0) { - ctx.moveTo(x+w/2, y); - } else { - ctx.lineTo(x+w/2, y); - } - } - ctx.stroke(); - } - - function drawKLine(ctx, from, to, points, highest) - { - ctx.globalAlpha = 0.4; - ctx.lineWidth = 2; - var end = canvas.running? canvas.frames - canvas.first :points.length; - for (var i = 0; i < end; i++) { - var x = points[i].x; - var open = canvas.height * (1 - points[i].open/highest) - canvas.movedY; - var close = canvas.height * (1 - points[i].close/highest) - canvas.movedY; - var high = canvas.height * (1 - points[i].high/highest) - canvas.movedY; - var low = canvas.height * (1 - points[i].low/highest) - canvas.movedY; - - var top, bottom; - if (close <= open) { - ctx.fillStyle = Qt.rgba(1, 0, 0, 1); - ctx.strokeStyle = Qt.rgba(1, 0, 0, 1); - top = close; - bottom = open; - } else { - ctx.fillStyle = Qt.rgba(0, 1, 0, 1); - ctx.strokeStyle = Qt.rgba(0, 1, 0, 1); - top = open; - bottom = close; - } - - var w1, w2; - w1 = canvas.width/points.length; - w2 = w1 > 10 ? w1/2 : w1; - - ctx.fillRect(x + (w1 - w2)/2, top, w2, bottom - top); - ctx.beginPath(); - ctx.moveTo(x+w1/2, high); - ctx.lineTo(x+w1/2, low); - ctx.stroke(); - } - ctx.globalAlpha = 1; - - } - - function drawVolume(ctx, from, to, color, price, points, highest) - { - ctx.fillStyle = color; - ctx.globalAlpha = 0.6; - ctx.strokeStyle = Qt.rgba(0.8, 0.8, 0.8, 1); - ctx.lineWidth = 1; - - //volume x axis - volumeAxis.text = "volume:" + Math.round(highest/(1000*100)) + "M"; - for (var j = 1; j < 30; j++) { - var val = (highest * j) / 30; - val = canvas.height * (1 - val/highest); - ctx.beginPath(); - if (j % 5) - ctx.moveTo(canvas.width - 15, val); - else - ctx.moveTo(canvas.width - 20, val); - ctx.lineTo(canvas.width - 10, val); - ctx.stroke(); - } - - ctx.beginPath(); - ctx.moveTo(canvas.width - 10, 0); - ctx.lineTo(canvas.width - 10, canvas.height); - ctx.stroke(); - - var end = canvas.running? canvas.frames - canvas.first :points.length; - for (var i = 0; i < end; i++) { - var x = points[i].x; - var y = points[i][price]; - y = canvas.height * (1 - y/highest); - ctx.fillRect(x, y, canvas.width/points.length, canvas.height - y); - } - } -/* - onPainted : { - if (canvas.running) { - if (frames >= last) { - canvas.running = false; - canvas.frames = first; - runButton.text = "Run this chart"; - comment.text = stockModel.description; - requestPaint(); - } else { - frames += Math.round(view.count / 100); - if (frames > last) frames = last; - var price = stockModel.stockPriceAtIndex(frames); - if (price) { - comment.updateCurrent(price); - } - - requestPaint(); - } - } - } -*/ - onPaint: { - if (view.currentIndex <= 0) - first = 0; - if (last >= view.count) - last = view.count - 1; - - //console.log("painting... first:" + first + ", last:" + last + " current:" + view.currentIndex); - var ctx = canvas.getContext("2d"); - ctx.save(); - - ctx.globalCompositeOperation = "source-over"; - ctx.lineWidth = 1; - ctx.lineJoin = "round"; - ctx.fillStyle = "rgba(0,0,0,0)"; - - ctx.fillRect(0, 0, canvas.width, canvas.height); - - - - var highestPrice = 500/canvas.scaleY; - var highestValume = 600 * 1000 * 1000/canvas.scaleY; - var points = []; - for (var i = 0; i <= last - first; i++) { - var price = stockModel.stockPriceAtIndex(i + first); - points.push({ - x: i*canvas.width/(last-first+1), - open: price.openPrice, - close: price.closePrice, - high:price.highPrice, - low:price.lowPrice, - volume:price.volume - }); - } - - drawPrice(ctx, first, last, Qt.rgba(1, 0, 0, 1),"high", points, highestPrice); - drawPrice(ctx, first, last, Qt.rgba(0, 1, 0, 1),"low", points, highestPrice); - drawPrice(ctx, first, last, Qt.rgba(0, 0, 1, 1),"open", points, highestPrice); - drawPrice(ctx, first, last, Qt.rgba(0.5, 0.5, 0.5, 1),"close", points, highestPrice); - drawVolume(ctx, first, last, Qt.rgba(0.3, 0.5, 0.7, 1),"volume", points, highestValume); - drawKLine(ctx, first, last, points, highestPrice); - ctx.restore(); - } - } -} diff --git a/examples/declarative/canvas/stockchart/stockchart.pro b/examples/declarative/canvas/stockchart/stockchart.pro deleted file mode 100644 index 4006b5dccf..0000000000 --- a/examples/declarative/canvas/stockchart/stockchart.pro +++ /dev/null @@ -1,20 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative network - -DESTDIR = com/nokia/StockChartExample -TARGET = qmlstockchartexampleplugin - -SOURCES += model.cpp plugin.cpp -HEADERS += model.h -qdeclarativesources.files += \ - com/nokia/StockChartExample/qmldir \ - stock.qml - -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample - -sources.files += stockchart.pro model.h model.cpp plugin.cpp README -sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins -target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample - -INSTALLS += qdeclarativesources sources target diff --git a/examples/declarative/canvas/tiger/tiger.js b/examples/declarative/canvas/tiger/tiger.js deleted file mode 100644 index 4be0d26c9d..0000000000 --- a/examples/declarative/canvas/tiger/tiger.js +++ /dev/null @@ -1,721 +0,0 @@ -var tiger = [ - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-122.304 84.285C-122.304 84.285 -122.203 86.179 -123.027 86.16C-123.851 86.141 -140.305 38.066 -160.833 40.309C-160.833 40.309 -143.05 32.956 -122.304 84.285z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-118.774 81.262C-118.774 81.262 -119.323 83.078 -120.092 82.779C-120.86 82.481 -119.977 31.675 -140.043 26.801C-140.043 26.801 -120.82 25.937 -118.774 81.262z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-91.284 123.59C-91.284 123.59 -89.648 124.55 -90.118 125.227C-90.589 125.904 -139.763 113.102 -149.218 131.459C-149.218 131.459 -145.539 112.572 -91.284 123.59z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-94.093 133.801C-94.093 133.801 -92.237 134.197 -92.471 134.988C-92.704 135.779 -143.407 139.121 -146.597 159.522C-146.597 159.522 -149.055 140.437 -94.093 133.801z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-98.304 128.276C-98.304 128.276 -96.526 128.939 -96.872 129.687C-97.218 130.435 -147.866 126.346 -153.998 146.064C-153.998 146.064 -153.646 126.825 -98.304 128.276z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-109.009 110.072C-109.009 110.072 -107.701 111.446 -108.34 111.967C-108.979 112.488 -152.722 86.634 -166.869 101.676C-166.869 101.676 -158.128 84.533 -109.009 110.072z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-116.554 114.263C-116.554 114.263 -115.098 115.48 -115.674 116.071C-116.25 116.661 -162.638 95.922 -174.992 112.469C-174.992 112.469 -168.247 94.447 -116.554 114.263z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-119.154 118.335C-119.154 118.335 -117.546 119.343 -118.036 120.006C-118.526 120.669 -167.308 106.446 -177.291 124.522C-177.291 124.522 -173.066 105.749 -119.154 118.335z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-108.42 118.949C-108.42 118.949 -107.298 120.48 -107.999 120.915C-108.7 121.35 -148.769 90.102 -164.727 103.207C-164.727 103.207 -153.862 87.326 -108.42 118.949z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-128.2 90C-128.2 90 -127.6 91.8 -128.4 92C-129.2 92.2 -157.8 50.2 -177.001 57.8C-177.001 57.8 -161.8 46 -128.2 90z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-127.505 96.979C-127.505 96.979 -126.53 98.608 -127.269 98.975C-128.007 99.343 -164.992 64.499 -182.101 76.061C-182.101 76.061 -169.804 61.261 -127.505 96.979z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.172, - "path":"M-127.62 101.349C-127.62 101.349 -126.498 102.88 -127.199 103.315C-127.9 103.749 -167.969 72.502 -183.927 85.607C-183.927 85.607 -173.062 69.726 -127.62 101.349z"} - , - {"fill": "#ffffff", "stroke":"#000000", - "path":"M-129.83 103.065C-129.327 109.113 -128.339 115.682 -126.6 118.801C-126.6 118.801 -130.2 131.201 -121.4 144.401C-121.4 144.401 -121.8 151.601 -120.2 154.801C-120.2 154.801 -116.2 163.201 -111.4 164.001C-107.516 164.648 -98.793 167.717 -88.932 169.121C-88.932 169.121 -71.8 183.201 -75 196.001C-75 196.001 -75.4 212.401 -79 214.001C-79 214.001 -67.4 202.801 -77 219.601L-81.4 238.401C-81.4 238.401 -55.8 216.801 -71.4 235.201L-81.4 261.201C-81.4 261.201 -61.8 242.801 -69 251.201L-72.2 260.001C-72.2 260.001 -29 232.801 -59.8 262.401C-59.8 262.401 -51.8 258.801 -47.4 261.601C-47.4 261.601 -40.6 260.401 -41.4 262.001C-41.4 262.001 -62.2 272.401 -65.8 290.801C-65.8 290.801 -57.4 280.801 -60.6 291.601L-60.2 303.201C-60.2 303.201 -56.2 281.601 -56.6 319.201C-56.6 319.201 -37.4 301.201 -49 322.001L-49 338.801C-49 338.801 -33.8 322.401 -40.2 335.201C-40.2 335.201 -30.2 326.401 -34.2 341.601C-34.2 341.601 -35 352.001 -30.6 340.801C-30.6 340.801 -14.6 310.201 -20.6 336.401C-20.6 336.401 -21.4 355.601 -16.6 340.801C-16.6 340.801 -16.2 351.201 -7 358.401C-7 358.401 -8.2 307.601 4.6 343.601L8.6 360.001C8.6 360.001 11.4 350.801 11 345.601C11 345.601 25.8 329.201 19 353.601C19 353.601 34.2 330.801 31 344.001C31 344.001 23.4 360.001 25 364.801C25 364.801 41.8 330.001 43 328.401C43 328.401 41 370.802 51.8 334.801C51.8 334.801 57.4 346.801 54.6 351.201C54.6 351.201 62.6 343.201 61.8 340.001C61.8 340.001 66.4 331.801 69.2 345.401C69.2 345.401 71 354.801 72.6 351.601C72.6 351.601 76.6 375.602 77.8 352.801C77.8 352.801 79.4 339.201 72.2 327.601C72.2 327.601 73 324.401 70.2 320.401C70.2 320.401 83.8 342.001 76.6 313.201C76.6 313.201 87.801 321.201 89.001 321.201C89.001 321.201 75.4 298.001 84.2 302.801C84.2 302.801 79 292.401 97.001 304.401C97.001 304.401 81 288.401 98.601 298.001C98.601 298.001 106.601 304.401 99.001 294.401C99.001 294.401 84.6 278.401 106.601 296.401C106.601 296.401 118.201 312.801 119.001 315.601C119.001 315.601 109.001 286.401 104.601 283.601C104.601 283.601 113.001 247.201 154.201 262.801C154.201 262.801 161.001 280.001 165.401 261.601C165.401 261.601 178.201 255.201 189.401 282.801C189.401 282.801 193.401 269.201 192.601 266.401C192.601 266.401 199.401 267.601 198.601 266.401C198.601 266.401 211.801 270.801 213.001 270.001C213.001 270.001 219.801 276.801 220.201 273.201C220.201 273.201 229.401 276.001 227.401 272.401C227.401 272.401 236.201 288.001 236.601 291.601L239.001 277.601L241.001 280.401C241.001 280.401 242.601 272.801 241.801 271.601C241.001 270.401 261.801 278.401 266.601 299.201L268.601 307.601C268.601 307.601 274.601 292.801 273.001 288.801C273.001 288.801 278.201 289.601 278.601 294.001C278.601 294.001 282.601 270.801 277.801 264.801C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 156.001C307.401 156.001 307.001 154.401 303.801 150.401C303.801 150.401 282.201 95.6 302.601 117.601C302.601 117.601 314.451 131.151 308.051 108.351C308.051 108.351 298.94 84.341 299.717 80.045L-129.83 103.065z"} - , - {"fill": "#cc7226", "stroke":"#000000", - "path":"M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 -53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 -119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 -139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 -129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 -103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 -51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 -42 -69.4 -39.2C-69.4 -39.2 -77 -25.2 -75.8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 -6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 -97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245z"} - , - {"fill": "#cc7226", - "path":"M-115.6 102.6C-140.6 63.2 -126.2 119.601 -126.2 119.601C-117.4 154.001 12.2 116.401 12.2 116.401C12.2 116.401 181.001 86 192.201 82C203.401 78 298.601 84.4 298.601 84.4L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 46.8C177.801 47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 60.4C23.4 49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 99.6 -39 93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91L-115.6 102.6z"} - , - {"fill": "#e87f3a", - "path":"M133.51 25.346C127.11 26.146 101.743 2.407 116.71 34.146C133.31 69.346 58.31 73.346 41.51 62.146C24.709 50.946 48.71 80.546 48.71 80.546C67.11 100.546 32.709 83.746 32.709 83.746C-1.691 70.946 -25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 88.546 -45.87 72.012 -77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 64.346 -125.546 122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 87.746 193.51 83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 196.71 42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346z"} - , - {"fill": "#ea8c4d", - "path":"M134.819 27.091C128.419 27.891 103.685 3.862 118.019 35.891C134.219 72.092 59.619 75.092 42.819 63.892C26.019 52.692 50.019 82.292 50.019 82.292C68.419 102.292 34.019 85.492 34.019 85.492C-0.381 72.692 -24.382 98.292 -27.582 99.092C-30.782 99.892 -35.582 103.092 -36.382 96.692C-37.182 90.292 -44.43 73.925 -76.382 99.892C-98.855 117.983 -112.036 97.074 -112.036 97.074L-115.636 105.692C-139.436 66.692 -124.891 125.71 -124.891 125.71C-116.091 160.11 14.819 119.892 14.819 119.892C14.819 119.892 183.619 89.492 194.819 85.492C206.019 81.492 299.474 87.746 299.474 87.746L294.02 69.928C229.219 23.528 211.619 47.891 198.019 43.891C184.419 39.891 186.819 49.491 183.619 50.292C180.419 51.092 141.219 26.291 134.819 27.091z"} - , - {"fill": "#ec9961", - "path":"M136.128 28.837C129.728 29.637 104.999 5.605 119.328 37.637C136.128 75.193 60.394 76.482 44.128 65.637C27.328 54.437 51.328 84.037 51.328 84.037C69.728 104.037 35.328 87.237 35.328 87.237C0.928 74.437 -23.072 100.037 -26.272 100.837C-29.472 101.637 -34.272 104.837 -35.072 98.437C-35.872 92.037 -42.989 75.839 -75.073 101.637C-98.782 120.474 -111.655 100.11 -111.655 100.11L-115.655 107.237C-137.455 70.437 -124.236 128.765 -124.236 128.765C-115.436 163.165 16.128 121.637 16.128 121.637C16.128 121.637 184.928 91.237 196.129 87.237C207.329 83.237 299.911 89.419 299.911 89.419L294.529 71.092C229.729 24.691 212.929 49.637 199.329 45.637C185.728 41.637 188.128 51.237 184.928 52.037C181.728 52.837 142.528 28.037 136.128 28.837z"} - , - {"fill": "#eea575", - "path":"M137.438 30.583C131.037 31.383 106.814 7.129 120.637 39.383C137.438 78.583 62.237 78.583 45.437 67.383C28.637 56.183 52.637 85.783 52.637 85.783C71.037 105.783 36.637 88.983 36.637 88.983C2.237 76.183 -21.763 101.783 -24.963 102.583C-28.163 103.383 -32.963 106.583 -33.763 100.183C-34.563 93.783 -41.548 77.752 -73.763 103.383C-98.709 122.965 -111.273 103.146 -111.273 103.146L-115.673 108.783C-135.473 73.982 -123.582 131.819 -123.582 131.819C-114.782 166.22 17.437 123.383 17.437 123.383C17.437 123.383 186.238 92.983 197.438 88.983C208.638 84.983 300.347 91.092 300.347 91.092L295.038 72.255C230.238 25.855 214.238 51.383 200.638 47.383C187.038 43.383 189.438 52.983 186.238 53.783C183.038 54.583 143.838 29.783 137.438 30.583z"} - , - {"fill": "#f1b288", - "path":"M138.747 32.328C132.347 33.128 106.383 9.677 121.947 41.128C141.147 79.928 63.546 80.328 46.746 69.128C29.946 57.928 53.946 87.528 53.946 87.528C72.346 107.528 37.946 90.728 37.946 90.728C3.546 77.928 -20.454 103.528 -23.654 104.328C-26.854 105.128 -31.654 108.328 -32.454 101.928C-33.254 95.528 -40.108 79.665 -72.454 105.128C-98.636 125.456 -110.891 106.183 -110.891 106.183L-115.691 110.328C-133.691 77.128 -122.927 134.874 -122.927 134.874C-114.127 169.274 18.746 125.128 18.746 125.128C18.746 125.128 187.547 94.728 198.747 90.728C209.947 86.728 300.783 92.764 300.783 92.764L295.547 73.419C230.747 27.019 215.547 53.128 201.947 49.128C188.347 45.128 190.747 54.728 187.547 55.528C184.347 56.328 145.147 31.528 138.747 32.328z"} - , - {"fill": "#f3bf9c", - "path":"M140.056 34.073C133.655 34.873 107.313 11.613 123.255 42.873C143.656 82.874 64.855 82.074 48.055 70.874C31.255 59.674 55.255 89.274 55.255 89.274C73.655 109.274 39.255 92.474 39.255 92.474C4.855 79.674 -19.145 105.274 -22.345 106.074C-25.545 106.874 -30.345 110.074 -31.145 103.674C-31.945 97.274 -38.668 81.578 -71.145 106.874C-98.564 127.947 -110.509 109.219 -110.509 109.219L-115.709 111.874C-131.709 81.674 -122.273 137.929 -122.273 137.929C-113.473 172.329 20.055 126.874 20.055 126.874C20.055 126.874 188.856 96.474 200.056 92.474C211.256 88.474 301.22 94.437 301.22 94.437L296.056 74.583C231.256 28.183 216.856 54.874 203.256 50.874C189.656 46.873 192.056 56.474 188.856 57.274C185.656 58.074 146.456 33.273 140.056 34.073z"} - , - {"fill": "#f5ccb0", - "path":"M141.365 35.819C134.965 36.619 107.523 13.944 124.565 44.619C146.565 84.219 66.164 83.819 49.364 72.619C32.564 61.419 56.564 91.019 56.564 91.019C74.964 111.019 40.564 94.219 40.564 94.219C6.164 81.419 -17.836 107.019 -21.036 107.819C-24.236 108.619 -29.036 111.819 -29.836 105.419C-30.636 99.019 -37.227 83.492 -69.836 108.619C-98.491 130.438 -110.127 112.256 -110.127 112.256L-115.727 113.419C-130.128 85.019 -121.618 140.983 -121.618 140.983C-112.818 175.384 21.364 128.619 21.364 128.619C21.364 128.619 190.165 98.219 201.365 94.219C212.565 90.219 301.656 96.11 301.656 96.11L296.565 75.746C231.765 29.346 218.165 56.619 204.565 52.619C190.965 48.619 193.365 58.219 190.165 59.019C186.965 59.819 147.765 35.019 141.365 35.819z"} - , - {"fill": "#f8d8c4", - "path":"M142.674 37.565C136.274 38.365 108.832 15.689 125.874 46.365C147.874 85.965 67.474 85.565 50.674 74.365C33.874 63.165 57.874 92.765 57.874 92.765C76.274 112.765 41.874 95.965 41.874 95.965C7.473 83.165 -16.527 108.765 -19.727 109.565C-22.927 110.365 -27.727 113.565 -28.527 107.165C-29.327 100.765 -35.786 85.405 -68.527 110.365C-98.418 132.929 -109.745 115.293 -109.745 115.293L-115.745 114.965C-129.346 88.564 -120.963 144.038 -120.963 144.038C-112.163 178.438 22.673 130.365 22.673 130.365C22.673 130.365 191.474 99.965 202.674 95.965C213.874 91.965 302.093 97.783 302.093 97.783L297.075 76.91C232.274 30.51 219.474 58.365 205.874 54.365C192.274 50.365 194.674 59.965 191.474 60.765C188.274 61.565 149.074 36.765 142.674 37.565z"} - , - {"fill": "#fae5d7", - "path":"M143.983 39.31C137.583 40.11 110.529 17.223 127.183 48.11C149.183 88.91 68.783 87.31 51.983 76.11C35.183 64.91 59.183 94.51 59.183 94.51C77.583 114.51 43.183 97.71 43.183 97.71C8.783 84.91 -15.217 110.51 -18.417 111.31C-21.618 112.11 -26.418 115.31 -27.218 108.91C-28.018 102.51 -34.346 87.318 -67.218 112.11C-98.345 135.42 -109.363 118.329 -109.363 118.329L-115.764 116.51C-128.764 92.51 -120.309 147.093 -120.309 147.093C-111.509 181.493 23.983 132.11 23.983 132.11C23.983 132.11 192.783 101.71 203.983 97.71C215.183 93.71 302.529 99.456 302.529 99.456L297.583 78.074C232.783 31.673 220.783 60.11 207.183 56.11C193.583 52.11 195.983 61.71 192.783 62.51C189.583 63.31 150.383 38.51 143.983 39.31z"} - , - {"fill": "#fcf2eb", - "path":"M145.292 41.055C138.892 41.855 112.917 18.411 128.492 49.855C149.692 92.656 70.092 89.056 53.292 77.856C36.492 66.656 60.492 96.256 60.492 96.256C78.892 116.256 44.492 99.456 44.492 99.456C10.092 86.656 -13.908 112.256 -17.108 113.056C-20.308 113.856 -25.108 117.056 -25.908 110.656C-26.708 104.256 -32.905 89.232 -65.908 113.856C-98.273 137.911 -108.982 121.365 -108.982 121.365L-115.782 118.056C-128.582 94.856 -119.654 150.147 -119.654 150.147C-110.854 184.547 25.292 133.856 25.292 133.856C25.292 133.856 194.093 103.456 205.293 99.456C216.493 95.456 302.965 101.128 302.965 101.128L298.093 79.237C233.292 32.837 222.093 61.856 208.493 57.856C194.893 53.855 197.293 63.456 194.093 64.256C190.892 65.056 151.692 40.255 145.292 41.055z"} - , - {"fill": "#ffffff", - "path":"M-115.8 119.601C-128.6 97.6 -119 153.201 -119 153.201C-110.2 187.601 26.6 135.601 26.6 135.601C26.6 135.601 195.401 105.2 206.601 101.2C217.801 97.2 303.401 102.8 303.401 102.8L298.601 80.4C233.801 34 223.401 63.6 209.801 59.6C196.201 55.6 198.601 65.2 195.401 66C192.201 66.8 153.001 42 146.601 42.8C140.201 43.6 114.981 19.793 129.801 51.6C152.028 99.307 69.041 89.227 54.6 79.6C37.8 68.4 61.8 98 61.8 98C80.2 118.001 45.8 101.2 45.8 101.2C11.4 88.4 -12.6 114.001 -15.8 114.801C-19 115.601 -23.8 118.801 -24.6 112.401C-25.4 106 -31.465 91.144 -64.6 115.601C-98.2 140.401 -108.6 124.401 -108.6 124.401L-115.8 119.601z"} - , - {"fill": "#000000", - "path":"M-74.2 149.601C-74.2 149.601 -81.4 161.201 -60.6 174.401C-60.6 174.401 -59.2 175.801 -77.2 171.601C-77.2 171.601 -83.4 169.601 -85 159.201C-85 159.201 -89.8 154.801 -94.6 149.201C-99.4 143.601 -74.2 149.601 -74.2 149.601z"} - , - {"fill": "#cccccc", - "path":"M65.8 102C65.8 102 83.498 128.821 82.9 133.601C81.6 144.001 81.4 153.601 84.6 157.601C87.801 161.601 96.601 194.801 96.601 194.801C96.601 194.801 96.201 196.001 108.601 158.001C108.601 158.001 120.201 142.001 100.201 123.601C100.201 123.601 65 94.8 65.8 102z"} - , - {"fill": "#000000", - "path":"M-54.2 176.401C-54.2 176.401 -43 183.601 -57.4 214.801L-51 212.401C-51 212.401 -51.8 223.601 -55 226.001L-47.8 222.801C-47.8 222.801 -43 230.801 -47 235.601C-47 235.601 -30.2 243.601 -31 250.001C-31 250.001 -24.6 242.001 -28.6 235.601C-32.6 229.201 -39.8 233.201 -39 214.801L-47.8 218.001C-47.8 218.001 -42.2 209.201 -42.2 202.801L-50.2 205.201C-50.2 205.201 -34.731 178.623 -45.4 177.201C-51.4 176.401 -54.2 176.401 -54.2 176.401z"} - , - {"fill": "#cccccc", - "path":"M-21.8 193.201C-21.8 193.201 -19 188.801 -21.8 189.601C-24.6 190.401 -55.8 205.201 -61.8 214.801C-61.8 214.801 -27.4 190.401 -21.8 193.201z"} - , - {"fill": "#cccccc", - "path":"M-11.4 201.201C-11.4 201.201 -8.6 196.801 -11.4 197.601C-14.2 198.401 -45.4 213.201 -51.4 222.801C-51.4 222.801 -17 198.401 -11.4 201.201z"} - , - {"fill": "#cccccc", - "path":"M1.8 186.001C1.8 186.001 4.6 181.601 1.8 182.401C-1 183.201 -32.2 198.001 -38.2 207.601C-38.2 207.601 -3.8 183.201 1.8 186.001z"} - , - {"fill": "#cccccc", - "path":"M-21.4 229.601C-21.4 229.601 -21.4 223.601 -24.2 224.401C-27 225.201 -63 242.801 -69 252.401C-69 252.401 -27 226.801 -21.4 229.601z"} - , - {"fill": "#cccccc", - "path":"M-20.2 218.801C-20.2 218.801 -19 214.001 -21.8 214.801C-23.8 214.801 -50.2 226.401 -56.2 236.001C-56.2 236.001 -26.6 214.401 -20.2 218.801z"} - , - {"fill": "#cccccc", - "path":"M-34.6 266.401L-44.6 274.001C-44.6 274.001 -34.2 266.401 -30.6 267.601C-30.6 267.601 -37.4 278.801 -38.2 284.001C-38.2 284.001 -27.8 271.201 -22.2 271.601C-22.2 271.601 -14.6 272.001 -14.6 282.801C-14.6 282.801 -9 272.401 -5.8 272.801C-5.8 272.801 -4.6 279.201 -5.8 286.001C-5.8 286.001 -1.8 278.401 2.2 280.001C2.2 280.001 8.6 278.001 7.8 289.601C7.8 289.601 7.8 300.001 7 302.801C7 302.801 12.6 276.401 15 276.001C15 276.001 23 274.801 27.8 283.601C27.8 283.601 23.8 276.001 28.6 278.001C28.6 278.001 39.4 279.601 42.6 286.401C42.6 286.401 35.8 274.401 41.4 277.601C41.4 277.601 48.2 277.601 49.4 284.001C49.4 284.001 57.8 305.201 59.8 306.801C59.8 306.801 52.2 285.201 53.8 285.201C53.8 285.201 51.8 273.201 57 288.001C57 288.001 53.8 274.001 59.4 274.801C65 275.601 69.4 285.601 77.8 283.201C77.8 283.201 87.401 288.801 89.401 219.601L-34.6 266.401z"} - , - {"fill": "#000000", - "path":"M-29.8 173.601C-29.8 173.601 -15 167.601 25 173.601C25 173.601 32.2 174.001 39 165.201C45.8 156.401 72.6 149.201 79 151.201L88.601 157.601L89.401 158.801C89.401 158.801 101.801 169.201 102.201 176.801C102.601 184.401 87.801 232.401 78.2 248.401C68.6 264.401 59 276.801 39.8 274.401C39.8 274.401 19 270.401 -6.6 274.401C-6.6 274.401 -35.8 272.801 -38.6 264.801C-41.4 256.801 -27.4 241.601 -27.4 241.601C-27.4 241.601 -23 233.201 -24.2 218.801C-25.4 204.401 -25 176.401 -29.8 173.601z"} - , - {"fill": "#e5668c", - "path":"M-7.8 175.601C0.6 194.001 -29 259.201 -29 259.201C-31 260.801 -16.34 266.846 -6.2 264.401C4.746 261.763 45 266.001 45 266.001C68.6 250.401 81.4 206.001 81.4 206.001C81.4 206.001 91.801 182.001 74.2 178.801C56.6 175.601 -7.8 175.601 -7.8 175.601z"} - , - {"fill": "#b23259", - "path":"M-9.831 206.497C-6.505 193.707 -4.921 181.906 -7.8 175.601C-7.8 175.601 54.6 182.001 65.8 161.201C70.041 153.326 84.801 184.001 84.4 193.601C84.4 193.601 21.4 208.001 6.6 196.801L-9.831 206.497z"} - , - {"fill": "#a5264c", - "path":"M-5.4 222.801C-5.4 222.801 -3.4 230.001 -5.8 234.001C-5.8 234.001 -7.4 234.801 -8.6 235.201C-8.6 235.201 -7.4 238.801 -1.4 240.401C-1.4 240.401 0.6 244.801 3 245.201C5.4 245.601 10.2 251.201 14.2 250.001C18.2 248.801 29.4 244.801 29.4 244.801C29.4 244.801 35 241.601 43.8 245.201C43.8 245.201 46.175 244.399 46.6 240.401C47.1 235.701 50.2 232.001 52.2 230.001C54.2 228.001 63.8 215.201 62.6 214.801C61.4 214.401 -5.4 222.801 -5.4 222.801z"} - , - {"fill": "#ff727f", "stroke":"#000000", - "path":"M-9.8 174.401C-9.8 174.401 -12.6 196.801 -9.4 205.201C-6.2 213.601 -7 215.601 -7.8 219.601C-8.6 223.601 -4.2 233.601 1.4 239.601L13.4 241.201C13.4 241.201 28.6 237.601 37.8 240.401C37.8 240.401 46.794 241.744 50.2 226.801C50.2 226.801 55 220.401 62.2 217.601C69.4 214.801 76.6 173.201 72.6 165.201C68.6 157.201 54.2 152.801 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-8.2 249.201C-8.2 249.201 -9 247.201 -13.4 246.801C-13.4 246.801 -35.8 243.201 -44.2 230.801C-44.2 230.801 -51 225.201 -46.6 236.801C-46.6 236.801 -36.2 257.201 -29.4 260.001C-29.4 260.001 -13 264.001 -8.2 249.201z"} - , - {"fill": "#cc3f4c", - "path":"M71.742 185.229C72.401 177.323 74.354 168.709 72.6 165.201C66.154 152.307 49.181 157.695 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401C-9.8 174.401 -11.545 188.364 -10.705 198.376C-10.705 198.376 26.6 186.801 27.4 192.401C27.4 192.401 29 189.201 38.2 189.201C47.4 189.201 70.142 188.029 71.742 185.229z"} - , - {"stroke":"#a51926", "width":2, - "path":"M28.6 175.201C28.6 175.201 33.4 180.001 29.8 189.601C29.8 189.601 15.4 205.601 17.4 219.601"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-19.4 260.001C-19.4 260.001 -23.8 247.201 -15 254.001C-15 254.001 -10.2 256.001 -11.4 257.601C-12.6 259.201 -18.2 263.201 -19.4 260.001z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-14.36 261.201C-14.36 261.201 -17.88 250.961 -10.84 256.401C-10.84 256.401 -6.419 258.849 -7.96 259.281C-12.52 260.561 -7.96 263.121 -14.36 261.201z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-9.56 261.201C-9.56 261.201 -13.08 250.961 -6.04 256.401C-6.04 256.401 -1.665 258.711 -3.16 259.281C-6.52 260.561 -3.16 263.121 -9.56 261.201z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-2.96 261.401C-2.96 261.401 -6.48 251.161 0.56 256.601C0.56 256.601 4.943 258.933 3.441 259.481C0.48 260.561 3.441 263.321 -2.96 261.401z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M3.52 261.321C3.52 261.321 0 251.081 7.041 256.521C7.041 256.521 10.881 258.121 9.921 259.401C8.961 260.681 9.921 263.241 3.52 261.321z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M10.2 262.001C10.2 262.001 5.4 249.601 14.6 256.001C14.6 256.001 19.4 258.001 18.2 259.601C17 261.201 18.2 264.401 10.2 262.001z"} - , - {"stroke":"#a5264c", "width":2, - "path":"M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 245.201 12.6 245.201"} - , - {"stroke":"#a5264c", "width":2, - "path":"M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 238.001 47.6 233.801 52.6 230.801"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M33 237.601C33 237.601 29 226.801 26.2 239.601C23.4 252.401 20.2 256.001 18.6 258.801C18.6 258.801 18.6 264.001 27 263.601C27 263.601 37.8 263.201 38.2 260.401C38.6 257.601 37 246.001 33 237.601z"} - , - {"stroke":"#a5264c", "width":2, - "path":"M47 244.801C47 244.801 50.6 242.401 53 243.601"} - , - {"stroke":"#a5264c", "width":2, - "path":"M53.5 228.401C53.5 228.401 56.4 223.501 61.2 222.701"} - , - {"fill": "#b2b2b2", - "path":"M-25.8 265.201C-25.8 265.201 -7.8 268.401 -3.4 266.801C-3.4 266.801 5.4 266.801 -3 268.801C-3 268.801 -15.8 268.801 -23.8 267.601C-23.8 267.601 -35.4 262.001 -25.8 265.201z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-11.8 172.001C-11.8 172.001 5.8 172.001 7.8 172.801C7.8 172.801 15 203.601 11.4 211.201C11.4 211.201 10.2 214.001 7.4 208.401C7.4 208.401 -11 175.601 -14.2 173.601C-17.4 171.601 -13 172.001 -11.8 172.001z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-88.9 169.301C-88.9 169.301 -80 171.001 -67.4 173.601C-67.4 173.601 -62.6 196.001 -59.4 200.801C-56.2 205.601 -59.8 205.601 -63.4 202.801C-67 200.001 -81.8 186.001 -83.8 181.601C-85.8 177.201 -88.9 169.301 -88.9 169.301z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-67.039 173.818C-67.039 173.818 -61.239 175.366 -60.23 177.581C-59.222 179.795 -61.432 183.092 -61.432 183.092C-61.432 183.092 -62.432 186.397 -63.634 184.235C-64.836 182.072 -67.708 174.412 -67.039 173.818z"} - , - {"fill": "#000000", - "path":"M-67 173.601C-67 173.601 -63.4 178.801 -59.8 178.801C-56.2 178.801 -55.818 178.388 -53 179.001C-48.4 180.001 -48.8 178.001 -42.2 179.201C-39.56 179.681 -37 178.801 -34.2 180.001C-31.4 181.201 -28.2 180.401 -27 178.401C-25.8 176.401 -21 172.201 -21 172.201C-21 172.201 -33.8 174.001 -36.6 174.801C-36.6 174.801 -59 176.001 -67 173.601z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-22.4 173.801C-22.4 173.801 -28.85 177.301 -29.25 179.701C-29.65 182.101 -24 185.801 -24 185.801C-24 185.801 -21.25 190.401 -20.65 188.001C-20.05 185.601 -21.6 174.201 -22.4 173.801z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-59.885 179.265C-59.885 179.265 -52.878 190.453 -52.661 179.242C-52.661 179.242 -52.104 177.984 -53.864 177.962C-59.939 177.886 -58.418 173.784 -59.885 179.265z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-52.707 179.514C-52.707 179.514 -44.786 190.701 -45.422 179.421C-45.422 179.421 -45.415 179.089 -47.168 178.936C-51.915 178.522 -51.57 174.004 -52.707 179.514z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-45.494 179.522C-45.494 179.522 -37.534 190.15 -38.203 180.484C-38.203 180.484 -38.084 179.251 -39.738 178.95C-43.63 178.244 -43.841 174.995 -45.494 179.522z"} - , - {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, - "path":"M-38.618 179.602C-38.618 179.602 -30.718 191.163 -30.37 181.382C-30.37 181.382 -28.726 180.004 -30.472 179.782C-36.29 179.042 -35.492 174.588 -38.618 179.602z"} - , - {"fill": "#e5e5b2", - "path":"M-74.792 183.132L-82.45 181.601C-85.05 176.601 -87.15 170.451 -87.15 170.451C-87.15 170.451 -80.8 171.451 -68.3 174.251C-68.3 174.251 -67.424 177.569 -65.952 183.364L-74.792 183.132z"} - , - {"fill": "#e5e5b2", - "path":"M-9.724 178.47C-11.39 175.964 -12.707 174.206 -13.357 173.8C-16.37 171.917 -12.227 172.294 -11.098 172.294C-11.098 172.294 5.473 172.294 7.356 173.047C7.356 173.047 7.88 175.289 8.564 178.68C8.564 178.68 -1.524 176.67 -9.724 178.47z"} - , - {"fill": "#cc7226", - "path":"M43.88 40.321C71.601 44.281 97.121 8.641 98.881 -1.04C100.641 -10.72 90.521 -22.6 90.521 -22.6C91.841 -25.68 87.001 -39.76 81.721 -49C76.441 -58.24 60.54 -57.266 43 -58.24C27.16 -59.12 8.68 -35.8 7.36 -34.04C6.04 -32.28 12.2 6.001 13.52 11.721C14.84 17.441 12.2 43.841 12.2 43.841C46.44 34.741 16.16 36.361 43.88 40.321z"} - , - {"fill": "#ea8e51", - "path":"M8.088 -33.392C6.792 -31.664 12.84 5.921 14.136 11.537C15.432 17.153 12.84 43.073 12.84 43.073C45.512 34.193 16.728 35.729 43.944 39.617C71.161 43.505 96.217 8.513 97.945 -0.992C99.673 -10.496 89.737 -22.16 89.737 -22.16C91.033 -25.184 86.281 -39.008 81.097 -48.08C75.913 -57.152 60.302 -56.195 43.08 -57.152C27.528 -58.016 9.384 -35.12 8.088 -33.392z"} - , - {"fill": "#efaa7c", - "path":"M8.816 -32.744C7.544 -31.048 13.48 5.841 14.752 11.353C16.024 16.865 13.48 42.305 13.48 42.305C44.884 33.145 17.296 35.097 44.008 38.913C70.721 42.729 95.313 8.385 97.009 -0.944C98.705 -10.272 88.953 -21.72 88.953 -21.72C90.225 -24.688 85.561 -38.256 80.473 -47.16C75.385 -56.064 60.063 -55.125 43.16 -56.064C27.896 -56.912 10.088 -34.44 8.816 -32.744z"} - , - {"fill": "#f4c6a8", - "path":"M9.544 -32.096C8.296 -30.432 14.12 5.761 15.368 11.169C16.616 16.577 14.12 41.537 14.12 41.537C43.556 32.497 17.864 34.465 44.072 38.209C70.281 41.953 94.409 8.257 96.073 -0.895C97.737 -10.048 88.169 -21.28 88.169 -21.28C89.417 -24.192 84.841 -37.504 79.849 -46.24C74.857 -54.976 59.824 -54.055 43.24 -54.976C28.264 -55.808 10.792 -33.76 9.544 -32.096z"} - , - {"fill": "#f9e2d3", - "path":"M10.272 -31.448C9.048 -29.816 14.76 5.681 15.984 10.985C17.208 16.289 14.76 40.769 14.76 40.769C42.628 31.849 18.432 33.833 44.136 37.505C69.841 41.177 93.505 8.129 95.137 -0.848C96.769 -9.824 87.385 -20.84 87.385 -20.84C88.609 -23.696 84.121 -36.752 79.225 -45.32C74.329 -53.888 59.585 -52.985 43.32 -53.888C28.632 -54.704 11.496 -33.08 10.272 -31.448z"} - , - {"fill": "#ffffff", - "path":"M44.2 36.8C69.4 40.4 92.601 8 94.201 -0.8C95.801 -9.6 86.601 -20.4 86.601 -20.4C87.801 -23.2 83.4 -36 78.6 -44.4C73.8 -52.8 59.346 -51.914 43.4 -52.8C29 -53.6 12.2 -32.4 11 -30.8C9.8 -29.2 15.4 5.6 16.6 10.8C17.8 16 15.4 40 15.4 40C40.9 31.4 19 33.2 44.2 36.8z"} - , - {"fill": "#cccccc", - "path":"M90.601 2.8C90.601 2.8 62.8 10.4 51.2 8.8C51.2 8.8 35.4 2.2 26.6 24C26.6 24 23 31.2 21 33.2C19 35.2 90.601 2.8 90.601 2.8z"} - , - {"fill": "#000000", - "path":"M94.401 0.6C94.401 0.6 65.4 12.8 55.4 12.4C55.4 12.4 39 7.8 30.6 22.4C30.6 22.4 22.2 31.6 19 33.2C19 33.2 18.6 34.8 25 30.8L35.4 36C35.4 36 50.2 45.6 59.8 29.6C59.8 29.6 63.8 18.4 63.8 16.4C63.8 14.4 85 8.8 86.601 8.4C88.201 8 94.801 3.8 94.401 0.6z"} - , - {"fill": "#99cc32", - "path":"M47 36.514C40.128 36.514 31.755 32.649 31.755 26.4C31.755 20.152 40.128 13.887 47 13.887C53.874 13.887 59.446 18.952 59.446 25.2C59.446 31.449 53.874 36.514 47 36.514z"} - , - {"fill": "#659900", - "path":"M43.377 19.83C38.531 20.552 33.442 22.055 33.514 21.839C35.054 17.22 41.415 13.887 47 13.887C51.296 13.887 55.084 15.865 57.32 18.875C57.32 18.875 52.004 18.545 43.377 19.83z"} - , - {"fill": "#ffffff", - "path":"M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6z"} - , - {"fill": "#000000", - "path":"M45.4 27.726C42.901 27.726 40.875 25.7 40.875 23.2C40.875 20.701 42.901 18.675 45.4 18.675C47.9 18.675 49.926 20.701 49.926 23.2C49.926 25.7 47.9 27.726 45.4 27.726z"} - , - {"fill": "#cc7226", - "path":"M-58.6 14.4C-58.6 14.4 -61.8 -6.8 -59.4 -11.2C-59.4 -11.2 -48.6 -21.2 -49 -24.8C-49 -24.8 -49.4 -42.8 -50.6 -43.6C-51.8 -44.4 -59.4 -50.4 -65.4 -44C-65.4 -44 -75.8 -26 -75 -19.6L-75 -17.6C-75 -17.6 -82.6 -18 -84.2 -16C-84.2 -16 -85.4 -10.8 -86.6 -10.4C-86.6 -10.4 -89.4 -8 -87.4 -5.2C-87.4 -5.2 -89.4 -2.8 -89 1.2L-81.4 5.2C-81.4 5.2 -79.4 19.6 -68.6 24.8C-63.764 27.129 -60.6 20.4 -58.6 14.4z"} - , - {"fill": "#ffffff", - "path":"M-59.6 12.56C-59.6 12.56 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.48 -40.36 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.96 -59.6 12.56z"} - , - {"fill": "#eb955c", - "path":"M-51.05 -42.61C-52.14 -43.47 -59.63 -49.24 -65.48 -43C-65.48 -43 -75.62 -25.45 -74.84 -19.21L-74.84 -17.26C-74.84 -17.26 -82.25 -17.65 -83.81 -15.7C-83.81 -15.7 -84.98 -10.63 -86.15 -10.24C-86.15 -10.24 -88.88 -7.9 -86.93 -5.17C-86.93 -5.17 -88.88 -2.83 -88.49 1.07L-81.08 4.97C-81.08 4.97 -79.13 19.01 -68.6 24.08C-63.886 26.35 -60.8 19.79 -58.85 13.94C-58.85 13.94 -61.97 -6.73 -59.63 -11.02C-59.63 -11.02 -49.1 -20.77 -49.49 -24.28C-49.49 -24.28 -49.88 -41.83 -51.05 -42.61z"} - , - {"fill": "#f2b892", - "path":"M-51.5 -41.62C-52.48 -42.54 -59.86 -48.08 -65.56 -42C-65.56 -42 -75.44 -24.9 -74.68 -18.82L-74.68 -16.92C-74.68 -16.92 -81.9 -17.3 -83.42 -15.4C-83.42 -15.4 -84.56 -10.46 -85.7 -10.08C-85.7 -10.08 -88.36 -7.8 -86.46 -5.14C-86.46 -5.14 -88.36 -2.86 -87.98 0.94L-80.76 4.74C-80.76 4.74 -78.86 18.42 -68.6 23.36C-64.006 25.572 -61 19.18 -59.1 13.48C-59.1 13.48 -62.14 -6.66 -59.86 -10.84C-59.86 -10.84 -49.6 -20.34 -49.98 -23.76C-49.98 -23.76 -50.36 -40.86 -51.5 -41.62z"} - , - {"fill": "#f8dcc8", - "path":"M-51.95 -40.63C-52.82 -41.61 -60.09 -46.92 -65.64 -41C-65.64 -41 -75.26 -24.35 -74.52 -18.43L-74.52 -16.58C-74.52 -16.58 -81.55 -16.95 -83.03 -15.1C-83.03 -15.1 -84.14 -10.29 -85.25 -9.92C-85.25 -9.92 -87.84 -7.7 -85.99 -5.11C-85.99 -5.11 -87.84 -2.89 -87.47 0.81L-80.44 4.51C-80.44 4.51 -78.59 17.83 -68.6 22.64C-64.127 24.794 -61.2 18.57 -59.35 13.02C-59.35 13.02 -62.31 -6.59 -60.09 -10.66C-60.09 -10.66 -50.1 -19.91 -50.47 -23.24C-50.47 -23.24 -50.84 -39.89 -51.95 -40.63z"} - , - {"fill": "#ffffff", - "path":"M-59.6 12.46C-59.6 12.46 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.16 -40.68 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.86 -59.6 12.46z"} - , - {"fill": "#cccccc", - "path":"M-62.7 6.2C-62.7 6.2 -84.3 -4 -85.2 -4.8C-85.2 -4.8 -76.1 3.4 -75.3 3.4C-74.5 3.4 -62.7 6.2 -62.7 6.2z"} - , - {"fill": "#000000", - "path":"M-79.8 0C-79.8 0 -61.4 3.6 -61.4 8C-61.4 10.912 -61.643 24.331 -67 22.8C-75.4 20.4 -71.8 6 -79.8 0z"} - , - {"fill": "#99cc32", - "path":"M-71.4 3.8C-71.4 3.8 -62.422 5.274 -61.4 8C-60.8 9.6 -60.137 17.908 -65.6 19C-70.152 19.911 -72.382 9.69 -71.4 3.8z"} - , - {"fill": "#000000", - "path":"M14.595 46.349C14.098 44.607 15.409 44.738 17.2 44.2C19.2 43.6 31.4 39.8 32.2 37.2C33 34.6 46.2 39 46.2 39C48 39.8 52.4 42.4 52.4 42.4C57.2 43.6 63.8 44 63.8 44C66.2 45 69.6 47.8 69.6 47.8C84.2 58 96.601 50.8 96.601 50.8C116.601 44.2 110.601 27 110.601 27C107.601 18 110.801 14.6 110.801 14.6C111.001 10.8 118.201 17.2 118.201 17.2C120.801 21.4 121.601 26.4 121.601 26.4C129.601 37.6 126.201 19.8 126.201 19.8C126.401 18.8 123.601 15.2 123.601 14C123.601 12.8 121.801 9.4 121.801 9.4C118.801 6 121.201 -1 121.201 -1C123.001 -14.8 120.801 -13 120.801 -13C119.601 -14.8 110.401 -4.8 110.401 -4.8C108.201 -1.4 102.201 0.2 102.201 0.2C99.401 2 96.001 0.6 96.001 0.6C93.401 0.2 87.801 7.2 87.801 7.2C90.601 7 93.001 11.4 95.401 11.6C97.801 11.8 99.601 9.2 101.201 8.6C102.801 8 105.601 13.8 105.601 13.8C106.001 16.4 100.401 21.2 100.401 21.2C100.001 25.8 98.401 24.2 98.401 24.2C95.401 23.6 94.201 27.4 93.201 32C92.201 36.6 88.001 37 88.001 37C86.401 44.4 85.2 41.4 85.2 41.4C85 35.8 79 41.6 79 41.6C77.8 43.6 73.2 41.4 73.2 41.4C66.4 39.4 68.8 37.4 68.8 37.4C70.6 35.2 81.8 37.4 81.8 37.4C84 35.8 76 31.8 76 31.8C75.4 30 76.4 25.6 76.4 25.6C77.6 22.4 84.4 16.8 84.4 16.8C93.801 15.6 91.001 14 91.001 14C84.801 8.8 79 16.4 79 16.4C76.8 22.6 59.4 37.6 59.4 37.6C54.6 41 57.2 34.2 53.2 37.6C49.2 41 28.6 32 28.6 32C17.038 30.807 14.306 46.549 10.777 43.429C10.777 43.429 16.195 51.949 14.595 46.349z"} - , - {"fill": "#000000", - "path":"M209.401 -120C209.401 -120 183.801 -112 181.001 -93.2C181.001 -93.2 178.601 -70.4 199.001 -52.8C199.001 -52.8 199.401 -46.4 201.401 -43.2C201.401 -43.2 199.801 -38.4 218.601 -46L245.801 -54.4C245.801 -54.4 252.201 -56.8 257.401 -65.6C262.601 -74.4 277.801 -93.2 274.201 -118.4C274.201 -118.4 275.401 -129.6 269.401 -130C269.401 -130 261.001 -131.6 253.801 -124C253.801 -124 247.001 -120.8 244.601 -121.2L209.401 -120z"} - , - {"fill": "#000000", - "path":"M264.022 -120.99C264.022 -120.99 266.122 -129.92 261.282 -125.08C261.282 -125.08 254.242 -119.36 246.761 -119.36C246.761 -119.36 232.241 -117.16 227.841 -103.96C227.841 -103.96 223.881 -77.12 231.801 -71.4C231.801 -71.4 236.641 -63.92 243.681 -70.52C250.722 -77.12 266.222 -107.35 264.022 -120.99z"} - , - {"fill": "#323232", - "path":"M263.648 -120.632C263.648 -120.632 265.738 -129.376 260.986 -124.624C260.986 -124.624 254.074 -119.008 246.729 -119.008C246.729 -119.008 232.473 -116.848 228.153 -103.888C228.153 -103.888 224.265 -77.536 232.041 -71.92C232.041 -71.92 236.793 -64.576 243.705 -71.056C250.618 -77.536 265.808 -107.24 263.648 -120.632z"} - , - {"fill": "#666666", - "path":"M263.274 -120.274C263.274 -120.274 265.354 -128.832 260.69 -124.168C260.69 -124.168 253.906 -118.656 246.697 -118.656C246.697 -118.656 232.705 -116.536 228.465 -103.816C228.465 -103.816 224.649 -77.952 232.281 -72.44C232.281 -72.44 236.945 -65.232 243.729 -71.592C250.514 -77.952 265.394 -107.13 263.274 -120.274z"} - , - {"fill": "#999999", - "path":"M262.9 -119.916C262.9 -119.916 264.97 -128.288 260.394 -123.712C260.394 -123.712 253.738 -118.304 246.665 -118.304C246.665 -118.304 232.937 -116.224 228.777 -103.744C228.777 -103.744 225.033 -78.368 232.521 -72.96C232.521 -72.96 237.097 -65.888 243.753 -72.128C250.41 -78.368 264.98 -107.02 262.9 -119.916z"} - , - {"fill": "#cccccc", - "path":"M262.526 -119.558C262.526 -119.558 264.586 -127.744 260.098 -123.256C260.098 -123.256 253.569 -117.952 246.633 -117.952C246.633 -117.952 233.169 -115.912 229.089 -103.672C229.089 -103.672 225.417 -78.784 232.761 -73.48C232.761 -73.48 237.249 -66.544 243.777 -72.664C250.305 -78.784 264.566 -106.91 262.526 -119.558z"} - , - {"fill": "#ffffff", - "path":"M262.151 -119.2C262.151 -119.2 264.201 -127.2 259.801 -122.8C259.801 -122.8 253.401 -117.6 246.601 -117.6C246.601 -117.6 233.401 -115.6 229.401 -103.6C229.401 -103.6 225.801 -79.2 233.001 -74C233.001 -74 237.401 -67.2 243.801 -73.2C250.201 -79.2 264.151 -106.8 262.151 -119.2z"} - , - {"fill": "#992600", - "path":"M50.6 84C50.6 84 30.2 64.8 22.2 64C22.2 64 -12.2 60 -27 78C-27 78 -9.4 57.6 18.2 63.2C18.2 63.2 -3.4 58.8 -15.8 62C-15.8 62 -32.6 62 -42.2 76L-45 80.8C-45 80.8 -41 66 -22.6 60C-22.6 60 0.2 55.2 11 60C11 60 -10.6 53.2 -20.6 55.2C-20.6 55.2 -51 52.8 -63.8 79.2C-63.8 79.2 -59.8 64.8 -45 57.6C-45 57.6 -31.4 48.8 -11 51.6C-11 51.6 3.4 54.8 8.6 57.2C13.8 59.6 12.6 56.8 4.2 52C4.2 52 -1.4 42 -15.4 42.4C-15.4 42.4 -58.2 46 -68.6 58C-68.6 58 -55 46.8 -44.6 44C-44.6 44 -22.2 36 -13.8 36.8C-13.8 36.8 11 37.8 18.6 33.8C18.6 33.8 7.4 38.8 10.6 42C13.8 45.2 20.6 52.8 20.6 54C20.6 55.2 44.8 77.3 48.4 81.7L50.6 84z"} - , - {"fill": "#cccccc", - "path":"M189 278C189 278 173.5 241.5 161 232C161 232 187 248 190.5 266C190.5 266 190.5 276 189 278z"} - , - {"fill": "#cccccc", - "path":"M236 285.5C236 285.5 209.5 230.5 191 206.5C191 206.5 234.5 244 239.5 270.5L240 276L237 273.5C237 273.5 236.5 282.5 236 285.5z"} - , - {"fill": "#cccccc", - "path":"M292.5 237C292.5 237 230 177.5 228.5 175C228.5 175 289 241 292 248.5C292 248.5 290 239.5 292.5 237z"} - , - {"fill": "#cccccc", - "path":"M104 280.5C104 280.5 123.5 228.5 142.5 251C142.5 251 157.5 261 157 264C157 264 153 257.5 135 258C135 258 116 255 104 280.5z"} - , - {"fill": "#cccccc", - "path":"M294.5 153C294.5 153 249.5 124.5 242 123C230.193 120.639 291.5 152 296.5 162.5C296.5 162.5 298.5 160 294.5 153z"} - , - {"fill": "#000000", - "path":"M143.801 259.601C143.801 259.601 164.201 257.601 171.001 250.801L175.401 254.401L193.001 216.001L196.601 221.201C196.601 221.201 211.001 206.401 210.201 198.401C209.401 190.401 223.001 204.401 223.001 204.401C223.001 204.401 222.201 192.801 229.401 199.601C229.401 199.601 227.001 184.001 235.401 192.001C235.401 192.001 224.864 161.844 247.401 187.601C253.001 194.001 248.601 187.201 248.601 187.201C248.601 187.201 222.601 139.201 244.201 153.601C244.201 153.601 246.201 130.801 245.001 126.401C243.801 122.001 241.801 99.6 237.001 94.4C232.201 89.2 237.401 87.6 243.001 92.8C243.001 92.8 231.801 68.8 245.001 80.8C245.001 80.8 241.401 65.6 237.001 62.8C237.001 62.8 231.401 45.6 246.601 56.4C246.601 56.4 242.201 44 239.001 40.8C239.001 40.8 227.401 13.2 234.601 18L239.001 21.6C239.001 21.6 232.201 7.6 238.601 12C245.001 16.4 245.001 16 245.001 16C245.001 16 223.801 -17.2 244.201 0.4C244.201 0.4 236.042 -13.518 232.601 -20.4C232.601 -20.4 213.801 -40.8 228.201 -34.4L233.001 -32.8C233.001 -32.8 224.201 -42.8 216.201 -44.4C208.201 -46 218.601 -52.4 225.001 -50.4C231.401 -48.4 247.001 -40.8 247.001 -40.8C247.001 -40.8 259.801 -22 263.801 -21.6C263.801 -21.6 243.801 -29.2 249.801 -21.2C249.801 -21.2 264.201 -7.2 257.001 -7.6C257.001 -7.6 251.001 -0.4 255.801 8.4C255.801 8.4 237.342 -9.991 252.201 15.6L259.001 32C259.001 32 234.601 7.2 245.801 29.2C245.801 29.2 263.001 52.8 265.001 53.2C267.001 53.6 271.401 62.4 271.401 62.4L267.001 60.4L272.201 69.2C272.201 69.2 261.001 57.2 267.001 70.4L272.601 84.8C272.601 84.8 252.201 62.8 265.801 92.4C265.801 92.4 249.401 87.2 258.201 104.4C258.201 104.4 256.601 120.401 257.001 125.601C257.401 130.801 258.601 159.201 254.201 167.201C249.801 175.201 260.201 194.401 262.201 198.401C264.201 202.401 267.801 213.201 259.001 204.001C250.201 194.801 254.601 200.401 256.601 209.201C258.601 218.001 264.601 233.601 263.801 239.201C263.801 239.201 262.601 240.401 259.401 236.801C259.401 236.801 244.601 214.001 246.201 228.401C246.201 228.401 245.001 236.401 241.801 245.201C241.801 245.201 238.601 256.001 238.601 247.201C238.601 247.201 235.401 230.401 232.601 238.001C229.801 245.601 226.201 251.601 223.401 254.001C220.601 256.401 215.401 233.601 214.201 244.001C214.201 244.001 202.201 231.601 197.401 248.001L185.801 264.401C185.801 264.401 185.401 252.001 184.201 258.001C184.201 258.001 154.201 264.001 143.801 259.601z"} - , - {"fill": "#000000", - "path":"M109.401 -97.2C109.401 -97.2 97.801 -105.2 93.801 -104.8C89.801 -104.4 121.401 -113.6 162.601 -86C162.601 -86 167.401 -83.2 171.001 -83.6C171.001 -83.6 174.201 -81.2 171.401 -77.6C171.401 -77.6 162.601 -68 173.801 -56.8C173.801 -56.8 192.201 -50 186.601 -58.8C186.601 -58.8 197.401 -54.8 199.801 -50.8C202.201 -46.8 201.001 -50.8 201.001 -50.8C201.001 -50.8 194.601 -58 188.601 -63.2C188.601 -63.2 183.401 -65.2 180.601 -73.6C177.801 -82 175.401 -92 179.801 -95.2C179.801 -95.2 175.801 -90.8 176.601 -94.8C177.401 -98.8 181.001 -102.4 182.601 -102.8C184.201 -103.2 200.601 -119 207.401 -119.4C207.401 -119.4 198.201 -118 195.201 -119C192.201 -120 165.601 -131.4 159.601 -132.6C159.601 -132.6 142.801 -139.2 154.801 -137.2C154.801 -137.2 190.601 -133.4 208.801 -120.2C208.801 -120.2 201.601 -128.6 183.201 -135.6C183.201 -135.6 161.001 -148.2 125.801 -143.2C125.801 -143.2 108.001 -140 100.201 -138.2C100.201 -138.2 97.601 -138.8 97.001 -139.2C96.401 -139.6 84.6 -148.6 57 -141.6C57 -141.6 40 -137 31.4 -132.2C31.4 -132.2 16.2 -131 12.6 -127.8C12.6 -127.8 -6 -113.2 -8 -112.4C-10 -111.6 -21.4 -104 -22.2 -103.6C-22.2 -103.6 2.4 -110.2 4.8 -112.6C7.2 -115 24.6 -117.6 27 -116.2C29.4 -114.8 37.8 -115.4 28.2 -114.8C28.2 -114.8 103.801 -100 104.601 -98C105.401 -96 109.401 -97.2 109.401 -97.2z"} - , - {"fill": "#cc7226", - "path":"M180.801 -106.4C180.801 -106.4 170.601 -113.8 168.601 -113.8C166.601 -113.8 154.201 -124 150.001 -123.6C145.801 -123.2 133.601 -133.2 106.201 -125C106.201 -125 105.601 -127 109.201 -127.8C109.201 -127.8 115.601 -130 116.001 -130.6C116.001 -130.6 136.201 -134.8 143.401 -131.2C143.401 -131.2 152.601 -128.6 158.801 -122.4C158.801 -122.4 170.001 -119.2 173.201 -120.2C173.201 -120.2 182.001 -118 182.401 -116.2C182.401 -116.2 188.201 -113.2 186.401 -110.6C186.401 -110.6 186.801 -109 180.801 -106.4z"} - , - {"fill": "#cc7226", - "path":"M168.33 -108.509C169.137 -107.877 170.156 -107.779 170.761 -106.97C170.995 -106.656 170.706 -106.33 170.391 -106.233C169.348 -105.916 168.292 -106.486 167.15 -105.898C166.748 -105.691 166.106 -105.873 165.553 -106.022C163.921 -106.463 162.092 -106.488 160.401 -105.8C158.416 -106.929 156.056 -106.345 153.975 -107.346C153.917 -107.373 153.695 -107.027 153.621 -107.054C150.575 -108.199 146.832 -107.916 144.401 -110.2C141.973 -110.612 139.616 -111.074 137.188 -111.754C135.37 -112.263 133.961 -113.252 132.341 -114.084C130.964 -114.792 129.507 -115.314 127.973 -115.686C126.11 -116.138 124.279 -116.026 122.386 -116.546C122.293 -116.571 122.101 -116.227 122.019 -116.254C121.695 -116.362 121.405 -116.945 121.234 -116.892C119.553 -116.37 118.065 -117.342 116.401 -117C115.223 -118.224 113.495 -117.979 111.949 -118.421C108.985 -119.269 105.831 -117.999 102.801 -119C106.914 -120.842 111.601 -119.61 115.663 -121.679C117.991 -122.865 120.653 -121.763 123.223 -122.523C123.71 -122.667 124.401 -122.869 124.801 -122.2C124.935 -122.335 125.117 -122.574 125.175 -122.546C127.625 -121.389 129.94 -120.115 132.422 -119.049C132.763 -118.903 133.295 -119.135 133.547 -118.933C135.067 -117.717 137.01 -117.82 138.401 -116.6C140.099 -117.102 141.892 -116.722 143.621 -117.346C143.698 -117.373 143.932 -117.032 143.965 -117.054C145.095 -117.802 146.25 -117.531 147.142 -117.227C147.48 -117.112 148.143 -116.865 148.448 -116.791C149.574 -116.515 150.43 -116.035 151.609 -115.852C151.723 -115.834 151.908 -116.174 151.98 -116.146C153.103 -115.708 154.145 -115.764 154.801 -114.6C154.936 -114.735 155.101 -114.973 155.183 -114.946C156.21 -114.608 156.859 -113.853 157.96 -113.612C158.445 -113.506 159.057 -112.88 159.633 -112.704C162.025 -111.973 163.868 -110.444 166.062 -109.549C166.821 -109.239 167.697 -109.005 168.33 -108.509z"} - , - {"fill": "#cc7226", - "path":"M91.696 -122.739C89.178 -124.464 86.81 -125.57 84.368 -127.356C84.187 -127.489 83.827 -127.319 83.625 -127.441C82.618 -128.05 81.73 -128.631 80.748 -129.327C80.209 -129.709 79.388 -129.698 78.88 -129.956C76.336 -131.248 73.707 -131.806 71.2 -133C71.882 -133.638 73.004 -133.394 73.6 -134.2C73.795 -133.92 74.033 -133.636 74.386 -133.827C76.064 -134.731 77.914 -134.884 79.59 -134.794C81.294 -134.702 83.014 -134.397 84.789 -134.125C85.096 -134.078 85.295 -133.555 85.618 -133.458C87.846 -132.795 90.235 -133.32 92.354 -132.482C93.945 -131.853 95.515 -131.03 96.754 -129.755C97.006 -129.495 96.681 -129.194 96.401 -129C96.789 -129.109 97.062 -128.903 97.173 -128.59C97.257 -128.351 97.257 -128.049 97.173 -127.81C97.061 -127.498 96.782 -127.397 96.408 -127.346C95.001 -127.156 96.773 -128.536 96.073 -128.088C94.8 -127.274 95.546 -125.868 94.801 -124.6C94.521 -124.794 94.291 -125.012 94.401 -125.4C94.635 -124.878 94.033 -124.588 93.865 -124.272C93.48 -123.547 92.581 -122.132 91.696 -122.739z"} - , - {"fill": "#cc7226", - "path":"M59.198 -115.391C56.044 -116.185 52.994 -116.07 49.978 -117.346C49.911 -117.374 49.688 -117.027 49.624 -117.054C48.258 -117.648 47.34 -118.614 46.264 -119.66C45.351 -120.548 43.693 -120.161 42.419 -120.648C42.095 -120.772 41.892 -121.284 41.591 -121.323C40.372 -121.48 39.445 -122.429 38.4 -123C40.736 -123.795 43.147 -123.764 45.609 -124.148C45.722 -124.166 45.867 -123.845 46 -123.845C46.136 -123.845 46.266 -124.066 46.4 -124.2C46.595 -123.92 46.897 -123.594 47.154 -123.848C47.702 -124.388 48.258 -124.198 48.798 -124.158C48.942 -124.148 49.067 -123.845 49.2 -123.845C49.336 -123.845 49.467 -124.156 49.6 -124.156C49.736 -124.155 49.867 -123.845 50 -123.845C50.136 -123.845 50.266 -124.066 50.4 -124.2C51.092 -123.418 51.977 -123.972 52.799 -123.793C53.837 -123.566 54.104 -122.418 55.178 -122.12C59.893 -120.816 64.03 -118.671 68.393 -116.584C68.7 -116.437 68.91 -116.189 68.8 -115.8C69.067 -115.8 69.38 -115.888 69.57 -115.756C70.628 -115.024 71.669 -114.476 72.366 -113.378C72.582 -113.039 72.253 -112.632 72.02 -112.684C67.591 -113.679 63.585 -114.287 59.198 -115.391z"} - , - {"fill": "#cc7226", - "path":"M45.338 -71.179C43.746 -72.398 43.162 -74.429 42.034 -76.221C41.82 -76.561 42.094 -76.875 42.411 -76.964C42.971 -77.123 43.514 -76.645 43.923 -76.443C45.668 -75.581 47.203 -74.339 49.2 -74.2C51.19 -71.966 55.45 -71.581 55.457 -68.2C55.458 -67.341 54.03 -68.259 53.6 -67.4C51.149 -68.403 48.76 -68.3 46.38 -69.767C45.763 -70.148 46.093 -70.601 45.338 -71.179z"} - , - {"fill": "#cc7226", - "path":"M17.8 -123.756C17.935 -123.755 24.966 -123.522 24.949 -123.408C24.904 -123.099 17.174 -122.05 16.81 -122.22C16.646 -122.296 9.134 -119.866 9 -120C9.268 -120.135 17.534 -123.756 17.8 -123.756z"} - , - {"fill": "#000000", - "path":"M33.2 -114C33.2 -114 18.4 -112.2 14 -111C9.6 -109.8 -9 -102.2 -12 -100.2C-12 -100.2 -25.4 -94.8 -42.4 -74.8C-42.4 -74.8 -34.8 -78.2 -32.6 -81C-32.6 -81 -19 -93.6 -19.2 -91C-19.2 -91 -7 -99.6 -7.6 -97.4C-7.6 -97.4 16.8 -108.6 14.8 -105.4C14.8 -105.4 36.4 -110 35.4 -108C35.4 -108 54.2 -103.6 51.4 -103.4C51.4 -103.4 45.6 -102.2 52 -98.6C52 -98.6 48.6 -94.2 43.2 -98.2C37.8 -102.2 40.8 -100 35.8 -99C35.8 -99 33.2 -98.2 28.6 -102.2C28.6 -102.2 23 -106.8 14.2 -103.2C14.2 -103.2 -16.4 -90.6 -18.4 -90C-18.4 -90 -22 -87.2 -24.4 -83.6C-24.4 -83.6 -30.2 -79.2 -33.2 -77.8C-33.2 -77.8 -46 -66.2 -47.2 -64.8C-47.2 -64.8 -50.6 -59.6 -51.4 -59.2C-51.4 -59.2 -45 -63 -43 -65C-43 -65 -29 -75 -23.6 -75.8C-23.6 -75.8 -19.2 -78.8 -18.4 -80.2C-18.4 -80.2 -4 -89.4 0.2 -89.4C0.2 -89.4 9.4 -84.2 11.8 -91.2C11.8 -91.2 17.6 -93 23.2 -91.8C23.2 -91.8 26.4 -94.4 25.6 -96.6C25.6 -96.6 27.2 -98.4 28.2 -94.6C28.2 -94.6 31.6 -91 36.4 -93C36.4 -93 40.4 -93.2 38.4 -90.8C38.4 -90.8 34 -87 22.2 -86.8C22.2 -86.8 9.8 -86.2 -6.6 -78.6C-6.6 -78.6 -36.4 -68.2 -45.6 -57.8C-45.6 -57.8 -52 -49 -57.4 -47.8C-57.4 -47.8 -63.2 -47 -69.2 -39.6C-69.2 -39.6 -59.4 -45.4 -50.4 -45.4C-50.4 -45.4 -46.4 -47.8 -50.2 -44.2C-50.2 -44.2 -53.8 -36.6 -52.2 -31.2C-52.2 -31.2 -52.8 -26 -53.6 -24.4C-53.6 -24.4 -61.4 -11.6 -61.4 -9.2C-61.4 -6.8 -60.2 3 -59.8 3.6C-59.4 4.2 -60.8 2 -57 4.4C-53.2 6.8 -50.4 8.4 -49.6 11.2C-48.8 14 -51.6 5.8 -51.8 4C-52 2.2 -56.2 -5 -55.4 -7.4C-55.4 -7.4 -54.4 -6.4 -53.6 -5C-53.6 -5 -54.2 -5.6 -53.6 -9.2C-53.6 -9.2 -52.8 -14.4 -51.4 -17.6C-50 -20.8 -48 -24.6 -47.6 -25.4C-47.2 -26.2 -47.2 -32 -45.8 -29.4L-42.4 -26.8C-42.4 -26.8 -45.2 -29.4 -43 -31.6C-43 -31.6 -44 -37.2 -42.2 -39.8C-42.2 -39.8 -35.2 -48.2 -33.6 -49.2C-32 -50.2 -33.4 -49.8 -33.4 -49.8C-33.4 -49.8 -27.4 -54 -33.2 -52.4C-33.2 -52.4 -37.2 -50.8 -40.2 -50.8C-40.2 -50.8 -47.8 -48.8 -43.8 -53C-39.8 -57.2 -29.8 -62.6 -26 -62.4L-25.2 -60.8L-14 -63.2L-15.2 -62.4C-15.2 -62.4 -15.4 -62.6 -11.2 -63C-7 -63.4 -1.2 -62 0.2 -63.8C1.6 -65.6 5 -66.6 4.6 -65.2C4.2 -63.8 4 -61.8 4 -61.8C4 -61.8 9 -67.6 8.4 -65.4C7.8 -63.2 -0.4 -58 -1.8 -51.8L8.6 -60L12.2 -63C12.2 -63 15.8 -60.8 16 -62.4C16.2 -64 20.8 -69.8 22 -69.6C23.2 -69.4 25.2 -72.2 25 -69.6C24.8 -67 32.4 -61.6 32.4 -61.6C32.4 -61.6 35.6 -63.4 37 -62C38.4 -60.6 42.6 -81.8 42.6 -81.8L67.6 -92.4L111.201 -95.8L94.201 -102.6L33.2 -114z"} - , - {"stroke":"#4c0000", "width":2, - "path":"M51.4 85C51.4 85 36.4 68.2 28 65.6C28 65.6 14.6 58.8 -10 66.6"} - , - {"stroke":"#4c0000", "width":2, - "path":"M24.8 64.2C24.8 64.2 -0.4 56.2 -15.8 60.4C-15.8 60.4 -34.2 62.4 -42.6 76.2"} - , - {"stroke":"#4c0000", "width":2, - "path":"M21.2 63C21.2 63 4.2 55.8 -10.6 53.6C-10.6 53.6 -27.2 51 -43.8 58.2C-43.8 58.2 -56 64.2 -61.4 74.4"} - , - {"stroke":"#4c0000", "width":2, - "path":"M22.2 63.4C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4"} - , - {"fill": "#000000", - "path":"M20.895 54.407C22.437 55.87 49.4 84.8 49.4 84.8C84.6 121.401 56.6 87.2 56.6 87.2C49 82.4 39.8 63.6 39.8 63.6C38.6 60.8 53.8 70.8 53.8 70.8C57.8 71.6 71.4 90.8 71.4 90.8C64.6 88.4 69.4 95.6 69.4 95.6C72.2 97.6 92.601 113.201 92.601 113.201C96.201 117.201 100.201 118.801 100.201 118.801C114.201 113.601 107.801 126.801 107.801 126.801C110.201 133.601 115.801 122.001 115.801 122.001C127.001 105.2 110.601 107.601 110.601 107.601C80.6 110.401 73.8 94.4 73.8 94.4C71.4 92 80.2 94.4 80.2 94.4C88.601 96.4 73 82 73 82C75.4 82 84.6 88.8 84.6 88.8C95.001 98 97.001 96 97.001 96C115.001 87.2 125.401 94.8 125.401 94.8C127.401 96.4 121.801 103.2 123.401 108.401C125.001 113.601 129.801 126.001 129.801 126.001C127.401 127.601 127.801 138.401 127.801 138.401C144.601 161.601 135.001 159.601 135.001 159.601C119.401 159.201 134.201 166.801 134.201 166.801C137.401 168.801 146.201 176.001 146.201 176.001C143.401 174.801 141.801 180.001 141.801 180.001C146.601 184.001 143.801 188.801 143.801 188.801C137.801 190.001 136.601 194.001 136.601 194.001C143.401 202.001 133.401 202.401 133.401 202.401C137.001 206.801 132.201 218.801 132.201 218.801C127.401 218.801 121.001 224.401 121.001 224.401C123.401 229.201 113.001 234.801 113.001 234.801C104.601 236.401 107.401 243.201 107.401 243.201C99.401 249.201 97.001 265.201 97.001 265.201C96.201 275.601 93.801 278.801 99.001 276.801C104.201 274.801 103.401 262.401 103.401 262.401C98.601 246.801 141.401 230.801 141.401 230.801C145.401 229.201 146.201 224.001 146.201 224.001C148.201 224.401 157.001 232.001 157.001 232.001C164.601 243.201 165.001 234.001 165.001 234.001C166.201 230.401 164.601 224.401 164.601 224.401C170.601 202.801 156.601 196.401 156.601 196.401C146.601 162.801 160.601 171.201 160.601 171.201C163.401 176.801 174.201 182.001 174.201 182.001L177.801 179.601C176.201 174.801 184.601 168.801 184.601 168.801C187.401 175.201 193.401 167.201 193.401 167.201C197.001 142.801 209.401 157.201 209.401 157.201C213.401 158.401 214.601 151.601 214.601 151.601C218.201 141.201 214.601 127.601 214.601 127.601C218.201 127.201 227.801 133.201 227.801 133.201C230.601 129.601 221.401 112.801 225.401 115.201C229.401 117.601 233.801 119.201 233.801 119.201C234.601 117.201 224.601 104.801 224.601 104.801C220.201 102 215.001 81.6 215.001 81.6C222.201 85.2 212.201 70 212.201 70C212.201 66.8 218.201 55.6 218.201 55.6C217.401 48.8 218.201 49.2 218.201 49.2C221.001 50.4 229.001 52 222.201 45.6C215.401 39.2 223.001 34.4 223.001 34.4C227.401 31.6 213.801 32 213.801 32C208.601 27.6 209.001 23.6 209.001 23.6C217.001 25.6 202.601 11.2 200.201 7.6C197.801 4 207.401 -1.2 207.401 -1.2C220.601 -4.8 209.001 -8 209.001 -8C189.401 -7.6 200.201 -18.4 200.201 -18.4C206.201 -18 204.601 -20.4 204.601 -20.4C199.401 -21.6 189.801 -28 189.801 -28C185.801 -31.6 189.401 -30.8 189.401 -30.8C206.201 -29.6 177.401 -40.8 177.401 -40.8C185.401 -40.8 167.401 -51.2 167.401 -51.2C165.401 -52.8 162.201 -60.4 162.201 -60.4C156.201 -65.6 151.401 -72.4 151.401 -72.4C151.001 -76.8 146.201 -81.6 146.201 -81.6C134.601 -95.2 129.001 -94.8 129.001 -94.8C114.201 -98.4 109.001 -97.6 109.001 -97.6L56.2 -93.2C29.8 -80.4 37.6 -59.4 37.6 -59.4C44 -51 53.2 -54.8 53.2 -54.8C57.8 -61 69.4 -58.8 69.4 -58.8C89.801 -55.6 87.201 -59.2 87.201 -59.2C84.801 -63.8 68.6 -70 68.4 -70.6C68.2 -71.2 59.4 -74.6 59.4 -74.6C56.4 -75.8 52 -85 52 -85C48.8 -88.4 64.6 -82.6 64.6 -82.6C63.4 -81.6 70.8 -77.6 70.8 -77.6C88.201 -78.6 98.801 -67.8 98.801 -67.8C109.601 -51.2 109.801 -59.4 109.801 -59.4C112.601 -68.8 100.801 -90 100.801 -90C101.201 -92 109.401 -85.4 109.401 -85.4C110.801 -87.4 111.601 -81.6 111.601 -81.6C111.801 -79.2 115.601 -71.2 115.601 -71.2C118.401 -58.2 122.001 -65.6 122.001 -65.6L126.601 -56.2C128.001 -53.6 122.001 -46 122.001 -46C121.801 -43.2 122.601 -43.4 117.001 -35.8C111.401 -28.2 114.801 -23.8 114.801 -23.8C113.401 -17.2 122.201 -17.6 122.201 -17.6C124.801 -15.4 128.201 -15.4 128.201 -15.4C130.001 -13.4 132.401 -14 132.401 -14C134.001 -17.8 140.201 -15.8 140.201 -15.8C141.601 -18.2 149.801 -18.6 149.801 -18.6C150.801 -21.2 151.201 -22.8 154.601 -23.4C158.001 -24 133.401 -67 133.401 -67C139.801 -67.8 131.601 -80.2 131.601 -80.2C129.401 -86.8 140.801 -72.2 143.001 -70.8C145.201 -69.4 146.201 -67.2 144.601 -67.4C143.001 -67.6 141.201 -65.4 142.601 -65.2C144.001 -65 157.001 -50 160.401 -39.8C163.801 -29.6 169.801 -25.6 176.001 -19.6C182.201 -13.6 181.401 10.6 181.401 10.6C181.001 19.4 187.001 30 187.001 30C189.001 33.8 184.801 52 184.801 52C182.801 54.2 184.201 55 184.201 55C185.201 56.2 192.001 69.4 192.001 69.4C190.201 69.2 193.801 72.8 193.801 72.8C199.001 78.8 192.601 75.8 192.601 75.8C186.601 74.2 193.601 84 193.601 84C194.801 85.8 185.801 81.2 185.801 81.2C176.601 80.6 188.201 87.8 188.201 87.8C196.801 95 185.401 90.6 185.401 90.6C180.801 88.8 184.001 95.6 184.001 95.6C187.201 97.2 204.401 104.2 204.401 104.2C204.801 108.001 201.801 113.001 201.801 113.001C202.201 117.001 200.001 120.401 200.001 120.401C198.801 128.601 198.201 129.401 198.201 129.401C194.001 129.601 186.601 143.401 186.601 143.401C184.801 146.001 174.601 158.001 174.601 158.001C172.601 165.001 154.601 157.801 154.601 157.801C148.001 161.201 150.001 157.801 150.001 157.801C149.601 155.601 154.401 149.601 154.401 149.601C161.401 147.001 158.801 136.201 158.801 136.201C162.801 134.801 151.601 132.001 151.801 130.801C152.001 129.601 157.801 128.201 157.801 128.201C165.801 126.201 161.401 123.801 161.401 123.801C160.801 119.801 163.801 114.201 163.801 114.201C175.401 113.401 163.801 97.2 163.801 97.2C153.001 89.6 152.001 83.8 152.001 83.8C164.601 75.6 156.401 63.2 156.601 59.6C156.801 56 158.001 34.4 158.001 34.4C156.001 28.2 153.001 14.6 153.001 14.6C155.201 9.4 162.601 -3.2 162.601 -3.2C165.401 -7.4 174.201 -12.2 172.001 -15.2C169.801 -18.2 162.001 -16.4 162.001 -16.4C154.201 -17.8 154.801 -12.6 154.801 -12.6C153.201 -11.6 152.401 -6.6 152.401 -6.6C151.68 1.333 142.801 7.6 142.801 7.6C131.601 13.8 140.801 17.8 140.801 17.8C146.801 24.4 137.001 24.6 137.001 24.6C126.001 22.8 134.201 33 134.201 33C145.001 45.8 142.001 48.6 142.001 48.6C131.801 49.6 144.401 58.8 144.401 58.8C144.401 58.8 143.601 56.8 143.801 58.6C144.001 60.4 147.001 64.6 147.801 66.6C148.601 68.6 144.601 68.8 144.601 68.8C145.201 78.4 129.801 74.2 129.801 74.2C129.801 74.2 129.801 74.2 128.201 74.4C126.601 74.6 115.401 73.8 109.601 71.6C103.801 69.4 97.001 69.4 97.001 69.4C97.001 69.4 93.001 71.2 85.4 71C77.8 70.8 69.8 73.6 69.8 73.6C65.4 73.2 74 68.8 74.2 69C74.4 69.2 80 63.6 72 64.2C50.203 65.835 39.4 55.6 39.4 55.6C37.4 54.2 34.8 51.4 34.8 51.4C24.8 49.4 36.2 63.8 36.2 63.8C37.4 65.2 36 66.2 36 66.2C35.2 64.6 27.4 59.2 27.4 59.2C24.589 58.227 23.226 56.893 20.895 54.407z"} - , - {"fill": "#4c0000", - "path":"M-3 42.8C-3 42.8 8.6 48.4 11.2 51.2C13.8 54 27.8 65.4 27.8 65.4C27.8 65.4 22.4 63.4 19.8 61.6C17.2 59.8 6.4 51.6 6.4 51.6C6.4 51.6 2.6 45.6 -3 42.8z"} - , - {"fill": "#99cc32", - "path":"M-61.009 11.603C-60.672 11.455 -61.196 8.743 -61.4 8.2C-62.422 5.474 -71.4 4 -71.4 4C-71.627 5.365 -71.682 6.961 -71.576 8.599C-71.576 8.599 -66.708 14.118 -61.009 11.603z"} - , - {"fill": "#659900", - "path":"M-61.009 11.403C-61.458 11.561 -61.024 8.669 -61.2 8.2C-62.222 5.474 -71.4 3.9 -71.4 3.9C-71.627 5.265 -71.682 6.861 -71.576 8.499C-71.576 8.499 -67.308 13.618 -61.009 11.403z"} - , - {"fill": "#000000", - "path":"M-65.4 11.546C-66.025 11.546 -66.531 10.406 -66.531 9C-66.531 7.595 -66.025 6.455 -65.4 6.455C-64.775 6.455 -64.268 7.595 -64.268 9C-64.268 10.406 -64.775 11.546 -65.4 11.546z"} - , - {"fill": "#000000", - "path":"M-65.4 9z"} - , - {"fill": "#000000", - "path":"M-111 109.601C-111 109.601 -116.6 119.601 -91.8 113.601C-91.8 113.601 -77.8 112.401 -75.4 110.001C-74.2 110.801 -65.834 113.734 -63 114.401C-56.2 116.001 -47.8 106 -47.8 106C-47.8 106 -43.2 95.5 -40.4 95.5C-37.6 95.5 -40.8 97.1 -40.8 97.1C-40.8 97.1 -47.4 107.201 -47 108.801C-47 108.801 -52.2 128.801 -68.2 129.601C-68.2 129.601 -84.35 130.551 -83 136.401C-83 136.401 -74.2 134.001 -71.8 136.401C-71.8 136.401 -61 136.001 -69 142.401L-75.8 154.001C-75.8 154.001 -75.66 157.919 -85.8 154.401C-95.6 151.001 -105.9 138.101 -105.9 138.101C-105.9 138.101 -121.85 123.551 -111 109.601z"} - , - {"fill": "#e59999", - "path":"M-112.2 113.601C-112.2 113.601 -114.2 123.201 -77.4 112.801C-77.4 112.801 -73 112.801 -70.6 113.601C-68.2 114.401 -56.2 117.201 -54.2 116.001C-54.2 116.001 -61.4 129.601 -73 128.001C-73 128.001 -86.2 129.601 -85.8 134.401C-85.8 134.401 -81.8 141.601 -77 144.001C-77 144.001 -74.2 146.401 -74.6 149.601C-75 152.801 -77.8 154.401 -79.8 155.201C-81.8 156.001 -85 152.801 -86.6 152.801C-88.2 152.801 -96.6 146.401 -101 141.601C-105.4 136.801 -113.8 124.801 -113.4 122.001C-113 119.201 -112.2 113.601 -112.2 113.601z"} - , - {"fill": "#b26565", - "path":"M-109 131.051C-106.4 135.001 -103.2 139.201 -101 141.601C-96.6 146.401 -88.2 152.801 -86.6 152.801C-85 152.801 -81.8 156.001 -79.8 155.201C-77.8 154.401 -75 152.801 -74.6 149.601C-74.2 146.401 -77 144.001 -77 144.001C-80.066 142.468 -82.806 138.976 -84.385 136.653C-84.385 136.653 -84.2 139.201 -89.4 138.401C-94.6 137.601 -99.8 134.801 -101.4 131.601C-103 128.401 -105.4 126.001 -103.8 129.601C-102.2 133.201 -99.8 136.801 -98.2 137.201C-96.6 137.601 -97 138.801 -99.4 138.401C-101.8 138.001 -104.6 137.601 -109 132.401z"} - , - {"fill": "#992600", - "path":"M-111.6 110.001C-111.6 110.001 -109.8 96.4 -108.6 92.4C-108.6 92.4 -109.4 85.6 -107 81.4C-104.6 77.2 -102.6 71 -99.6 65.6C-96.6 60.2 -96.4 56.2 -92.4 54.6C-88.4 53 -82.4 44.4 -79.6 43.4C-76.8 42.4 -77 43.2 -77 43.2C-77 43.2 -70.2 28.4 -56.6 32.4C-56.6 32.4 -72.8 29.6 -57 20.2C-57 20.2 -61.8 21.3 -58.5 14.3C-56.299 9.632 -56.8 16.4 -67.8 28.2C-67.8 28.2 -72.8 36.8 -78 39.8C-83.2 42.8 -95.2 49.8 -96.4 53.6C-97.6 57.4 -100.8 63.2 -102.8 64.8C-104.8 66.4 -107.6 70.6 -108 74C-108 74 -109.2 78 -110.6 79.2C-112 80.4 -112.2 83.6 -112.2 85.6C-112.2 87.6 -114.2 90.4 -114 92.8C-114 92.8 -113.2 111.801 -113.6 113.801L-111.6 110.001z"} - , - {"fill": "#ffffff", - "path":"M-120.2 114.601C-120.2 114.601 -122.2 113.201 -126.6 119.201C-126.6 119.201 -119.3 152.201 -119.3 153.601C-119.3 153.601 -118.2 151.501 -119.5 144.301C-120.8 137.101 -121.7 124.401 -121.7 124.401L-120.2 114.601z"} - , - {"fill": "#992600", - "path":"M-98.6 54C-98.6 54 -116.2 57.2 -115.8 86.4L-116.6 111.201C-116.6 111.201 -117.8 85.6 -119 84C-120.2 82.4 -116.2 71.2 -119.4 77.2C-119.4 77.2 -133.4 91.2 -125.4 112.401C-125.4 112.401 -123.9 115.701 -126.9 111.101C-126.9 111.101 -131.5 98.5 -130.4 92.1C-130.4 92.1 -130.2 89.9 -128.3 87.1C-128.3 87.1 -119.7 75.4 -117 73.1C-117 73.1 -115.2 58.7 -99.8 53.5C-99.8 53.5 -94.1 51.2 -98.6 54z"} - , - {"fill": "#000000", - "path":"M40.8 -12.2C41.46 -12.554 41.451 -13.524 42.031 -13.697C43.18 -14.041 43.344 -15.108 43.862 -15.892C44.735 -17.211 44.928 -18.744 45.51 -20.235C45.782 -20.935 45.809 -21.89 45.496 -22.55C44.322 -25.031 43.62 -27.48 42.178 -29.906C41.91 -30.356 41.648 -31.15 41.447 -31.748C40.984 -33.132 39.727 -34.123 38.867 -35.443C38.579 -35.884 39.104 -36.809 38.388 -36.893C37.491 -36.998 36.042 -37.578 35.809 -36.552C35.221 -33.965 36.232 -31.442 37.2 -29C36.418 -28.308 36.752 -27.387 36.904 -26.62C37.614 -23.014 36.416 -19.662 35.655 -16.188C35.632 -16.084 35.974 -15.886 35.946 -15.824C34.724 -13.138 33.272 -10.693 31.453 -8.312C30.695 -7.32 29.823 -6.404 29.326 -5.341C28.958 -4.554 28.55 -3.588 28.8 -2.6C25.365 0.18 23.115 4.025 20.504 7.871C20.042 8.551 20.333 9.76 20.884 10.029C21.697 10.427 22.653 9.403 23.123 8.557C23.512 7.859 23.865 7.209 24.356 6.566C24.489 6.391 24.31 5.972 24.445 5.851C27.078 3.504 28.747 0.568 31.2 -1.8C33.15 -2.129 34.687 -3.127 36.435 -4.14C36.743 -4.319 37.267 -4.07 37.557 -4.265C39.31 -5.442 39.308 -7.478 39.414 -9.388C39.464 -10.272 39.66 -11.589 40.8 -12.2z"} - , - {"fill": "#000000", - "path":"M31.959 -16.666C32.083 -16.743 31.928 -17.166 32.037 -17.382C32.199 -17.706 32.602 -17.894 32.764 -18.218C32.873 -18.434 32.71 -18.814 32.846 -18.956C35.179 -21.403 35.436 -24.427 34.4 -27.4C35.424 -28.02 35.485 -29.282 35.06 -30.129C34.207 -31.829 34.014 -33.755 33.039 -35.298C32.237 -36.567 30.659 -37.811 29.288 -36.508C28.867 -36.108 28.546 -35.321 28.824 -34.609C28.888 -34.446 29.173 -34.3 29.146 -34.218C29.039 -33.894 28.493 -33.67 28.487 -33.398C28.457 -31.902 27.503 -30.391 28.133 -29.062C28.905 -27.433 29.724 -25.576 30.4 -23.8C29.166 -21.684 30.199 -19.235 28.446 -17.358C28.31 -17.212 28.319 -16.826 28.441 -16.624C28.733 -16.138 29.139 -15.732 29.625 -15.44C29.827 -15.319 30.175 -15.317 30.375 -15.441C30.953 -15.803 31.351 -16.29 31.959 -16.666z"} - , - {"fill": "#000000", - "path":"M94.771 -26.977C96.16 -25.185 96.45 -22.39 94.401 -21C94.951 -17.691 98.302 -19.67 100.401 -20.2C100.292 -20.588 100.519 -20.932 100.802 -20.937C101.859 -20.952 102.539 -21.984 103.601 -21.8C104.035 -23.357 105.673 -24.059 106.317 -25.439C108.043 -29.134 107.452 -33.407 104.868 -36.653C104.666 -36.907 104.883 -37.424 104.759 -37.786C104.003 -39.997 101.935 -40.312 100.001 -41C98.824 -44.875 98.163 -48.906 96.401 -52.6C94.787 -52.85 94.089 -54.589 92.752 -55.309C91.419 -56.028 90.851 -54.449 90.892 -53.403C90.899 -53.198 91.351 -52.974 91.181 -52.609C91.105 -52.445 90.845 -52.334 90.845 -52.2C90.846 -52.065 91.067 -51.934 91.201 -51.8C90.283 -50.98 88.86 -50.503 88.565 -49.358C87.611 -45.648 90.184 -42.523 91.852 -39.322C92.443 -38.187 91.707 -36.916 90.947 -35.708C90.509 -35.013 90.617 -33.886 90.893 -33.03C91.645 -30.699 93.236 -28.96 94.771 -26.977z"} - , - {"fill": "#000000", - "path":"M57.611 -8.591C56.124 -6.74 52.712 -4.171 55.629 -2.243C55.823 -2.114 56.193 -2.11 56.366 -2.244C58.387 -3.809 60.39 -4.712 62.826 -5.294C62.95 -5.323 63.224 -4.856 63.593 -5.017C65.206 -5.72 67.216 -5.662 68.4 -7C72.167 -6.776 75.732 -7.892 79.123 -9.2C80.284 -9.648 81.554 -10.207 82.755 -10.709C84.131 -11.285 85.335 -12.213 86.447 -13.354C86.58 -13.49 86.934 -13.4 87.201 -13.4C87.161 -14.263 88.123 -14.39 88.37 -15.012C88.462 -15.244 88.312 -15.64 88.445 -15.742C90.583 -17.372 91.503 -19.39 90.334 -21.767C90.049 -22.345 89.8 -22.963 89.234 -23.439C88.149 -24.35 87.047 -23.496 86 -23.8C85.841 -23.172 85.112 -23.344 84.726 -23.146C83.867 -22.707 82.534 -23.292 81.675 -22.854C80.313 -22.159 79.072 -21.99 77.65 -21.613C77.338 -21.531 76.56 -21.627 76.4 -21C76.266 -21.134 76.118 -21.368 76.012 -21.346C74.104 -20.95 72.844 -20.736 71.543 -19.044C71.44 -18.911 70.998 -19.09 70.839 -18.955C69.882 -18.147 69.477 -16.913 68.376 -16.241C68.175 -16.118 67.823 -16.286 67.629 -16.157C66.983 -15.726 66.616 -15.085 65.974 -14.638C65.645 -14.409 65.245 -14.734 65.277 -14.99C65.522 -16.937 66.175 -18.724 65.6 -20.6C67.677 -23.12 70.194 -25.069 72 -27.8C72.015 -29.966 72.707 -32.112 72.594 -34.189C72.584 -34.382 72.296 -35.115 72.17 -35.462C71.858 -36.316 72.764 -37.382 71.92 -38.106C70.516 -39.309 69.224 -38.433 68.4 -37C66.562 -36.61 64.496 -35.917 62.918 -37.151C61.911 -37.938 61.333 -38.844 60.534 -39.9C59.549 -41.202 59.884 -42.638 59.954 -44.202C59.96 -44.33 59.645 -44.466 59.645 -44.6C59.646 -44.735 59.866 -44.866 60 -45C59.294 -45.626 59.019 -46.684 58 -47C58.305 -48.092 57.629 -48.976 56.758 -49.278C54.763 -49.969 53.086 -48.057 51.194 -47.984C50.68 -47.965 50.213 -49.003 49.564 -49.328C49.132 -49.544 48.428 -49.577 48.066 -49.311C47.378 -48.807 46.789 -48.693 46.031 -48.488C44.414 -48.052 43.136 -46.958 41.656 -46.103C40.171 -45.246 39.216 -43.809 38.136 -42.489C37.195 -41.337 37.059 -38.923 38.479 -38.423C40.322 -37.773 41.626 -40.476 43.592 -40.15C43.904 -40.099 44.11 -39.788 44 -39.4C44.389 -39.291 44.607 -39.52 44.8 -39.8C45.658 -38.781 46.822 -38.444 47.76 -37.571C48.73 -36.667 50.476 -37.085 51.491 -36.088C53.02 -34.586 52.461 -31.905 54.4 -30.6C53.814 -29.287 53.207 -28.01 52.872 -26.583C52.59 -25.377 53.584 -24.18 54.795 -24.271C56.053 -24.365 56.315 -25.124 56.8 -26.2C57.067 -25.933 57.536 -25.636 57.495 -25.42C57.038 -23.033 56.011 -21.04 55.553 -18.609C55.494 -18.292 55.189 -18.09 54.8 -18.2C54.332 -14.051 50.28 -11.657 47.735 -8.492C47.332 -7.99 47.328 -6.741 47.737 -6.338C49.14 -4.951 51.1 -6.497 52.8 -7C53.013 -8.206 53.872 -9.148 55.204 -9.092C55.46 -9.082 55.695 -9.624 56.019 -9.754C56.367 -9.892 56.869 -9.668 57.155 -9.866C58.884 -11.061 60.292 -12.167 62.03 -13.356C62.222 -13.487 62.566 -13.328 62.782 -13.436C63.107 -13.598 63.294 -13.985 63.617 -14.17C63.965 -14.37 64.207 -14.08 64.4 -13.8C63.754 -13.451 63.75 -12.494 63.168 -12.292C62.393 -12.024 61.832 -11.511 61.158 -11.064C60.866 -10.871 60.207 -11.119 60.103 -10.94C59.505 -9.912 58.321 -9.474 57.611 -8.591z"} - , - {"fill": "#000000", - "path":"M2.2 -58C2.2 -58 -7.038 -60.872 -18.2 -35.2C-18.2 -35.2 -20.6 -30 -23 -28C-25.4 -26 -36.6 -22.4 -38.6 -18.4L-49 -2.4C-49 -2.4 -34.2 -18.4 -31 -20.8C-31 -20.8 -23 -29.2 -26.2 -22.4C-26.2 -22.4 -40.2 -11.6 -39 -2.4C-39 -2.4 -44.6 12 -45.4 14C-45.4 14 -29.4 -18 -27 -19.2C-24.6 -20.4 -23.4 -20.4 -24.6 -16.8C-25.8 -13.2 -26.2 3.2 -29 5.2C-29 5.2 -21 -15.2 -21.8 -18.4C-21.8 -18.4 -18.6 -22 -16.2 -16.8L-17.4 -0.8L-13 11.2C-13 11.2 -15.4 0 -13.8 -15.6C-13.8 -15.6 -15.8 -26 -11.8 -20.4C-7.8 -14.8 1.8 -8.8 1.8 -4C1.8 -4 -3.4 -21.6 -12.6 -26.4L-16.6 -20.4L-17.8 -22.4C-17.8 -22.4 -21.4 -23.2 -17 -30C-12.6 -36.8 -13 -37.6 -13 -37.6C-13 -37.6 -6.6 -30.4 -5 -30.4C-5 -30.4 8.2 -38 9.4 -13.6C9.4 -13.6 16.2 -28 7 -34.8C7 -34.8 -7.8 -36.8 -6.6 -42L0.6 -54.4C4.2 -59.6 2.6 -56.8 2.6 -56.8z"} - , - {"fill": "#000000", - "path":"M-17.8 -41.6C-17.8 -41.6 -30.6 -41.6 -33.8 -36.4L-41 -26.8C-41 -26.8 -23.8 -36.8 -19.8 -38C-15.8 -39.2 -17.8 -41.6 -17.8 -41.6z"} - , - {"fill": "#000000", - "path":"M-57.8 -35.2C-57.8 -35.2 -59.8 -34 -60.2 -31.2C-60.6 -28.4 -63 -28 -62.2 -25.2C-61.4 -22.4 -59.4 -20 -59.4 -24C-59.4 -28 -57.8 -30 -57 -31.2C-56.2 -32.4 -54.6 -36.8 -57.8 -35.2z"} - , - {"fill": "#000000", - "path":"M-66.6 26C-66.6 26 -75 22 -78.2 18.4C-81.4 14.8 -80.948 19.966 -85.8 19.6C-91.647 19.159 -90.6 3.2 -90.6 3.2L-94.6 10.8C-94.6 10.8 -95.8 25.2 -87.8 22.8C-83.893 21.628 -82.6 23.2 -84.2 24C-85.8 24.8 -78.6 25.2 -81.4 26.8C-84.2 28.4 -69.8 23.2 -72.2 33.6L-66.6 26z"} - , - {"fill": "#000000", - "path":"M-79.2 40.4C-79.2 40.4 -94.6 44.8 -98.2 35.2C-98.2 35.2 -103 37.6 -100.8 40.6C-98.6 43.6 -97.4 44 -97.4 44C-97.4 44 -92 45.2 -92.6 46C-93.2 46.8 -95.6 50.2 -95.6 50.2C-95.6 50.2 -85.4 44.2 -79.2 40.4z"} - , - {"fill": "#ffffff", - "path":"M149.201 118.601C148.774 120.735 147.103 121.536 145.201 122.201C143.284 121.243 140.686 118.137 138.801 120.201C138.327 119.721 137.548 119.661 137.204 118.999C136.739 118.101 137.011 117.055 136.669 116.257C136.124 114.985 135.415 113.619 135.601 112.201C137.407 111.489 138.002 109.583 137.528 107.82C137.459 107.563 137.03 107.366 137.23 107.017C137.416 106.694 137.734 106.467 138.001 106.2C137.866 106.335 137.721 106.568 137.61 106.548C137 106.442 137.124 105.805 137.254 105.418C137.839 103.672 139.853 103.408 141.201 104.6C141.457 104.035 141.966 104.229 142.401 104.2C142.351 103.621 142.759 103.094 142.957 102.674C143.475 101.576 145.104 102.682 145.901 102.07C146.977 101.245 148.04 100.546 149.118 101.149C150.927 102.162 152.636 103.374 153.835 105.115C154.41 105.949 154.65 107.23 154.592 108.188C154.554 108.835 153.173 108.483 152.83 109.412C152.185 111.16 154.016 111.679 154.772 113.017C154.97 113.366 154.706 113.67 154.391 113.768C153.98 113.896 153.196 113.707 153.334 114.16C154.306 117.353 151.55 118.031 149.201 118.601z"} - , - {"fill": "#ffffff", - "path":"M139.6 138.201C139.593 136.463 137.992 134.707 139.201 133.001C139.336 133.135 139.467 133.356 139.601 133.356C139.736 133.356 139.867 133.135 140.001 133.001C141.496 135.217 145.148 136.145 145.006 138.991C144.984 139.438 143.897 140.356 144.801 141.001C142.988 142.349 142.933 144.719 142.001 146.601C140.763 146.315 139.551 145.952 138.401 145.401C138.753 143.915 138.636 142.231 139.456 140.911C139.89 140.213 139.603 139.134 139.6 138.201z"} - , - {"fill": "#cccccc", - "path":"M-26.6 129.201C-26.6 129.201 -43.458 139.337 -29.4 124.001C-20.6 114.401 -10.6 108.801 -10.6 108.801C-10.6 108.801 -0.2 104.4 3.4 103.2C7 102 22.2 96.8 25.4 96.4C28.6 96 38.2 92 45 96C51.8 100 59.8 104.4 59.8 104.4C59.8 104.4 43.4 96 39.8 98.4C36.2 100.8 29 100.4 23 103.6C23 103.6 8.2 108.001 5 110.001C1.8 112.001 -8.6 123.601 -10.2 122.801C-11.8 122.001 -9.8 121.601 -8.6 118.801C-7.4 116.001 -9.4 114.401 -17.4 120.801C-25.4 127.201 -26.6 129.201 -26.6 129.201z"} - , - {"fill": "#000000", - "path":"M-19.195 123.234C-19.195 123.234 -17.785 110.194 -9.307 111.859C-9.307 111.859 -1.081 107.689 1.641 105.721C1.641 105.721 9.78 104.019 11.09 103.402C29.569 94.702 44.288 99.221 44.835 98.101C45.381 96.982 65.006 104.099 68.615 108.185C69.006 108.628 58.384 102.588 48.686 100.697C40.413 99.083 18.811 100.944 7.905 106.48C4.932 107.989 -4.013 113.773 -6.544 113.662C-9.075 113.55 -19.195 123.234 -19.195 123.234z"} - , - {"fill": "#cccccc", - "path":"M-23 148.801C-23 148.801 -38.2 146.401 -21.4 144.801C-21.4 144.801 -3.4 142.801 0.6 137.601C0.6 137.601 14.2 128.401 17 128.001C19.8 127.601 49.8 120.401 50.2 118.001C50.6 115.601 56.2 115.601 57.8 116.401C59.4 117.201 58.6 118.401 55.8 119.201C53 120.001 21.8 136.401 15.4 137.601C9 138.801 -2.6 146.401 -7.4 147.601C-12.2 148.801 -23 148.801 -23 148.801z"} - , - {"fill": "#000000", - "path":"M-3.48 141.403C-3.48 141.403 -12.062 140.574 -3.461 139.755C-3.461 139.755 5.355 136.331 7.403 133.668C7.403 133.668 14.367 128.957 15.8 128.753C17.234 128.548 31.194 124.861 31.399 123.633C31.604 122.404 65.67 109.823 70.09 113.013C73.001 115.114 63.1 113.437 53.466 117.847C52.111 118.467 18.258 133.054 14.981 133.668C11.704 134.283 5.765 138.174 3.307 138.788C0.85 139.403 -3.48 141.403 -3.48 141.403z"} - , - {"fill": "#000000", - "path":"M-11.4 143.601C-11.4 143.601 -6.2 143.201 -7.4 144.801C-8.6 146.401 -11 145.601 -11 145.601L-11.4 143.601z"} - , - {"fill": "#000000", - "path":"M-18.6 145.201C-18.6 145.201 -13.4 144.801 -14.6 146.401C-15.8 148.001 -18.2 147.201 -18.2 147.201L-18.6 145.201z"} - , - {"fill": "#000000", - "path":"M-29 146.801C-29 146.801 -23.8 146.401 -25 148.001C-26.2 149.601 -28.6 148.801 -28.6 148.801L-29 146.801z"} - , - {"fill": "#000000", - "path":"M-36.6 147.601C-36.6 147.601 -31.4 147.201 -32.6 148.801C-33.8 150.401 -36.2 149.601 -36.2 149.601L-36.6 147.601z"} - , - {"fill": "#000000", - "path":"M1.8 108.001C1.8 108.001 6.2 108.001 5 109.601C3.8 111.201 0.6 110.801 0.6 110.801L1.8 108.001z"} - , - {"fill": "#000000", - "path":"M-8.2 113.601C-8.2 113.601 -1.694 111.46 -4.2 114.801C-5.4 116.401 -7.8 115.601 -7.8 115.601L-8.2 113.601z"} - , - {"fill": "#000000", - "path":"M-19.4 118.401C-19.4 118.401 -14.2 118.001 -15.4 119.601C-16.6 121.201 -19 120.401 -19 120.401L-19.4 118.401z"} - , - {"fill": "#000000", - "path":"M-27 124.401C-27 124.401 -21.8 124.001 -23 125.601C-24.2 127.201 -26.6 126.401 -26.6 126.401L-27 124.401z"} - , - {"fill": "#000000", - "path":"M-33.8 129.201C-33.8 129.201 -28.6 128.801 -29.8 130.401C-31 132.001 -33.4 131.201 -33.4 131.201L-33.8 129.201z"} - , - {"fill": "#000000", - "path":"M5.282 135.598C5.282 135.598 12.203 135.066 10.606 137.195C9.009 139.325 5.814 138.26 5.814 138.26L5.282 135.598z"} - , - {"fill": "#000000", - "path":"M15.682 130.798C15.682 130.798 22.603 130.266 21.006 132.395C19.409 134.525 16.214 133.46 16.214 133.46L15.682 130.798z"} - , - {"fill": "#000000", - "path":"M26.482 126.398C26.482 126.398 33.403 125.866 31.806 127.995C30.209 130.125 27.014 129.06 27.014 129.06L26.482 126.398z"} - , - {"fill": "#000000", - "path":"M36.882 121.598C36.882 121.598 43.803 121.066 42.206 123.195C40.609 125.325 37.414 124.26 37.414 124.26L36.882 121.598z"} - , - {"fill": "#000000", - "path":"M9.282 103.598C9.282 103.598 16.203 103.066 14.606 105.195C13.009 107.325 9.014 107.06 9.014 107.06L9.282 103.598z"} - , - {"fill": "#000000", - "path":"M19.282 100.398C19.282 100.398 26.203 99.866 24.606 101.995C23.009 104.125 18.614 103.86 18.614 103.86L19.282 100.398z"} - , - {"fill": "#000000", - "path":"M-3.4 140.401C-3.4 140.401 1.8 140.001 0.6 141.601C-0.6 143.201 -3 142.401 -3 142.401L-3.4 140.401z"} - , - {"fill": "#992600", - "path":"M-76.6 41.2C-76.6 41.2 -81 50 -81.4 53.2C-81.4 53.2 -80.6 44.4 -79.4 42.4C-78.2 40.4 -76.6 41.2 -76.6 41.2z"} - , - {"fill": "#992600", - "path":"M-95 55.2C-95 55.2 -98.2 69.6 -97.8 72.4C-97.8 72.4 -99 60.8 -98.6 59.6C-98.2 58.4 -95 55.2 -95 55.2z"} - , - {"fill": "#cccccc", - "path":"M-74.2 -19.4L-74.4 -16.2L-76.6 -16C-76.6 -16 -62.4 -3.4 -61.8 4.2C-61.8 4.2 -61 -4 -74.2 -19.4z"} - , - {"fill": "#000000", - "path":"M-70.216 -18.135C-70.647 -18.551 -70.428 -19.296 -70.836 -19.556C-71.645 -20.072 -69.538 -20.129 -69.766 -20.845C-70.149 -22.051 -69.962 -22.072 -70.084 -23.348C-70.141 -23.946 -69.553 -25.486 -69.168 -25.926C-67.722 -27.578 -69.046 -30.51 -67.406 -32.061C-67.102 -32.35 -66.726 -32.902 -66.441 -33.32C-65.782 -34.283 -64.598 -34.771 -63.648 -35.599C-63.33 -35.875 -63.531 -36.702 -62.962 -36.61C-62.248 -36.495 -61.007 -36.625 -61.052 -35.784C-61.165 -33.664 -62.494 -31.944 -63.774 -30.276C-63.323 -29.572 -63.781 -28.937 -64.065 -28.38C-65.4 -25.76 -65.211 -22.919 -65.385 -20.079C-65.39 -19.994 -65.697 -19.916 -65.689 -19.863C-65.336 -17.528 -64.752 -15.329 -63.873 -13.1C-63.507 -12.17 -63.036 -11.275 -62.886 -10.348C-62.775 -9.662 -62.672 -8.829 -63.08 -8.124C-61.045 -5.234 -62.354 -2.583 -61.185 0.948C-60.978 1.573 -59.286 3.487 -59.749 3.326C-62.262 2.455 -62.374 2.057 -62.551 1.304C-62.697 0.681 -63.027 -0.696 -63.264 -1.298C-63.328 -1.462 -63.499 -3.346 -63.577 -3.468C-65.09 -5.85 -63.732 -5.674 -65.102 -8.032C-66.53 -8.712 -67.496 -9.816 -68.619 -10.978C-68.817 -11.182 -67.674 -11.906 -67.855 -12.119C-68.947 -13.408 -70.1 -14.175 -69.764 -15.668C-69.609 -16.358 -69.472 -17.415 -70.216 -18.135z"} - , - {"fill": "#000000", - "path":"M-73.8 -16.4C-73.8 -16.4 -73.4 -9.6 -71 -8C-68.6 -6.4 -69.8 -7.2 -73 -8.4C-76.2 -9.6 -75 -10.4 -75 -10.4C-75 -10.4 -77.8 -10 -75.4 -8C-73 -6 -69.4 -3.6 -71 -3.6C-72.6 -3.6 -80.2 -7.6 -80.2 -10.4C-80.2 -13.2 -81.2 -17.3 -81.2 -17.3C-81.2 -17.3 -80.1 -18.1 -75.3 -18C-75.3 -18 -73.9 -17.3 -73.8 -16.4z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-74.6 2.2C-74.6 2.2 -83.12 -0.591 -101.6 2.8C-101.6 2.8 -92.569 0.722 -73.8 3C-63.5 4.25 -74.6 2.2 -74.6 2.2z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-72.502 2.129C-72.502 2.129 -80.748 -1.389 -99.453 0.392C-99.453 0.392 -90.275 -0.897 -71.774 2.995C-61.62 5.131 -72.502 2.129 -72.502 2.129z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-70.714 2.222C-70.714 2.222 -78.676 -1.899 -97.461 -1.514C-97.461 -1.514 -88.213 -2.118 -70.052 3.14C-60.086 6.025 -70.714 2.222 -70.714 2.222z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-69.444 2.445C-69.444 2.445 -76.268 -1.862 -93.142 -2.96C-93.142 -2.96 -84.803 -2.79 -68.922 3.319C-60.206 6.672 -69.444 2.445 -69.444 2.445z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M45.84 12.961C45.84 12.961 44.91 13.605 45.124 12.424C45.339 11.243 73.547 -1.927 77.161 -1.677C77.161 -1.677 46.913 11.529 45.84 12.961z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M42.446 13.6C42.446 13.6 41.57 14.315 41.691 13.121C41.812 11.927 68.899 -3.418 72.521 -3.452C72.521 -3.452 43.404 12.089 42.446 13.6z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M39.16 14.975C39.16 14.975 38.332 15.747 38.374 14.547C38.416 13.348 58.233 -2.149 68.045 -4.023C68.045 -4.023 50.015 4.104 39.16 14.975z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M36.284 16.838C36.284 16.838 35.539 17.532 35.577 16.453C35.615 15.373 53.449 1.426 62.28 -0.26C62.28 -0.26 46.054 7.054 36.284 16.838z"} - , - {"fill": "#cccccc", - "path":"M4.6 164.801C4.6 164.801 -10.6 162.401 6.2 160.801C6.2 160.801 24.2 158.801 28.2 153.601C28.2 153.601 41.8 144.401 44.6 144.001C47.4 143.601 63.8 140.001 64.2 137.601C64.6 135.201 70.6 132.801 72.2 133.601C73.8 134.401 73.8 143.601 71 144.401C68.2 145.201 49.4 152.401 43 153.601C36.6 154.801 25 162.401 20.2 163.601C15.4 164.801 4.6 164.801 4.6 164.801z"} - , - {"fill": "#000000", - "path":"M77.6 127.401C77.6 127.401 74.6 129.001 73.4 131.601C73.4 131.601 67 142.201 52.8 145.401C52.8 145.401 29.8 154.401 22 156.401C22 156.401 8.6 161.401 1.2 160.601C1.2 160.601 -5.8 160.801 0.4 162.401C0.4 162.401 20.6 160.401 24 158.601C24 158.601 39.6 153.401 42.6 150.801C45.6 148.201 63.8 143.201 66 141.201C68.2 139.201 78 130.801 77.6 127.401z"} - , - {"fill": "#000000", - "path":"M18.882 158.911C18.882 158.911 24.111 158.685 22.958 160.234C21.805 161.784 19.357 160.91 19.357 160.91L18.882 158.911z"} - , - {"fill": "#000000", - "path":"M11.68 160.263C11.68 160.263 16.908 160.037 15.756 161.586C14.603 163.136 12.155 162.263 12.155 162.263L11.68 160.263z"} - , - {"fill": "#000000", - "path":"M1.251 161.511C1.251 161.511 6.48 161.284 5.327 162.834C4.174 164.383 1.726 163.51 1.726 163.51L1.251 161.511z"} - , - {"fill": "#000000", - "path":"M-6.383 162.055C-6.383 162.055 -1.154 161.829 -2.307 163.378C-3.46 164.928 -5.908 164.054 -5.908 164.054L-6.383 162.055z"} - , - {"fill": "#000000", - "path":"M35.415 151.513C35.415 151.513 42.375 151.212 40.84 153.274C39.306 155.336 36.047 154.174 36.047 154.174L35.415 151.513z"} - , - {"fill": "#000000", - "path":"M45.73 147.088C45.73 147.088 51.689 143.787 51.155 148.849C50.885 151.405 46.362 149.749 46.362 149.749L45.73 147.088z"} - , - {"fill": "#000000", - "path":"M54.862 144.274C54.862 144.274 62.021 140.573 60.287 146.035C59.509 148.485 55.493 146.935 55.493 146.935L54.862 144.274z"} - , - {"fill": "#000000", - "path":"M64.376 139.449C64.376 139.449 68.735 134.548 69.801 141.21C70.207 143.748 65.008 142.11 65.008 142.11L64.376 139.449z"} - , - {"fill": "#000000", - "path":"M26.834 155.997C26.834 155.997 32.062 155.77 30.91 157.32C29.757 158.869 27.308 157.996 27.308 157.996L26.834 155.997z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M62.434 34.603C62.434 34.603 61.708 35.268 61.707 34.197C61.707 33.127 79.191 19.863 88.034 18.479C88.034 18.479 71.935 25.208 62.434 34.603z"} - , - {"fill": "#000000", - "path":"M65.4 98.4C65.4 98.4 87.401 120.801 96.601 124.401C96.601 124.401 105.801 135.601 101.801 161.601C101.801 161.601 98.601 169.201 95.401 148.401C95.401 148.401 98.601 123.201 87.401 139.201C87.401 139.201 79 129.301 85.4 129.601C85.4 129.601 88.601 131.601 89.001 130.001C89.401 128.401 81.4 114.801 64.2 100.4C47 86 65.4 98.4 65.4 98.4z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M7 137.201C7 137.201 6.8 135.401 8.6 136.201C10.4 137.001 104.601 143.201 136.201 167.201C136.201 167.201 91.001 144.001 7 137.201z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M17.4 132.801C17.4 132.801 17.2 131.001 19 131.801C20.8 132.601 157.401 131.601 181.001 164.001C181.001 164.001 159.001 138.801 17.4 132.801z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M29 128.801C29 128.801 28.8 127.001 30.6 127.801C32.4 128.601 205.801 115.601 229.401 148.001C229.401 148.001 219.801 122.401 29 128.801z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M39 124.001C39 124.001 38.8 122.201 40.6 123.001C42.4 123.801 164.601 85.2 188.201 117.601C188.201 117.601 174.801 93 39 124.001z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-19 146.801C-19 146.801 -19.2 145.001 -17.4 145.801C-15.6 146.601 2.2 148.801 4.2 187.601C4.2 187.601 -3 145.601 -19 146.801z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-27.8 148.401C-27.8 148.401 -28 146.601 -26.2 147.401C-24.4 148.201 -10.2 143.601 -13 182.401C-13 182.401 -11.8 147.201 -27.8 148.401z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-35.8 148.801C-35.8 148.801 -36 147.001 -34.2 147.801C-32.4 148.601 -17 149.201 -29.4 171.601C-29.4 171.601 -19.8 147.601 -35.8 148.801z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M11.526 104.465C11.526 104.465 11.082 106.464 12.631 105.247C28.699 92.622 61.141 33.72 116.826 28.086C116.826 28.086 78.518 15.976 11.526 104.465z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M22.726 102.665C22.726 102.665 21.363 101.472 23.231 100.847C25.099 100.222 137.541 27.72 176.826 35.686C176.826 35.686 149.719 28.176 22.726 102.665z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M1.885 108.767C1.885 108.767 1.376 110.366 3.087 109.39C12.062 104.27 15.677 47.059 59.254 45.804C59.254 45.804 26.843 31.09 1.885 108.767z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-18.038 119.793C-18.038 119.793 -19.115 121.079 -17.162 120.825C-6.916 119.493 14.489 78.222 58.928 83.301C58.928 83.301 26.962 68.955 -18.038 119.793z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-6.8 113.667C-6.8 113.667 -7.611 115.136 -5.742 114.511C4.057 111.237 17.141 66.625 61.729 63.078C61.729 63.078 27.603 55.135 -6.8 113.667z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-25.078 124.912C-25.078 124.912 -25.951 125.954 -24.369 125.748C-16.07 124.669 1.268 91.24 37.264 95.354C37.264 95.354 11.371 83.734 -25.078 124.912z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-32.677 130.821C-32.677 130.821 -33.682 131.866 -32.091 131.748C-27.923 131.439 2.715 98.36 21.183 113.862C21.183 113.862 9.168 95.139 -32.677 130.821z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M36.855 98.898C36.855 98.898 35.654 97.543 37.586 97.158C39.518 96.774 160.221 39.061 198.184 51.927C198.184 51.927 172.243 41.053 36.855 98.898z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M3.4 163.201C3.4 163.201 3.2 161.401 5 162.201C6.8 163.001 22.2 163.601 9.8 186.001C9.8 186.001 19.4 162.001 3.4 163.201z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M13.8 161.601C13.8 161.601 13.6 159.801 15.4 160.601C17.2 161.401 35 163.601 37 202.401C37 202.401 29.8 160.401 13.8 161.601z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M20.6 160.001C20.6 160.001 20.4 158.201 22.2 159.001C24 159.801 48.6 163.201 72.2 195.601C72.2 195.601 36.6 158.801 20.6 160.001z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M28.225 157.972C28.225 157.972 27.788 156.214 29.678 156.768C31.568 157.322 52.002 155.423 90.099 189.599C90.099 189.599 43.924 154.656 28.225 157.972z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M38.625 153.572C38.625 153.572 38.188 151.814 40.078 152.368C41.968 152.922 76.802 157.423 128.499 192.399C128.499 192.399 54.324 150.256 38.625 153.572z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-1.8 142.001C-1.8 142.001 -2 140.201 -0.2 141.001C1.6 141.801 55 144.401 85.4 171.201C85.4 171.201 50.499 146.426 -1.8 142.001z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M-11.8 146.001C-11.8 146.001 -12 144.201 -10.2 145.001C-8.4 145.801 16.2 149.201 39.8 181.601C39.8 181.601 4.2 144.801 -11.8 146.001z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M49.503 148.962C49.503 148.962 48.938 147.241 50.864 147.655C52.79 148.068 87.86 150.004 141.981 181.098C141.981 181.098 64.317 146.704 49.503 148.962z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M57.903 146.562C57.903 146.562 57.338 144.841 59.264 145.255C61.19 145.668 96.26 147.604 150.381 178.698C150.381 178.698 73.317 143.904 57.903 146.562z"} - , - {"fill": "#ffffff", "stroke":"#000000", "width":0.1, - "path":"M67.503 141.562C67.503 141.562 66.938 139.841 68.864 140.255C70.79 140.668 113.86 145.004 203.582 179.298C203.582 179.298 82.917 138.904 67.503 141.562z"} - , - {"fill": "#000000", - "path":"M-43.8 148.401C-43.8 148.401 -38.6 148.001 -39.8 149.601C-41 151.201 -43.4 150.401 -43.4 150.401L-43.8 148.401z"} - , - {"fill": "#000000", - "path":"M-13 162.401C-13 162.401 -7.8 162.001 -9 163.601C-10.2 165.201 -12.6 164.401 -12.6 164.401L-13 162.401z"} - , - {"fill": "#000000", - "path":"M-21.8 162.001C-21.8 162.001 -16.6 161.601 -17.8 163.201C-19 164.801 -21.4 164.001 -21.4 164.001L-21.8 162.001z"} - , - {"fill": "#000000", - "path":"M-117.169 150.182C-117.169 150.182 -112.124 151.505 -113.782 152.624C-115.439 153.744 -117.446 152.202 -117.446 152.202L-117.169 150.182z"} - , - {"fill": "#000000", - "path":"M-115.169 140.582C-115.169 140.582 -110.124 141.905 -111.782 143.024C-113.439 144.144 -115.446 142.602 -115.446 142.602L-115.169 140.582z"} - , - {"fill": "#000000", - "path":"M-122.369 136.182C-122.369 136.182 -117.324 137.505 -118.982 138.624C-120.639 139.744 -122.646 138.202 -122.646 138.202L-122.369 136.182z"} - , - {"fill": "#cccccc", - "path":"M-42.6 211.201C-42.6 211.201 -44.2 211.201 -48.2 213.201C-50.2 213.201 -61.4 216.801 -67 226.801C-67 226.801 -54.6 217.201 -42.6 211.201z"} - , - {"fill": "#cccccc", - "path":"M45.116 303.847C45.257 304.105 45.312 304.525 45.604 304.542C46.262 304.582 47.495 304.883 47.37 304.247C46.522 299.941 45.648 295.004 41.515 293.197C40.876 292.918 39.434 293.331 39.36 294.215C39.233 295.739 39.116 297.088 39.425 298.554C39.725 299.975 41.883 299.985 42.8 298.601C43.736 300.273 44.168 302.116 45.116 303.847z"} - , - {"fill": "#cccccc", - "path":"M34.038 308.581C34.786 309.994 34.659 311.853 36.074 312.416C36.814 312.71 38.664 311.735 38.246 310.661C37.444 308.6 37.056 306.361 35.667 304.55C35.467 304.288 35.707 303.755 35.547 303.427C34.953 302.207 33.808 301.472 32.4 301.801C31.285 304.004 32.433 306.133 33.955 307.842C34.091 307.994 33.925 308.37 34.038 308.581z"} - , - {"fill": "#cccccc", - "path":"M-5.564 303.391C-5.672 303.014 -5.71 302.551 -5.545 302.23C-5.014 301.197 -4.221 300.075 -4.558 299.053C-4.906 297.997 -6.022 298.179 -6.672 298.748C-7.807 299.742 -7.856 301.568 -8.547 302.927C-8.743 303.313 -8.692 303.886 -9.133 304.277C-9.607 304.698 -10.047 306.222 -9.951 306.793C-9.898 307.106 -10.081 317.014 -9.859 316.751C-9.24 316.018 -6.19 306.284 -6.121 305.392C-6.064 304.661 -5.332 304.196 -5.564 303.391z"} - , - {"fill": "#cccccc", - "path":"M-31.202 296.599C-28.568 294.1 -25.778 291.139 -26.22 287.427C-26.336 286.451 -28.111 286.978 -28.298 287.824C-29.1 291.449 -31.139 294.11 -33.707 296.502C-35.903 298.549 -37.765 304.893 -38 305.401C-34.303 300.145 -32.046 297.399 -31.202 296.599z"} - , - {"fill": "#cccccc", - "path":"M-44.776 290.635C-44.253 290.265 -44.555 289.774 -44.338 289.442C-43.385 287.984 -42.084 286.738 -42.066 285C-42.063 284.723 -42.441 284.414 -42.776 284.638C-43.053 284.822 -43.395 284.952 -43.503 285.082C-45.533 287.531 -46.933 290.202 -48.376 293.014C-48.559 293.371 -49.703 297.862 -49.39 297.973C-49.151 298.058 -47.431 293.877 -47.221 293.763C-45.958 293.077 -45.946 291.462 -44.776 290.635z"} - , - {"fill": "#cccccc", - "path":"M-28.043 310.179C-27.599 309.31 -26.023 308.108 -26.136 307.219C-26.254 306.291 -25.786 304.848 -26.698 305.536C-27.955 306.484 -31.404 307.833 -31.674 313.641C-31.7 314.212 -28.726 311.519 -28.043 310.179z"} - , - {"fill": "#cccccc", - "path":"M-13.6 293.001C-13.2 292.333 -12.492 292.806 -12.033 292.543C-11.385 292.171 -10.774 291.613 -10.482 290.964C-9.512 288.815 -7.743 286.995 -7.6 284.601C-9.091 283.196 -9.77 285.236 -10.4 286.201C-11.723 284.554 -12.722 286.428 -14.022 286.947C-14.092 286.975 -14.305 286.628 -14.38 286.655C-15.557 287.095 -16.237 288.176 -17.235 288.957C-17.406 289.091 -17.811 288.911 -17.958 289.047C-18.61 289.65 -19.583 289.975 -19.863 290.657C-20.973 293.364 -24.113 295.459 -26 303.001C-25.619 303.91 -21.488 296.359 -21.001 295.661C-20.165 294.465 -20.047 297.322 -18.771 296.656C-18.72 296.629 -18.534 296.867 -18.4 297.001C-18.206 296.721 -17.988 296.492 -17.6 296.601C-17.6 296.201 -17.734 295.645 -17.533 295.486C-16.296 294.509 -16.38 293.441 -15.6 292.201C-15.142 292.99 -14.081 292.271 -13.6 293.001z"} - , - {"fill": "#cccccc", - "path":"M46.2 347.401C46.2 347.401 53.6 327.001 49.2 315.801C49.2 315.801 60.6 337.401 56 348.601C56 348.601 55.6 338.201 51.6 333.201C51.6 333.201 47.6 346.001 46.2 347.401z"} - , - {"fill": "#cccccc", - "path":"M31.4 344.801C31.4 344.801 36.8 336.001 28.8 317.601C28.8 317.601 28 338.001 21.2 349.001C21.2 349.001 35.4 328.801 31.4 344.801z"} - , - {"fill": "#cccccc", - "path":"M21.4 342.801C21.4 342.801 21.2 322.801 21.6 319.801C21.6 319.801 17.8 336.401 7.6 346.001C7.6 346.001 22 334.001 21.4 342.801z"} - , - {"fill": "#cccccc", - "path":"M11.8 310.801C11.8 310.801 17.8 324.401 7.8 342.801C7.8 342.801 14.2 330.601 9.4 323.601C9.4 323.601 12 320.201 11.8 310.801z"} - , - {"fill": "#cccccc", - "path":"M-7.4 342.401C-7.4 342.401 -8.4 326.801 -6.6 324.601C-6.6 324.601 -6.4 318.201 -6.8 317.201C-6.8 317.201 -2.8 311.001 -2.6 318.401C-2.6 318.401 -1.2 326.201 1.6 330.801C1.6 330.801 5.2 336.201 5 342.601C5 342.601 -5 312.401 -7.4 342.401z"} - , - {"fill": "#cccccc", - "path":"M-11 314.801C-11 314.801 -17.6 325.601 -19.4 344.601C-19.4 344.601 -20.8 338.401 -17 324.001C-17 324.001 -12.8 308.601 -11 314.801z"} - , - {"fill": "#cccccc", - "path":"M-32.8 334.601C-32.8 334.601 -27.8 329.201 -26.4 324.201C-26.4 324.201 -22.8 308.401 -29.2 317.001C-29.2 317.001 -29 325.001 -37.2 332.401C-37.2 332.401 -32.4 330.001 -32.8 334.601z"} - , - {"fill": "#cccccc", - "path":"M-38.6 329.601C-38.6 329.601 -35.2 312.201 -34.4 311.401C-34.4 311.401 -32.6 308.001 -35.4 311.201C-35.4 311.201 -44.2 330.401 -48.2 337.001C-48.2 337.001 -40.2 327.801 -38.6 329.601z"} - , - {"fill": "#cccccc", - "path":"M-44.4 313.001C-44.4 313.001 -32.8 290.601 -54.6 316.401C-54.6 316.401 -43.6 306.601 -44.4 313.001z"} - , - {"fill": "#cccccc", - "path":"M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401z"} - , - {"fill": "#cccccc", - "path":"M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 287z"} - , - {"fill": "#cccccc", - "path":"M276 265C276 265 255 250 251.5 242.5C251.5 242.5 278 272 278 276.5C278 276.5 278.5 267.5 276 265z"} - , - {"fill": "#cccccc", - "path":"M293 111C293 111 281 103 279.5 105C279.5 105 290 111.5 292.5 120C292.5 120 291 111 293 111z"} - , - {"fill": "#cccccc", - "path":"M301.5 191.5L284 179.5C284 179.5 303 196.5 303.5 200.5L301.5 191.5z"} - , - {"stroke":"#000000", - "path":"M-89.25 169L-67.25 173.75"} - , - {"stroke":"#000000", - "path":"M-39 331C-39 331 -39.5 327.5 -48.5 338"} - , - {"stroke":"#000000", - "path":"M-33.5 336C-33.5 336 -31.5 329.5 -38 334"} - , - {"stroke":"#000000", - "path":"M20.5 344.5C20.5 344.5 22 333.5 10.5 346.5"} -]; \ No newline at end of file diff --git a/examples/declarative/canvas/tiger/tiger.qml b/examples/declarative/canvas/tiger/tiger.qml deleted file mode 100644 index 2eb1bb2106..0000000000 --- a/examples/declarative/canvas/tiger/tiger.qml +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../contents" -import "tiger.js" as Tiger -Item { - id:container - width:360 - height:600 - - Column { - spacing:5 - anchors.fill:parent - Text { font.pointSize:25; text:"Tiger with SVG path"; anchors.horizontalCenter:parent.horizontalCenter} - - Canvas { - id:canvas - width:360 - height:360 - smooth:true - renderTarget:Canvas.FramebufferObject - renderStrategy: Canvas.Cooperative - property string strokeStyle:"steelblue" - property string fillStyle:"yellow" - property bool fill:true - property bool stroke:true - property real alpha:alphaCtrl.value - property real scaleX : scaleXCtrl.value - property real scaleY : scaleYCtrl.value - property real rotate : rotateCtrl.value - property int frame:0 - - onFillChanged: requestPaint(); - onStrokeChanged: requestPaint(); - onAlphaChanged: requestPaint(); - onScaleXChanged: requestPaint(); - onScaleYChanged: requestPaint(); - onRotateChanged: requestPaint(); - - onPainted : { - canvas.frame++; - if (canvas.frame < Tiger.tiger.length) - requestPaint(); - } - onPaint: { - var ctx = canvas.getContext('2d'); - ctx.save(); - ctx.clearRect(0, 0, canvas.width, canvas.height); - ctx.globalAlpha = canvas.alpha; - ctx.scale(canvas.scaleX, canvas.scaleY); - ctx.rotate(canvas.rotate); - ctx.globalCompositeOperation = "source-over"; - ctx.translate(canvas.width/2, canvas.height/2); - ctx.strokeStyle = Qt.rgba(.3, .3, .3,1); - ctx.lineWidth = 1; - - - for (var i = 0; i < canvas.frame && i < Tiger.tiger.length; i++) { - if (Tiger.tiger[i].width != undefined) - ctx.lineWidth = Tiger.tiger[i].width; - - if (Tiger.tiger[i].path != undefined) - ctx.path = Tiger.tiger[i].path; - - if (Tiger.tiger[i].fill != undefined) { - ctx.fillStyle = Tiger.tiger[i].fill; - ctx.fill(); - } - - if (Tiger.tiger[i].stroke != undefined) { - ctx.strokeStyle = Tiger.tiger[i].stroke; - ctx.stroke(); - } - } - ctx.restore(); - } - } - Rectangle { - id:controls - width:360 - height:160 - Column { - spacing:3 - Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleX"} - Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleY"} - Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} - Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} - } - } - } -} diff --git a/examples/declarative/canvas/twitterfriends/TwitterUser.qml b/examples/declarative/canvas/twitterfriends/TwitterUser.qml deleted file mode 100644 index 8b906216ef..0000000000 --- a/examples/declarative/canvas/twitterfriends/TwitterUser.qml +++ /dev/null @@ -1,294 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id:twitterUser - property variant friends : []; - property string name : ""; - property string twitterId : ""; - property string image : ""; - property string url : ""; - property string desc : ""; - width : 0; - height : 0; - property int posX:0; - property int posY:0; - property bool hasFocus : false; - property variant canvas; - property variant manager; - property variant linkColor; - property bool selected : false; - - Rectangle { - id:twitterStatus - x:twitterUser.width - y:twitterUser.height - width:250 - height:60 - opacity: 0 - border.color:"steelblue" - border.width:3 - Column { - spacing:2 - Text {color:"steelblue"; font.pointSize:15; width:250; height:30; text:twitterUser.name; wrapMode: Text.WrapAnywhere} - Text {color:"steelblue"; font.pointSize:8; width:250; height:30; text:twitterUser.url; wrapMode: Text.WrapAnywhere} - } - } - - function moved() { - twitterUser.posX = twitterUser.x; - twitterUser.posY = twitterUser.y; - twitterUser.canvas.requestPaint(); - } - - onXChanged: moved(); - onYChanged: moved(); - - MouseArea { - anchors.fill:parent - drag.target : twitterUser - drag.axis : Drag.XandYAxis - - onClicked: { - if (!twitterUser.selected) { - twitterUser.selected = true; - twitterStatus.opacity = 1; - twitterStatus.visible = true; - } else { - twitterUser.selected = false; - twitterStatus.opacity = 0; - } - } - - onDoubleClicked : { - twitterStatus.opacity = 0; - twitterUser.selected = false; - twitterUser.hasFocus = true; - twitterUser.canvas.twitterName = twitterUser.name; - twitterUser.canvas.twitterId = twitterUser.twitterId; - twitterUser.canvas.loading = true; - twitterUser.createFriends(); - } - } - - function show(ctx, layoutChanged) { - var w = canvas.width; - var h = canvas.height; - if (twitterUser.hasFocus) { - twitterUser.width = 60 - twitterUser.height = 60 - twitterUser.posX = w/2; - twitterUser.posY = h/2; - } else { - twitterUser.width = 40 - twitterUser.height = 40 - } - - - if (twitterUser.hasFocus) { - if (layoutChanged) - twitterUser.layoutFriends(); - twitterUser.linkFriends(ctx); - twitterUser.showFriends(ctx); - ctx.shadowOffsetX = 5; - ctx.shadowOffsetY = 5; - ctx.shadowBlur = 7; - ctx.shadowColor = "blue"; - ctx.globalAlpha = 1; - } else { - ctx.shadowOffsetX = 5; - ctx.shadowOffsetY = 5; - ctx.shadowBlur = 7; - ctx.shadowColor = twitterUser.linkColor; - ctx.globalAlpha = 0.6; - } - - if (twitterUser.canvas.isImageLoaded(twitterUser.image)) { - ctx.drawImage(twitterUser.image, twitterUser.posX, twitterUser.posY, twitterUser.width, twitterUser.height); - } -// ctx.font = "15px"; -// var nameSize = ctx.measureText(twitterUser.name).width; -// ctx.fillText(twitterUser.name, twitterUser.posX + nameSize/2 - twitterUser.width/2, twitterUser.posY + twitterUser.height/2 + 10); - } - function dump() { - console.log("name:" + twitterUser.name - + " x:" + twitterUser.posX - + " y:" + twitterUser.posY - + " width:" + twitterUser.width - + " height:" + twitterUser.height - + " id:" + twitterUser.twitterId - + " image:" + twitterUser.image - + " url:" + twitterUser.url + "\n" + twitterUser.desc); - } - - function layoutFriends() { - var w = canvas.width; - var h = canvas.height; - for (var i=0; i < twitterUser.friends.length; i++) { - var friend = manager.getById(twitterUser.friends[i]); - if (friend) { - friend.x = Math.random() *w; - friend.y = Math.random() *h; - } - } - } - - function showFriends(ctx) { - var w = canvas.width; - var h = canvas.height; - for (var i=0; i < twitterUser.friends.length && i < 15; i++) { - var friend = manager.getById(twitterUser.friends[i]); - if (friend && twitterUser.canvas.isImageLoaded(friend.image)) { - friend.hasFocus = false; - friend.show(ctx, false); - } - } - } - - function linkFriends(ctx) { - var w = canvas.width; - var h = canvas.height; - for (var i=0; i < twitterUser.friends.length && i < 15; i++) { - var friend = manager.getById(twitterUser.friends[i]); - if (friend && twitterUser.canvas.isImageLoaded(friend.image)) { - if (!friend.linkColor) - friend.linkColor = Qt.rgba( ((Math.random() * 200) +55)/255 - , ((Math.random() * 200) +55)/255 - , ((Math.random() * 200) +55)/255, 0.8); - ctx.strokeStyle = friend.linkColor; - ctx.lineWidth = 8; - ctx.beginPath(); - ctx.moveTo(twitterUser.posX + twitterUser.width/2, twitterUser.posY + twitterUser.height/2); - ctx.lineTo(friend.x + friend.width/2, friend.y + friend.height/2); - ctx.stroke(); - } - } - } - - - function create(url) { - var x = new XMLHttpRequest; - x.open("GET", url); - - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - var user = eval('(' + x.responseText +')')[0]; - twitterUser.name = user.name; - twitterUser.twitterId = user.id; - twitterUser.image = user.profile_image_url; - twitterUser.canvas.loadImage(twitterUser.image); - twitterUser.url = user.url; - twitterUser.desc = user.description; - twitterUser.createFriends(); - } - } - x.send(); - } - - function createByName(name) { - if (twitterUser.name === "" && twitterUser.twitterId === "") { - twitterUser.name = name; - var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&screen_name=" + name; - twitterUser.create(userUrl); - } - } - - function createById(id) { - if (twitterUser.name === "" && twitterUser.twitterId === "") { - twitterUser.twitterId = id; - var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=" + id; - twitterUser.create(userUrl); - } - } - - function createFriends() { - if (twitterUser.friends.length === 0) { - var x = new XMLHttpRequest; - var friendsUrl = "https://api.twitter.com/1/friends/ids.json?cursor=-1&stringify_ids=true&user_id=" + twitterUser.twitterId; - x.open("GET", friendsUrl); - - x.onreadystatechange = function() { - if (x.readyState == XMLHttpRequest.DONE) { - twitterUser.friends = eval('(' + x.responseText +')').ids; - var doRequest = false; - var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id="; - - for (var i=0; i - -#include -#include -#include -#include - -//![0] -class ColorImageProvider : public QDeclarativeImageProvider -{ -public: - ColorImageProvider() - : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap) - { - } - - QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) - { - int width = 100; - int height = 50; - - if (size) - *size = QSize(width, height); - QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, - requestedSize.height() > 0 ? requestedSize.height() : height); - pixmap.fill(QColor(id).rgba()); -//![0] - - // write the color name - QPainter painter(&pixmap); - QFont f = painter.font(); - f.setPixelSize(20); - painter.setFont(f); - painter.setPen(Qt::black); - if (requestedSize.isValid()) - painter.scale(requestedSize.width() / width, requestedSize.height() / height); - painter.drawText(QRectF(0, 0, width, height), Qt::AlignCenter, id); - -//![1] - return pixmap; - } -}; -//![1] - - -class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "imageprovider.json") -public: - void registerTypes(const char *uri) - { - Q_UNUSED(uri); - } - - void initializeEngine(QDeclarativeEngine *engine, const char *uri) - { - Q_UNUSED(uri); - engine->addImageProvider("colors", new ColorImageProvider); - } - -}; - - -#define QDeclarativeExtensionInterface_iid "org.qt-project.Qt.QDeclarativeExtensionInterface" - - -#include "imageprovider.moc" diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/cppextensions/imageprovider/imageprovider.pro deleted file mode 100644 index dd128d56a8..0000000000 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.pro +++ /dev/null @@ -1,22 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative - -DESTDIR = ImageProviderCore -TARGET = qmlimageproviderplugin - -SOURCES += imageprovider.cpp - -OTHER_FILES += imageprovider.json - -sources.files = $$SOURCES imageprovider.qml imageprovider.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider/ImageProviderCore - -ImageProviderCore_sources.files = \ - ImageProviderCore/qmldir -ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider/ImageProviderCore - -INSTALLS = sources ImageProviderCore_sources target - diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject b/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp b/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp deleted file mode 100644 index 2bad2aa285..0000000000 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -#include -#include -#include - - -/* - This example illustrates using a QDeclarativeNetworkAccessManagerFactory to - create a QNetworkAccessManager with a proxy. - - Usage: - networkaccessmanagerfactory [-host -port ] [file] -*/ - -static QString proxyHost; -static int proxyPort = 0; - -class MyNetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory -{ -public: - virtual QNetworkAccessManager *create(QObject *parent); -}; - -QNetworkAccessManager *MyNetworkAccessManagerFactory::create(QObject *parent) -{ - QNetworkAccessManager *nam = new QNetworkAccessManager(parent); - if (!proxyHost.isEmpty()) { - qDebug() << "Created QNetworkAccessManager using proxy" << (proxyHost + ":" + QString::number(proxyPort)); - QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, proxyHost, proxyPort); - nam->setProxy(proxy); - } - - return nam; -} - -int main(int argc, char ** argv) -{ - QUrl source("qrc:view.qml"); - - QGuiApplication app(argc, argv); - - for (int i = 1; i < argc; ++i) { - QString arg(argv[i]); - if (arg == "-host" && i < argc-1) { - proxyHost = argv[++i]; - } else if (arg == "-port" && i < argc-1) { - arg = argv[++i]; - proxyPort = arg.toInt(); - } else if (arg[0] != '-') { - source = QUrl::fromLocalFile(arg); - } else { - qWarning() << "Usage: networkaccessmanagerfactory [-host -port ] [file]"; - exit(1); - } - } - - QQuickView view; - view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); - - view.setSource(source); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro deleted file mode 100644 index 479af364d0..0000000000 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro +++ /dev/null @@ -1,4 +0,0 @@ -QT += declarative quick network - -SOURCES += main.cpp -RESOURCES += networkaccessmanagerfactory.qrc diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc deleted file mode 100644 index 17e9301471..0000000000 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml b/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml deleted file mode 100644 index b2d46a991f..0000000000 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - width: 100 - height: 100 - source: "http://qt.nokia.com/logo.png" -} diff --git a/examples/declarative/cppextensions/plugins/README b/examples/declarative/cppextensions/plugins/README deleted file mode 100644 index f4f9074059..0000000000 --- a/examples/declarative/cppextensions/plugins/README +++ /dev/null @@ -1,9 +0,0 @@ -This example shows a module "com.nokia.TimeExample" that is implemented -by a C++ plugin (providing the "Time" type), and by QML files (providing the -"Clock" type). - -To run: - - make install - QML_IMPORT_PATH=$PWD qmlscene plugins.qml - diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml deleted file mode 100644 index eac9226a00..0000000000 --- a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: clock - width: 200; height: 200; color: "gray" - - property alias city: cityLabel.text - property variant hours - property variant minutes - property variant shift : 0 - - Image { id: background; source: "clock.png" } - - Image { - x: 92.5; y: 27 - source: "hour.png" - smooth: true - transform: Rotation { - id: hourRotation - origin.x: 7.5; origin.y: 73; - angle: (clock.hours * 30) + (clock.minutes * 0.5) - Behavior on angle { - SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - x: 93.5; y: 17 - source: "minute.png" - smooth: true - transform: Rotation { - id: minuteRotation - origin.x: 6.5; origin.y: 83; - angle: clock.minutes * 6 - Behavior on angle { - SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - anchors.centerIn: background; source: "center.png" - } - - Text { - id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white" - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png deleted file mode 100644 index 7fbd802a44..0000000000 Binary files a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/center.png and /dev/null differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png deleted file mode 100644 index 462edacc0e..0000000000 Binary files a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/clock.png and /dev/null differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png deleted file mode 100644 index f8061a1235..0000000000 Binary files a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/hour.png and /dev/null differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png deleted file mode 100644 index 1297ec7c2b..0000000000 Binary files a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/minute.png and /dev/null differ diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir deleted file mode 100644 index e1288cfac0..0000000000 --- a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Clock 1.0 Clock.qml -plugin qmlqtimeexampleplugin diff --git a/examples/declarative/cppextensions/plugins/plugin.cpp b/examples/declarative/cppextensions/plugins/plugin.cpp deleted file mode 100644 index 4ba0a928eb..0000000000 --- a/examples/declarative/cppextensions/plugins/plugin.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -// Implements a "TimeModel" class with hour and minute properties -// that change on-the-minute yet efficiently sleep the rest -// of the time. - -class MinuteTimer : public QObject -{ - Q_OBJECT -public: - MinuteTimer(QObject *parent) : QObject(parent) - { - } - - void start() - { - if (!timer.isActive()) { - time = QTime::currentTime(); - timer.start(60000-time.second()*1000, this); - } - } - - void stop() - { - timer.stop(); - } - - int hour() const { return time.hour(); } - int minute() const { return time.minute(); } - -signals: - void timeChanged(); - -protected: - void timerEvent(QTimerEvent *) - { - QTime now = QTime::currentTime(); - if (now.second() == 59 && now.minute() == time.minute() && now.hour() == time.hour()) { - // just missed time tick over, force it, wait extra 0.5 seconds - time.addSecs(60); - timer.start(60500, this); - } else { - time = now; - timer.start(60000-time.second()*1000, this); - } - emit timeChanged(); - } - -private: - QTime time; - QBasicTimer timer; -}; - -//![0] -class TimeModel : public QObject -{ - Q_OBJECT - Q_PROPERTY(int hour READ hour NOTIFY timeChanged) - Q_PROPERTY(int minute READ minute NOTIFY timeChanged) -//![0] - -public: - TimeModel(QObject *parent=0) : QObject(parent) - { - if (++instances == 1) { - if (!timer) - timer = new MinuteTimer(QCoreApplication::instance()); - connect(timer, SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); - timer->start(); - } - } - - ~TimeModel() - { - if (--instances == 0) { - timer->stop(); - } - } - - int minute() const { return timer->minute(); } - int hour() const { return timer->hour(); } - -signals: - void timeChanged(); - -private: - QTime t; - static MinuteTimer *timer; - static int instances; -}; - -int TimeModel::instances=0; -MinuteTimer *TimeModel::timer=0; - -//![plugin] -class QExampleQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "plugin.json") - -public: - void registerTypes(const char *uri) - { - Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); - qmlRegisterType(uri, 1, 0, "Time"); - } -}; -//![plugin] - -#include "plugin.moc" diff --git a/examples/declarative/cppextensions/plugins/plugins.pro b/examples/declarative/cppextensions/plugins/plugins.pro deleted file mode 100644 index a28582a07a..0000000000 --- a/examples/declarative/cppextensions/plugins/plugins.pro +++ /dev/null @@ -1,27 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative - -DESTDIR = com/nokia/TimeExample -TARGET = qmlqtimeexampleplugin - -SOURCES += plugin.cpp - -OTHER_FILES += "plugin.json" - -qdeclarativesources.files += \ - com/nokia/TimeExample/qmldir \ - com/nokia/TimeExample/center.png \ - com/nokia/TimeExample/clock.png \ - com/nokia/TimeExample/Clock.qml \ - com/nokia/TimeExample/hour.png \ - com/nokia/TimeExample/minute.png - -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/TimeExample - -sources.files += plugins.pro plugin.cpp plugins.qml README -sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins -target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/TimeExample - -INSTALLS += qdeclarativesources sources target - diff --git a/examples/declarative/cppextensions/plugins/plugins.qml b/examples/declarative/cppextensions/plugins/plugins.qml deleted file mode 100644 index f1048ddd36..0000000000 --- a/examples/declarative/cppextensions/plugins/plugins.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import com.nokia.TimeExample 1.0 // import types from the plugin - -Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml) - - Time { // this class is defined in C++ (plugin.cpp) - id: time - } - - hours: time.hour - minutes: time.minute - -} -//![0] diff --git a/examples/declarative/cppextensions/plugins/plugins.qmlproject b/examples/declarative/cppextensions/plugins/plugins.qmlproject deleted file mode 100644 index 771ab45b66..0000000000 --- a/examples/declarative/cppextensions/plugins/plugins.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "plugins.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/cppextensions/referenceexamples/adding/adding.pro b/examples/declarative/cppextensions/referenceexamples/adding/adding.pro deleted file mode 100644 index 1a972926b7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/adding.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp -HEADERS += person.h -RESOURCES += adding.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/adding -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/adding -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/adding/adding.qrc b/examples/declarative/cppextensions/referenceexamples/adding/adding.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/adding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/adding/example.qml b/examples/declarative/cppextensions/referenceexamples/adding/example.qml deleted file mode 100644 index 3b2ca34d10..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/example.qml +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -import People 1.0 - -Person { - name: "Bob Jones" - shoeSize: 12 -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/adding/main.cpp b/examples/declarative/cppextensions/referenceexamples/adding/main.cpp deleted file mode 100644 index 4c1918b6de..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); -//![0] - qmlRegisterType("People", 1,0, "Person"); -//![0] - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - Person *person = qobject_cast(component.create()); - if (person) { - qWarning() << "The person's name is" << person->name(); - qWarning() << "They wear a" << person->shoeSize() << "sized shoe"; - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/adding/person.cpp b/examples/declarative/cppextensions/referenceexamples/adding/person.cpp deleted file mode 100644 index 0e78b0b77b..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/person.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -// ![0] -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/adding/person.h b/examples/declarative/cppextensions/referenceexamples/adding/person.h deleted file mode 100644 index 45fb2f3297..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/adding/person.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -//![0] -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); - -private: - QString m_name; - int m_shoeSize; -}; -//![0] - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/attached/attached.pro b/examples/declarative/cppextensions/referenceexamples/attached/attached.pro deleted file mode 100644 index 4cfd4e0aed..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/attached.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += attached.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/attached -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/attached -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/attached/attached.qrc b/examples/declarative/cppextensions/referenceexamples/attached/attached.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/attached.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp deleted file mode 100644 index feefef4fe1..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h deleted file mode 100644 index c789c0bd51..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/birthdayparty.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - //! [static attached] - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - //! [static attached] -private: - Person *m_host; - QList m_guests; -}; - -//! [declare attached] -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) -//! [declare attached] -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/attached/example.qml b/examples/declarative/cppextensions/referenceexamples/attached/example.qml deleted file mode 100644 index 6a83af2804..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/example.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -//! [begin] -BirthdayParty { -//! [begin] - -//! [rsvp] - Boy { - name: "Robert Campbell" - BirthdayParty.rsvp: "2009-07-01" - } -//! [rsvp] - // ![1] - Boy { - name: "Leo Hodges" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - - BirthdayParty.rsvp: "2009-07-06" - } - // ![1] - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } -//! [end] -} -//! [end] - diff --git a/examples/declarative/cppextensions/referenceexamples/attached/main.cpp b/examples/declarative/cppextensions/referenceexamples/attached/main.cpp deleted file mode 100644 index 4c2c3003fe..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - //! [query rsvp] - QDate rsvpDate; - QObject *attached = qmlAttachedPropertiesObject(guest, false); - - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - //! [query rsvp] - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/attached/person.cpp b/examples/declarative/cppextensions/referenceexamples/attached/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/attached/person.h b/examples/declarative/cppextensions/referenceexamples/attached/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/attached/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/binding/binding.pro b/examples/declarative/cppextensions/referenceexamples/binding/binding.pro deleted file mode 100644 index 2add33fa47..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/binding.pro +++ /dev/null @@ -1,15 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.h - -RESOURCES += binding.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/binding -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/binding -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/binding/binding.qrc b/examples/declarative/cppextensions/referenceexamples/binding/binding.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/binding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp deleted file mode 100644 index 4f5acdfb75..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - if (d != m_rsvp) { - m_rsvp = d; - emit rsvpChanged(); - } -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - if (c == m_host) return; - m_host = c; - emit hostChanged(); -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -QString BirthdayParty::announcement() const -{ - return QString(); -} - -void BirthdayParty::setAnnouncement(const QString &speak) -{ - qWarning() << qPrintable(speak); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h deleted file mode 100644 index 376d107f26..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -signals: - void rsvpChanged(); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] - Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged) -// ![0] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - QString announcement() const; - void setAnnouncement(const QString &); - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -signals: - void partyStarted(const QTime &time); - void hostChanged(); - -private: - Person *m_host; - QList m_guests; -}; - -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/binding/example.qml b/examples/declarative/cppextensions/referenceexamples/binding/example.qml deleted file mode 100644 index 99a0098ff6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/example.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - id: theParty - - HappyBirthdaySong on announcement { name: theParty.host.name } - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } -// ![0] - onPartyStarted: console.log("This party started rockin' at " + time); - - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } - -// ![1] -} -// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp deleted file mode 100644 index df4dbec9c4..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "happybirthdaysong.h" -#include - -HappyBirthdaySong::HappyBirthdaySong(QObject *parent) -: QObject(parent), m_line(-1) -{ - setName(QString()); - QTimer *timer = new QTimer(this); - QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); - timer->start(1000); -} - -void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) -{ - m_target = p; -} - -QString HappyBirthdaySong::name() const -{ - return m_name; -} - -void HappyBirthdaySong::setName(const QString &name) -{ - if (m_name == name) - return; - - m_name = name; - - m_lyrics.clear(); - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday dear " + m_name + ","; - m_lyrics << "Happy birthday to you!"; - m_lyrics << ""; - - emit nameChanged(); -} - -void HappyBirthdaySong::advance() -{ - m_line = (m_line + 1) % m_lyrics.count(); - - m_target.write(m_lyrics.at(m_line)); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h b/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h deleted file mode 100644 index a9f3a94544..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/happybirthdaysong.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include - -#include - -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_INTERFACES(QDeclarativePropertyValueSource) -public: - HappyBirthdaySong(QObject *parent = 0); - - virtual void setTarget(const QDeclarativeProperty &); - - QString name() const; - void setName(const QString &); - -private slots: - void advance(); - -signals: - void nameChanged(); -private: - int m_line; - QStringList m_lyrics; - QDeclarativeProperty m_target; - QString m_name; -}; - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/declarative/cppextensions/referenceexamples/binding/main.cpp b/examples/declarative/cppextensions/referenceexamples/binding/main.cpp deleted file mode 100644 index 551d24b702..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/main.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "happybirthdaysong.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << component.errors(); - } - - return app.exec(); -} diff --git a/examples/declarative/cppextensions/referenceexamples/binding/person.cpp b/examples/declarative/cppextensions/referenceexamples/binding/person.cpp deleted file mode 100644 index 89e7127caf..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/person.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - if (m_size == s) - return; - - m_size = s; - emit shoeChanged(); -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - if (m_color == c) - return; - - m_color = c; - emit shoeChanged(); -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - if (m_brand == b) - return; - - m_brand = b; - emit shoeChanged(); -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - if (m_price == p) - return; - - m_price = p; - emit shoeChanged(); -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - if (m_name == n) - return; - - m_name = n; - emit nameChanged(); -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/binding/person.h b/examples/declarative/cppextensions/referenceexamples/binding/person.h deleted file mode 100644 index d0f196b95c..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/binding/person.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize NOTIFY shoeChanged) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY shoeChanged) - Q_PROPERTY(QString brand READ brand WRITE setBrand NOTIFY shoeChanged) - Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -signals: - void shoeChanged(); - -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) -// ![0] - Q_PROPERTY(ShoeDescription *shoe READ shoe CONSTANT) -// ![0] -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -signals: - void nameChanged(); - -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp deleted file mode 100644 index 1859ca9461..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h deleted file mode 100644 index 4315d3727e..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/birthdayparty.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![0] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro b/examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro deleted file mode 100644 index 742b85b683..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/coercion.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += coercion.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/coercion -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/coercion -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc b/examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/coercion.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/example.qml b/examples/declarative/cppextensions/referenceexamples/coercion/example.qml deleted file mode 100644 index 25791f38f8..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/example.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Boy { name: "Leo Hodges" }, - Boy { name: "Jack Smith" }, - Girl { name: "Anne Brown" } - ] -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp deleted file mode 100644 index 95b309de4c..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/main.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - //![0] - qmlRegisterType(); - //![0] - - //![register boy girl] - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - //![register boy girl] - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/person.cpp b/examples/declarative/cppextensions/referenceexamples/coercion/person.cpp deleted file mode 100644 index b28d63216e..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/person.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - -// ![1] -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - -// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/coercion/person.h b/examples/declarative/cppextensions/referenceexamples/coercion/person.h deleted file mode 100644 index dc4ae43dd6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/coercion/person.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - - -// ![0] -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -//! [girl class] -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; -//! [girl class] - -// ![0] - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp deleted file mode 100644 index 1859ca9461..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h deleted file mode 100644 index cfca6689db..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/birthdayparty.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -// ![0] -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![0] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/default/default.pro b/examples/declarative/cppextensions/referenceexamples/default/default.pro deleted file mode 100644 index 6533cdd7d3..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/default.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += default.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/default -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/default -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/default/default.qrc b/examples/declarative/cppextensions/referenceexamples/default/default.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/default.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/default/example.qml b/examples/declarative/cppextensions/referenceexamples/default/example.qml deleted file mode 100644 index 9ef24b59b7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/example.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoeSize: 12 - } - - Boy { name: "Leo Hodges" } - Boy { name: "Jack Smith" } - Girl { name: "Anne Brown" } -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/default/main.cpp b/examples/declarative/cppextensions/referenceexamples/default/main.cpp deleted file mode 100644 index 3a03279129..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/main.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/default/person.cpp b/examples/declarative/cppextensions/referenceexamples/default/person.cpp deleted file mode 100644 index 5a615a1ecd..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/person.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/default/person.h b/examples/declarative/cppextensions/referenceexamples/default/person.h deleted file mode 100644 index d85672798c..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/default/person.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/extended/example.qml b/examples/declarative/cppextensions/referenceexamples/extended/example.qml deleted file mode 100644 index 642a95d443..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/example.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -QLineEdit { - leftMargin: 20 -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/extended/extended.pro b/examples/declarative/cppextensions/referenceexamples/extended/extended.pro deleted file mode 100644 index 3d9f59c470..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/extended.pro +++ /dev/null @@ -1,11 +0,0 @@ -QT += declarative widgets - -SOURCES += main.cpp \ - lineedit.cpp -HEADERS += lineedit.h -RESOURCES += extended.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/extended -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/extended -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/extended/extended.qrc b/examples/declarative/cppextensions/referenceexamples/extended/extended.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/extended.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp b/examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp deleted file mode 100644 index 8f7fd8aa93..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "lineedit.h" -#include - -LineEditExtension::LineEditExtension(QObject *object) -: QObject(object), m_lineedit(static_cast(object)) -{ -} - -int LineEditExtension::leftMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return l; -} - -void LineEditExtension::setLeftMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(m, t, r, b); -} - -int LineEditExtension::rightMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return r; -} - -void LineEditExtension::setRightMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, t, m, b); -} - -int LineEditExtension::topMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return t; -} - -void LineEditExtension::setTopMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, m, r, b); -} - -int LineEditExtension::bottomMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return b; -} - -void LineEditExtension::setBottomMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, t, r, m); -} - - diff --git a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.h b/examples/declarative/cppextensions/referenceexamples/extended/lineedit.h deleted file mode 100644 index fa8c75df78..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/lineedit.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef LINEEDIT_H -#define LINEEDIT_H - -#include - -class LineEditExtension : public QObject -{ - Q_OBJECT - Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY marginsChanged) - Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY marginsChanged) - Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY marginsChanged) - Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY marginsChanged) -public: - LineEditExtension(QObject *); - - int leftMargin() const; - void setLeftMargin(int); - - int rightMargin() const; - void setRightMargin(int); - - int topMargin() const; - void setTopMargin(int); - - int bottomMargin() const; - void setBottomMargin(int); -signals: - void marginsChanged(); - -private: - QLineEdit *m_lineedit; -}; - -#endif // LINEEDIT_H diff --git a/examples/declarative/cppextensions/referenceexamples/extended/main.cpp b/examples/declarative/cppextensions/referenceexamples/extended/main.cpp deleted file mode 100644 index 3c580396f2..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/extended/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include "lineedit.h" - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - qmlRegisterExtendedType("People", 1,0, "QLineEdit"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - QLineEdit *edit = qobject_cast(component.create()); - - if (edit) { - edit->show(); - return app.exec(); - } else { - qWarning() << component.errors(); - return 0; - } -} diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp deleted file mode 100644 index 1859ca9461..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h deleted file mode 100644 index 491903adc5..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/birthdayparty.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/example.qml b/examples/declarative/cppextensions/referenceexamples/grouped/example.qml deleted file mode 100644 index 9ae80f222e..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/example.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Bikey"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" -//![grouped] - shoe { size: 10; color: "black"; brand: "Thebok"; price: 59.95 } -//![grouped] - } - // ![1] - Boy { - name: "Jack Smith" - shoe { - size: 8 - color: "blue" - brand: "Luma" - price: 19.95 - } - } - // ![1] - Girl { - name: "Anne Brown" -//![ungrouped] - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Job Macobs" - shoe.price: 699.99 -//![ungrouped] - } -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro b/examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro deleted file mode 100644 index aab0c8469a..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/grouped.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += grouped.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/grouped -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/grouped -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc b/examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/grouped.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp deleted file mode 100644 index de7d714c52..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/main.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - Person *bestShoe = 0; - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - qWarning() << " " << guest->name(); - - if (!bestShoe || bestShoe->shoe()->price() < guest->shoe()->price()) - bestShoe = guest; - } - if (bestShoe) - qWarning() << bestShoe->name() << "is wearing the best shoes!"; - - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/person.cpp b/examples/declarative/cppextensions/referenceexamples/grouped/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/grouped/person.h b/examples/declarative/cppextensions/referenceexamples/grouped/person.h deleted file mode 100644 index dea715bacb..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/grouped/person.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) -// ![1] - Q_PROPERTY(ShoeDescription *shoe READ shoe) -// ![1] -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp deleted file mode 100644 index 35444f505a..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -// ![0] -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::invite(const QString &name) -{ - Person *person = new Person(this); - person->setName(name); - m_guests.append(person); -} -// ![0] - diff --git a/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h deleted file mode 100644 index e49afdb78d..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -// ![0] - Q_INVOKABLE void invite(const QString &name); -// ![0] - -private: - Person *m_host; - QList m_guests; -}; - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/methods/example.qml b/examples/declarative/cppextensions/referenceexamples/methods/example.qml deleted file mode 100644 index 9119835e04..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/example.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import People 1.0 - -BirthdayParty { - host: Person { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Person { name: "Leo Hodges" }, - Person { name: "Jack Smith" }, - Person { name: "Anne Brown" } - ] - -// ![0] - Component.onCompleted: invite("William Green") -// ![0] -} diff --git a/examples/declarative/cppextensions/referenceexamples/methods/main.cpp b/examples/declarative/cppextensions/referenceexamples/methods/main.cpp deleted file mode 100644 index d037d88f20..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/main.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "Person"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - qWarning() << "They are inviting:"; - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/methods/methods.pro b/examples/declarative/cppextensions/referenceexamples/methods/methods.pro deleted file mode 100644 index ee28355188..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/methods.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += methods.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/methods -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS methods.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/methods -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/methods/methods.qrc b/examples/declarative/cppextensions/referenceexamples/methods/methods.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/methods.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/methods/person.cpp b/examples/declarative/cppextensions/referenceexamples/methods/person.cpp deleted file mode 100644 index 30d1e46e5a..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/person.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - diff --git a/examples/declarative/cppextensions/referenceexamples/methods/person.h b/examples/declarative/cppextensions/referenceexamples/methods/person.h deleted file mode 100644 index dd3ad4d188..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/methods/person.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp deleted file mode 100644 index 0038cd0a41..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -// ![0] -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} -// ![0] - diff --git a/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h deleted file mode 100644 index 2c3d128b6d..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -// ![0] -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] -// ![1] - Q_PROPERTY(Person *host READ host WRITE setHost) -// ![1] -// ![2] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![2] -// ![3] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![3] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/example.qml b/examples/declarative/cppextensions/referenceexamples/properties/example.qml deleted file mode 100644 index 36ee952243..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/example.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Person { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Person { name: "Leo Hodges" }, - Person { name: "Jack Smith" }, - Person { name: "Anne Brown" } - ] -} -// ![0] diff --git a/examples/declarative/cppextensions/referenceexamples/properties/main.cpp b/examples/declarative/cppextensions/referenceexamples/properties/main.cpp deleted file mode 100644 index 421ce9fbaa..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/main.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - -//![register list] - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "Person"); -//![register list] - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - qWarning() << "They are inviting:"; - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/properties/person.cpp b/examples/declarative/cppextensions/referenceexamples/properties/person.cpp deleted file mode 100644 index 30d1e46e5a..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/person.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - diff --git a/examples/declarative/cppextensions/referenceexamples/properties/person.h b/examples/declarative/cppextensions/referenceexamples/properties/person.h deleted file mode 100644 index dd3ad4d188..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/person.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/properties/properties.pro b/examples/declarative/cppextensions/referenceexamples/properties/properties.pro deleted file mode 100644 index 936d0ea429..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/properties.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += properties.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/properties -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/properties -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/properties/properties.qrc b/examples/declarative/cppextensions/referenceexamples/properties/properties.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/properties/properties.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro b/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro deleted file mode 100644 index 505cefd331..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/referenceexamples.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - adding \ - attached \ - binding \ - coercion \ - default \ - extended \ - grouped \ - properties \ - signal \ - valuesource \ - methods diff --git a/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject b/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/referenceexamples.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp deleted file mode 100644 index d576c2a278..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h deleted file mode 100644 index 45ad4f0acf..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -// ![0] -signals: - void partyStarted(const QTime &time); -// ![0] - -private: - Person *m_host; - QList m_guests; -}; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/signal/example.qml b/examples/declarative/cppextensions/referenceexamples/signal/example.qml deleted file mode 100644 index 796c2f32a1..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/example.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -BirthdayParty { -// ![0] - onPartyStarted: console.log("This party started rockin' at " + time); -// ![0] - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } -// ![1] -} -// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/signal/main.cpp b/examples/declarative/cppextensions/referenceexamples/signal/main.cpp deleted file mode 100644 index 5800cf450f..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/cppextensions/referenceexamples/signal/person.cpp b/examples/declarative/cppextensions/referenceexamples/signal/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/signal/person.h b/examples/declarative/cppextensions/referenceexamples/signal/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/signal/signal.pro b/examples/declarative/cppextensions/referenceexamples/signal/signal.pro deleted file mode 100644 index 8ffdb50f90..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/signal.pro +++ /dev/null @@ -1,13 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += signal.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/signal -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/signal -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/signal/signal.qrc b/examples/declarative/cppextensions/referenceexamples/signal/signal.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/signal/signal.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp deleted file mode 100644 index 09137c41a8..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -QString BirthdayParty::announcement() const -{ - return QString(); -} - -void BirthdayParty::setAnnouncement(const QString &speak) -{ - qWarning() << qPrintable(speak); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h b/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h deleted file mode 100644 index 5d561da807..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![0] - Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) -// ![0] - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - QString announcement() const; - void setAnnouncement(const QString &); - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -signals: - void partyStarted(const QTime &time); - -private: - Person *m_host; - QList m_guests; -}; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml b/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml deleted file mode 100644 index 04c3048e9e..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/example.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - HappyBirthdaySong on announcement { name: "Bob Jones" } -// ![0] - - onPartyStarted: console.log("This party started rockin' at " + time); - - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } - -// ![1] -} -// ![1] diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp deleted file mode 100644 index 629c354543..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "happybirthdaysong.h" -#include - -HappyBirthdaySong::HappyBirthdaySong(QObject *parent) -: QObject(parent), m_line(-1) -{ - setName(QString()); - QTimer *timer = new QTimer(this); - QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); - timer->start(1000); -} - -void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) -{ - m_target = p; -} - -QString HappyBirthdaySong::name() const -{ - return m_name; -} - -void HappyBirthdaySong::setName(const QString &name) -{ - m_name = name; - - m_lyrics.clear(); - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday dear " + m_name + ","; - m_lyrics << "Happy birthday to you!"; - m_lyrics << ""; -} - -void HappyBirthdaySong::advance() -{ - m_line = (m_line + 1) % m_lyrics.count(); - - m_target.write(m_lyrics.at(m_line)); -} - diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h b/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h deleted file mode 100644 index 9721350435..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include -#include - -#include - -// ![0] -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource -{ - Q_OBJECT - Q_INTERFACES(QDeclarativePropertyValueSource) -// ![0] - Q_PROPERTY(QString name READ name WRITE setName) -// ![1] -public: - HappyBirthdaySong(QObject *parent = 0); - - virtual void setTarget(const QDeclarativeProperty &); -// ![1] - - QString name() const; - void setName(const QString &); - -private slots: - void advance(); - -private: - int m_line; - QStringList m_lyrics; - QDeclarativeProperty m_target; - QString m_name; -// ![2] -}; -// ![2] - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp deleted file mode 100644 index 53d676dfbe..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "happybirthdaysong.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << component.errors(); - } - - return app.exec(); -} diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp b/examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/person.h b/examples/declarative/cppextensions/referenceexamples/valuesource/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro deleted file mode 100644 index a978d8452a..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.pro +++ /dev/null @@ -1,15 +0,0 @@ -QT += declarative - -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.h -RESOURCES += valuesource.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/valuesource -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/valuesource -INSTALLS += target sources diff --git a/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc b/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/cppextensions/referenceexamples/valuesource/valuesource.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro deleted file mode 100644 index 883c0afe2d..0000000000 --- a/examples/declarative/declarative.pro +++ /dev/null @@ -1,38 +0,0 @@ -TEMPLATE = subdirs - -# These examples contain some C++ and need to be built -SUBDIRS = \ - cppextensions \ - minehunt \ - modelviews \ - painteditem \ - tutorials \ - script - -# These examples contain no C++ and can simply be copied -sources.files = \ - animation \ - calculator \ - cppextensions \ - flickr \ - i18n \ - imageelements \ - keyinteraction \ - photoviewer \ - positioners \ - rssnews \ - samegame \ - snake \ - sqllocalstorage \ - text \ - threading \ - touchinteraction \ - toys \ - twitter \ - ui-components \ - webbrowser \ - xml - - -sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative -INSTALLS += sources diff --git a/examples/declarative/draganddrop/dragtarget.qmlproject b/examples/declarative/draganddrop/dragtarget.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/draganddrop/dragtarget.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/draganddrop/tiles/DragTile.qml b/examples/declarative/draganddrop/tiles/DragTile.qml deleted file mode 100644 index 2813fa8caf..0000000000 --- a/examples/declarative/draganddrop/tiles/DragTile.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property string colorKey - - width: 100; height: 100 - - MouseArea { - id: mouseArea - - width: 100; height: 100 - anchors.centerIn: parent - - drag.target: tile - - onReleased: parent = tile.Drag.target !== null ? tile.Drag.target : root - - Rectangle { - id: tile - - width: 100; height: 100 - - anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter - color: colorKey - - Drag.keys: [ colorKey ] - Drag.active: mouseArea.drag.active - Drag.hotSpot.x: 50 - Drag.hotSpot.y: 50 - - Text { - anchors.fill: parent - color: "white" - font.pixelSize: 90 - text: modelData + 1 - horizontalAlignment:Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - - states: State { - when: mouseArea.drag.active - ParentChange { target: tile; parent: root } - AnchorChanges { target: tile; anchors.verticalCenter: undefined; anchors.horizontalCenter: undefined } - } - } - } -} - diff --git a/examples/declarative/draganddrop/tiles/DropTile.qml b/examples/declarative/draganddrop/tiles/DropTile.qml deleted file mode 100644 index e8566f04cc..0000000000 --- a/examples/declarative/draganddrop/tiles/DropTile.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -DropArea { - id: dragTarget - - property string colorKey - property alias dropProxy: dragTarget - - width: 100; height: 100 - keys: [ colorKey ] - - Rectangle { - id: dropRectangle - - anchors.fill: parent - color: colorKey - - states: [ - State { - when: dragTarget.containsDrag - PropertyChanges { - target: dropRectangle - color: "grey" - } - } - ] - } -} diff --git a/examples/declarative/draganddrop/tiles/tiles.qml b/examples/declarative/draganddrop/tiles/tiles.qml deleted file mode 100644 index 31c87f8244..0000000000 --- a/examples/declarative/draganddrop/tiles/tiles.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - - width: 620 - height: 410 - - color: "black" - - Grid { - id: redDestination - - anchors.left: redSource.right; anchors.top: parent.top; - anchors.margins: 5 - width: 300 - height: 300 - opacity: 0.5 - columns: 3 - - Repeater { - model: 9; - delegate: DropTile { colorKey: "red" } - } - } - - Grid { - anchors.right: blueSource.left; anchors.bottom: parent.bottom; - anchors.margins: 5 - width: 300 - height: 300 - - opacity: 0.5 - - columns: 3 - - Repeater { - model: 9 - delegate: DropTile { colorKey: "blue" } - } - } - - Column { - id: redSource - - anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom - anchors.margins: 5 - width: 100 - spacing: -60 - - Repeater { - model: 9 - delegate: DragTile { colorKey: "red" } - } - } - Column { - id: blueSource - - anchors.right: parent.right; anchors.top: parent.top; anchors.bottom: parent.bottom - anchors.margins: 5 - width: 100 - spacing: -60 - - Repeater { - model: 9 - delegate: DragTile { colorKey: "blue" } - } - } -} diff --git a/examples/declarative/draganddrop/views/gridview.qml b/examples/declarative/draganddrop/views/gridview.qml deleted file mode 100644 index 375f3d2824..0000000000 --- a/examples/declarative/draganddrop/views/gridview.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -GridView { - id: root - width: 360; height: 360 - cellWidth: 90; cellHeight: 90 - - model: VisualDataModel { - id: visualModel - model: ListModel { - id: colorModel - ListElement { color: "blue" } - ListElement { color: "green" } - ListElement { color: "red" } - ListElement { color: "yellow" } - ListElement { color: "orange" } - ListElement { color: "purple" } - ListElement { color: "cyan" } - ListElement { color: "magenta" } - ListElement { color: "chartreuse" } - ListElement { color: "aquamarine" } - ListElement { color: "indigo" } - ListElement { color: "black" } - ListElement { color: "chartreuse" } - ListElement { color: "violet" } - ListElement { color: "grey" } - ListElement { color: "springgreen" } - } - - delegate: MouseArea { - id: delegateRoot - - property int visualIndex: VisualDataModel.itemsIndex - - width: 90; height: 90 - drag.target: icon - - Rectangle { - id: icon - width: 80; height: 80 - anchors { - horizontalCenter: parent.horizontalCenter; - verticalCenter: parent.verticalCenter - } - color: model.color - radius: 3 - - Drag.active: delegateRoot.pressed - Drag.source: delegateRoot - Drag.hotSpot.x: 40 - Drag.hotSpot.y: 40 - - states: [ - State { - when: icon.Drag.active - ParentChange { - target: icon - parent: root - } - - AnchorChanges { - target: icon; - anchors.horizontalCenter: undefined; - anchors.verticalCenter: undefined - } - } - ] - } - - DropArea { - anchors { fill: parent; margins: 15 } - - onEntered: visualModel.items.move(drag.source.visualIndex, delegateRoot.visualIndex) - } - } - } -} diff --git a/examples/declarative/flickr/content/Button.qml b/examples/declarative/flickr/content/Button.qml deleted file mode 100644 index d6a8d3e001..0000000000 --- a/examples/declarative/flickr/content/Button.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - signal clicked - - property string text - - BorderImage { - id: buttonImage - source: "images/toolbutton.sci" - width: container.width; height: container.height - } - BorderImage { - id: pressed - opacity: 0 - source: "images/toolbutton.sci" - width: container.width; height: container.height - } - MouseArea { - id: mouseRegion - anchors.fill: buttonImage - onClicked: { container.clicked(); } - } - Text { - color: "white" - anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 15 - text: container.text; style: Text.Raised; styleColor: "black" - } - states: [ - State { - name: "Pressed" - when: mouseRegion.pressed == true - PropertyChanges { target: pressed; opacity: 1 } - } - ] -} diff --git a/examples/declarative/flickr/content/GridDelegate.qml b/examples/declarative/flickr/content/GridDelegate.qml deleted file mode 100644 index 794d768c74..0000000000 --- a/examples/declarative/flickr/content/GridDelegate.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: wrapper; width: GridView.view.cellWidth; height: GridView.view.cellHeight - - function photoClicked() { - imageDetails.photoTitle = title; - imageDetails.photoTags = tags; - imageDetails.photoWidth = photoWidth; - imageDetails.photoHeight = photoHeight; - imageDetails.photoType = photoType; - imageDetails.photoAuthor = photoAuthor; - imageDetails.photoDate = photoDate; - imageDetails.photoUrl = url; - imageDetails.rating = 0; - scaleMe.state = "Details"; - } - - Item { - anchors.centerIn: parent - scale: 0.0 - Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} } - id: scaleMe - - Item { - width: 77; height: 77; anchors.centerIn: parent - Rectangle { - id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true - Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true } - Image { source: "images/gloss.png" } - } - } - - Connections { - target: toolBar - onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' - } - - states: [ - State { - name: "Show"; when: thumb.status == Image.Ready - PropertyChanges { target: scaleMe; scale: 1 } - }, - State { - name: "Details" - PropertyChanges { target: scaleMe; scale: 1 } - ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer } - PropertyChanges { target: background; state: "DetailedView" } - } - ] - transitions: [ - Transition { - from: "Show"; to: "Details" - ParentAnimation { - via: foreground - NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } - } - }, - Transition { - from: "Details"; to: "Show" - ParentAnimation { - via: foreground - NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } - } - } - ] - } - MouseArea { anchors.fill: wrapper; onClicked: photoClicked() } -} - diff --git a/examples/declarative/flickr/content/ImageDetails.qml b/examples/declarative/flickr/content/ImageDetails.qml deleted file mode 100644 index 83f2537d65..0000000000 --- a/examples/declarative/flickr/content/ImageDetails.qml +++ /dev/null @@ -1,323 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Flipable { - id: container - - property alias frontContainer: containerFront - property string photoTitle: "" - property string photoTags: "" - property int photoWidth - property int photoHeight - property string photoType - property string photoAuthor - property string photoDate - property string photoUrl - property int rating: 2 - property variant prevScale: 1.0 - - property int flipDuration: 1600 - - signal closed - - transform: Rotation { - id: itemRotation - origin.x: container.width / 2; - axis.y: 1; axis.z: 0 - } - - front: Item { - id: containerFront; anchors.fill: container - - Rectangle { - anchors.fill: parent - color: "black"; opacity: 0.4 - } - - Column { - spacing: 10 - anchors { - left: parent.left; leftMargin: 10 - right: parent.right; rightMargin: 10 - top: parent.top; topMargin: 120 - } - Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: "Size: " + container.photoWidth + 'x' + container.photoHeight; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: "Type: " + container.photoType; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: "Author: " + container.photoAuthor; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: "Published: " + container.photoDate; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "Tags: "; width: parent.width } - Text { color: "white"; elide: Text.ElideRight; text: container.photoTags; width: parent.width } - } - } - - back: Item { - anchors.fill: container - - Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 } - - Progress { - anchors.centerIn: parent; width: 200; height: 22 - progress: bigImage.progress; visible: bigImage.status != Image.Ready - } - - Flickable { - id: flickable; anchors.fill: parent; clip: true - contentWidth: imageContainer.width; contentHeight: imageContainer.height - - function updateMinimumScale() { - if (bigImage.status == Image.Ready && bigImage.width != 0) { - slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height); - if (bigImage.width * slider.value > flickable.width) { - var xoff = (flickable.width/2 + flickable.contentX) * slider.value / prevScale; - flickable.contentX = xoff - flickable.width/2; - } - if (bigImage.height * slider.value > flickable.height) { - var yoff = (flickable.height/2 + flickable.contentY) * slider.value / prevScale; - flickable.contentY = yoff - flickable.height/2; - } - prevScale = slider.value; - } - } - - onWidthChanged: updateMinimumScale() - onHeightChanged: updateMinimumScale() - - Item { - id: imageContainer - width: Math.max(bigImage.width * bigImage.scale, flickable.width); - height: Math.max(bigImage.height * bigImage.scale, flickable.height); - Image { - id: bigImage; source: container.photoUrl; scale: slider.value - anchors.centerIn: parent; smooth: !flickable.movingVertically - onStatusChanged : { - // Default scale shows the entire image. - if (bigImage.status == Image.Ready && bigImage.width != 0) { - slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height); - prevScale = Math.min(slider.minimum, 1); - slider.value = prevScale; - } - if (inBackState && bigImage.status == Image.Ready) - effectBox.imageInAnim(); - } - property bool inBackState: false - onInBackStateChanged:{ - if(inBackState && bigImage.status == Image.Ready) - effectBox.imageInAnim(); - else if (!inBackState && bigImage.status == Image.Ready) - effectBox.imageOutAnim(); - } - } - ShaderEffectSource{ - id: pictureSource - sourceItem: bigImage - smooth: true - //Workaround: Doesn't work below lines - width: bigImage.width - height: bigImage.width - visible: false - } - Turbulence{//only fill visible rect - id: turbulence - system: imageSystem - anchors.fill: parent - strength: 240 - enabled: false - } - - Item{ - id: effectBox - width: bigImage.width * bigImage.scale - height: bigImage.height * bigImage.scale - anchors.centerIn: parent - function imageInAnim(){ - bigImage.visible = false; - noiseIn.visible = true; - endEffectTimer.start(); - } - function imageOutAnim(){ - bigImage.visible = false; - noiseIn.visible = false; - turbulence.enabled = true; - endEffectTimer.start(); - pixelEmitter.burst(2048); - } - Timer{ - id: endEffectTimer - interval: flipDuration - repeat: false - running: false - onTriggered:{ - turbulence.enabled = false; - noiseIn.visible = false; - bigImage.visible = true; - } - } - ShaderEffect{ - id: noiseIn - anchors.fill: parent - property real t: 0 - visible: false - onVisibleChanged: tAnim.start() - NumberAnimation{ - id: tAnim - target: noiseIn - property: "t" - from: 0.0 - to: 1.0 - duration: flipDuration - } - property variant source: pictureSource - property variant noise: ShaderEffectSource{ - sourceItem:Image{ - source: "images/noise.png" - } - hideSource: true - smooth: false - } - fragmentShader:" - uniform sampler2D noise; - uniform sampler2D source; - uniform highp float t; - uniform lowp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main(){ - //Want to use noise2, but it always returns (0,0)? - if(texture2D(noise, qt_TexCoord0).w <= t) - gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; - else - gl_FragColor = vec4(0.,0.,0.,0.); - } - " - } - ParticleSystem{ - id: imageSystem - } - Emitter{ - id: pixelEmitter - system: imageSystem - //anchors.fill: parent - width: Math.min(bigImage.width * bigImage.scale, flickable.width); - height: Math.min(bigImage.height * bigImage.scale, flickable.height); - anchors.centerIn: parent - size: 4 - lifeSpan: flipDuration - emitRate: 2048 - enabled: false - } - CustomParticle{ - id: blowOut - system: imageSystem - property real maxWidth: effectBox.width - property real maxHeight: effectBox.height - vertexShader:" - uniform highp float maxWidth; - uniform highp float maxHeight; - - varying highp vec2 fTex2; - - void main() { - defaultMain(); - fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight); - } - " - property variant pictureTexture: pictureSource - fragmentShader: " - uniform lowp float qt_Opacity; - uniform sampler2D pictureTexture; - varying highp vec2 fTex2; - void main() { - gl_FragColor = texture2D(pictureTexture, fTex2) * qt_Opacity; - }" - } - - - - } - } - } - - Text { - text: "Image Unavailable" - visible: bigImage.status == Image.Error - anchors.centerIn: parent; color: "white"; font.bold: true - } - - Slider { - id: slider; visible: { bigImage.status == Image.Ready && maximum > minimum } - anchors { - bottom: parent.bottom; bottomMargin: 65 - left: parent.left; leftMargin: 25 - right: parent.right; rightMargin: 25 - } - onValueChanged: { - if (bigImage.width * value > flickable.width) { - var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale; - flickable.contentX = xoff - flickable.width/2; - } - if (bigImage.height * value > flickable.height) { - var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale; - flickable.contentY = yoff - flickable.height/2; - } - prevScale = value; - } - } - } - - states: State { - name: "Back" - PropertyChanges { target: itemRotation; angle: 180 } - PropertyChanges { target: toolBar; button2Visible: false } - PropertyChanges { target: toolBar; button1Label: "Back" } - PropertyChanges { target: bigImage; inBackState: true } - } - - transitions: Transition { - SequentialAnimation { - PropertyAction { target: bigImage; property: "smooth"; value: false } - NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: flipDuration } - PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically } - } - } -} diff --git a/examples/declarative/flickr/content/ListDelegate.qml b/examples/declarative/flickr/content/ListDelegate.qml deleted file mode 100644 index 9c239151f1..0000000000 --- a/examples/declarative/flickr/content/ListDelegate.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Component { - Item { - id: wrapper; width: wrapper.ListView.view.width; height: 86 - Item { - id: moveMe - Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 } - Rectangle { - x: 6; y: 4; width: 77; height: 77; color: "white"; smooth: true - - Image { source: imagePath; x: 1; y: 1 } - Image { source: "images/gloss.png" } - } - Column { - x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2 - Text { text: title; color: "white"; width: parent.width; font.pixelSize: 14; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" } - Text { text: photoAuthor; width: parent.width; font.pixelSize: 14; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" } - Text { text: photoDate; width: parent.width; font.pixelSize: 14; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" } - } - } - } -} diff --git a/examples/declarative/flickr/content/Progress.qml b/examples/declarative/flickr/content/Progress.qml deleted file mode 100644 index 81f1e79ed6..0000000000 --- a/examples/declarative/flickr/content/Progress.qml +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item{ - id: container - property variant progress: 0 - - Rectangle { - anchors.fill: parent; smooth: true - border.color: "white"; border.width: 0; radius: height/2 - 2 - gradient: Gradient { - GradientStop { position: 0; color: "#66343434" } - GradientStop { position: 1.0; color: "#66000000" } - } - } - - ParticleSystem{ - running: container.visible - id: barSys - } - ImageParticle{ - color: "lightsteelblue" - alpha: 0.1 - colorVariation: 0.05 - source: "images/particle.png" - system: barSys - } - Emitter{ - y: 2; height: parent.height-4; - x: 2; width: Math.max(parent.width * progress - 4, 0); - speed: AngleDirection{ angleVariation: 180; magnitudeVariation: 12 } - system: barSys - emitRate: width; - lifeSpan: 1000 - size: 20 - sizeVariation: 4 - endSize: 12 - maximumEmitted: parent.width; - } - - Text { - text: Math.round(progress * 100) + "%" - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - color: Qt.rgba(1.0, 1.0 - progress, 1.0 - progress,0.9); font.bold: true; font.pixelSize: 15 - } -} diff --git a/examples/declarative/flickr/content/RssModel.qml b/examples/declarative/flickr/content/RssModel.qml deleted file mode 100644 index f28a23d502..0000000000 --- a/examples/declarative/flickr/content/RssModel.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - property string tags : "" - - function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } - - source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")+"format=rss2" - query: "/rss/channel/item" - namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } - XmlRole { name: "url"; query: "media:content/@url/string()" } - XmlRole { name: "description"; query: "description/string()" } - XmlRole { name: "tags"; query: "media:category/string()" } - XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } - XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } - XmlRole { name: "photoType"; query: "media:content/@type/string()" } - XmlRole { name: "photoAuthor"; query: "author/string()" } - XmlRole { name: "photoDate"; query: "pubDate/string()" } -} diff --git a/examples/declarative/flickr/content/ScrollBar.qml b/examples/declarative/flickr/content/ScrollBar.qml deleted file mode 100644 index 388e43dc2d..0000000000 --- a/examples/declarative/flickr/content/ScrollBar.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property variant flickableArea - - Rectangle { - radius: 5 - color: "black" - opacity: 0.3 - border.color: "white" - border.width: 2 - x: 0 - y: flickableArea.visibleArea.yPosition * container.height - width: parent.width - height: flickableArea.visibleArea.heightRatio * container.height - } - states: [ - State { - name: "show" - when: flickableArea.movingVertically - PropertyChanges { - target: container - opacity: 1 - } - } - ] - transitions: [ - Transition { - from: "*" - to: "*" - NumberAnimation { - target: container - properties: "opacity" - duration: 400 - } - } - ] -} diff --git a/examples/declarative/flickr/content/Slider.qml b/examples/declarative/flickr/content/Slider.qml deleted file mode 100644 index 0f9e8b20f2..0000000000 --- a/examples/declarative/flickr/content/Slider.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: slider; width: 400; height: 16 - - // value is read/write. - property real value: 1 - onValueChanged: updatePos(); - property real maximum: 1 - property real minimum: 1 - property int xMax: width - handle.width - 4 - onXMaxChanged: updatePos(); - onMinimumChanged: updatePos(); - - function updatePos() { - if (maximum > minimum) { - var pos = 2 + (value - minimum) * slider.xMax / (maximum - minimum); - pos = Math.min(pos, width - handle.width - 2); - pos = Math.max(pos, 2); - handle.x = pos; - } else { - handle.x = 2; - } - } - - Rectangle { - anchors.fill: parent - border.color: "white"; border.width: 0; radius: 8 - gradient: Gradient { - GradientStop { position: 0.0; color: "#66343434" } - GradientStop { position: 1.0; color: "#66000000" } - } - } - - Rectangle { - id: handle; smooth: true - y: 2; width: 30; height: slider.height-4; radius: 6 - gradient: Gradient { - GradientStop { position: 0.0; color: "lightgray" } - GradientStop { position: 1.0; color: "gray" } - } - - MouseArea { - id: mouse - anchors.fill: parent; drag.target: parent - drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: slider.xMax+2 - onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; } - } - } -} diff --git a/examples/declarative/flickr/content/TitleBar.qml b/examples/declarative/flickr/content/TitleBar.qml deleted file mode 100644 index 3dab005a11..0000000000 --- a/examples/declarative/flickr/content/TitleBar.qml +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: titleBar - property string untaggedString: "Uploads from everyone" - property string taggedString: "Recent uploads tagged " - - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - - Item { - id: container - width: (parent.width * 2) - 55 ; height: parent.height - - function accept() { - imageDetails.closed() - titleBar.state = "" - background.state = "" - rssModel.tags = editor.text - } - - Image { - id: quitButton - anchors.left: parent.left//; anchors.leftMargin: 0 - anchors.verticalCenter: parent.verticalCenter - source: "images/quit.png" - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - } - - Text { - id: categoryText - anchors { - left: quitButton.right; right: tagButton.left; leftMargin: 10; rightMargin: 10 - verticalCenter: parent.verticalCenter - } - elide: Text.ElideLeft - text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags) - font.bold: true; font.pixelSize: 15; color: "White"; style: Text.Raised; styleColor: "Black" - } - - Button { - id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..." - onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags" - anchors.verticalCenter: parent.verticalCenter - } - - Item { - id: lineEdit - y: 4; height: parent.height - 9 - anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 } - - BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } - - TextInput { - id: editor - anchors { - left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10 - verticalCenter: parent.verticalCenter - } - cursorVisible: true; font.bold: true - color: "#151515"; selectionColor: "Green" - } - - Keys.forwardTo: [ (returnKey), (editor)] - - Item { - id: returnKey - Keys.onReturnPressed: container.accept() - Keys.onEnterPressed: container.accept() - Keys.onEscapePressed: titleBar.state = "" - } - } - } - - states: State { - name: "Tags" - PropertyChanges { target: container; x: -tagButton.x + 5 } - PropertyChanges { target: tagButton; text: "OK" } - PropertyChanges { target: editor; focus: true } - } - - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } - } -} diff --git a/examples/declarative/flickr/content/ToolBar.qml b/examples/declarative/flickr/content/ToolBar.qml deleted file mode 100644 index e82be63e7e..0000000000 --- a/examples/declarative/flickr/content/ToolBar.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: toolbar - - property alias button1Label: button1.text - property alias button2Label: button2.text - property alias button2Visible: button2.visible - - signal button1Clicked - signal button2Clicked - - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - - Row { - anchors.right: parent.right; anchors.rightMargin: 5; y: 3; height: 32; spacing: 30 - Button { - id: button1 - width: 140; height: 32 - onClicked: toolbar.button1Clicked() - } - - Button { - id: button2; width: 140; height: 32 - onClicked: toolbar.button2Clicked() - } - } -} diff --git a/examples/declarative/flickr/content/UnifiedDelegate.qml b/examples/declarative/flickr/content/UnifiedDelegate.qml deleted file mode 100644 index 00a777b0a1..0000000000 --- a/examples/declarative/flickr/content/UnifiedDelegate.qml +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Package { - function photoClicked() { - imageDetails.photoTitle = title; - imageDetails.photoTags = tags; - imageDetails.photoWidth = photoWidth; - imageDetails.photoHeight = photoHeight; - imageDetails.photoType = photoType; - imageDetails.photoAuthor = photoAuthor; - imageDetails.photoDate = photoDate; - imageDetails.photoUrl = url; - imageDetails.rating = 0; - scaleMe.state = "Details"; - } - - Item { - id: gridwrapper; - width: GridView.view.cellWidth; height: GridView.view.cellHeight - Package.name: "grid" - } - Item { - id: streamwrapper; - width: 80; height: 80 - Package.name: "stream" - } - Item { - //anchors.centerIn: parent//Doesn't animate :( - width: 80; height: 80 - scale: 0.0 - Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} } - id: scaleMe - - Item { - id: whiteRectContainer - width: 77; height: 77; anchors.centerIn: parent - Rectangle { - id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true - x:0; y:0 - Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true } - Image { source: "images/gloss.png" } - MouseArea { anchors.fill: parent; onClicked: photoClicked() } - } - } - - Connections { - target: toolBar - onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' - } - - state: 'inStream' - states: [ - State { - name: "Show"; when: thumb.status == Image.Ready - PropertyChanges { target: scaleMe; scale: 1; } - }, - State { - name: "Details" - PropertyChanges { target: scaleMe; scale: 1 } - ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer } - PropertyChanges { target: background; state: "DetailedView" } - } - ] - transitions: [ - Transition { - from: "Show"; to: "Details" - ParentAnimation { - via: foreground - NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } - } - }, - Transition { - from: "Details"; to: "Show" - SequentialAnimation{ - ParentAnimation { - via: foreground - NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } - } - } - } - ] - Item{ - id: stateContainer - states: [ - State { - name: 'inStream' - when: screen.inGridView == false - ParentChange { - target: scaleMe; parent: streamwrapper - x: 0; y: 0; - } - }, - State { - name: 'inGrid' - when: screen.inGridView == true - ParentChange { - target: scaleMe; parent: gridwrapper - x: 0; y: 0; - } - } - ] - - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { target: scaleMe; properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } - } -} diff --git a/examples/declarative/flickr/content/images/gloss.png b/examples/declarative/flickr/content/images/gloss.png deleted file mode 100644 index 5d370cd93d..0000000000 Binary files a/examples/declarative/flickr/content/images/gloss.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/lineedit.png b/examples/declarative/flickr/content/images/lineedit.png deleted file mode 100644 index 2cc38dc35b..0000000000 Binary files a/examples/declarative/flickr/content/images/lineedit.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/lineedit.sci b/examples/declarative/flickr/content/images/lineedit.sci deleted file mode 100644 index 054bff78be..0000000000 --- a/examples/declarative/flickr/content/images/lineedit.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 10 -border.bottom: 10 -border.right: 10 -source: lineedit.png diff --git a/examples/declarative/flickr/content/images/noise.png b/examples/declarative/flickr/content/images/noise.png deleted file mode 100644 index c5a5ba0053..0000000000 Binary files a/examples/declarative/flickr/content/images/noise.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/particle.png b/examples/declarative/flickr/content/images/particle.png deleted file mode 100644 index dbc39cb16e..0000000000 Binary files a/examples/declarative/flickr/content/images/particle.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/quit.png b/examples/declarative/flickr/content/images/quit.png deleted file mode 100644 index 5bda1b6e0d..0000000000 Binary files a/examples/declarative/flickr/content/images/quit.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/squareParticle.png b/examples/declarative/flickr/content/images/squareParticle.png deleted file mode 100644 index faf85c24e0..0000000000 Binary files a/examples/declarative/flickr/content/images/squareParticle.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/stripes.png b/examples/declarative/flickr/content/images/stripes.png deleted file mode 100644 index 9f36727ea4..0000000000 Binary files a/examples/declarative/flickr/content/images/stripes.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/titlebar.png b/examples/declarative/flickr/content/images/titlebar.png deleted file mode 100644 index 51c90082d0..0000000000 Binary files a/examples/declarative/flickr/content/images/titlebar.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/titlebar.sci b/examples/declarative/flickr/content/images/titlebar.sci deleted file mode 100644 index 0418d94cd6..0000000000 --- a/examples/declarative/flickr/content/images/titlebar.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 12 -border.bottom: 12 -border.right: 10 -source: titlebar.png diff --git a/examples/declarative/flickr/content/images/toolbutton.png b/examples/declarative/flickr/content/images/toolbutton.png deleted file mode 100644 index 11310013ee..0000000000 Binary files a/examples/declarative/flickr/content/images/toolbutton.png and /dev/null differ diff --git a/examples/declarative/flickr/content/images/toolbutton.sci b/examples/declarative/flickr/content/images/toolbutton.sci deleted file mode 100644 index 9e4f965307..0000000000 --- a/examples/declarative/flickr/content/images/toolbutton.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 15 -border.top: 4 -border.bottom: 4 -border.right: 15 -source: toolbutton.png diff --git a/examples/declarative/flickr/content/qmldir b/examples/declarative/flickr/content/qmldir deleted file mode 100644 index adc2479b9f..0000000000 --- a/examples/declarative/flickr/content/qmldir +++ /dev/null @@ -1,10 +0,0 @@ -ImageDetails ImageDetails.qml -LikeOMeter LikeOMeter.qml -Loading Loading.qml -MediaButton MediaButton.qml -MediaLineEdit MediaLineEdit.qml -Progress Progress.qml -RssModel RssModel.qml -ScrollBar ScrollBar.qml -Slider Slider.qml -Star Star.qml diff --git a/examples/declarative/flickr/flickr-90.qml b/examples/declarative/flickr/flickr-90.qml deleted file mode 100644 index ae06957649..0000000000 --- a/examples/declarative/flickr/flickr-90.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - width: 480; height: 320 - - Loader { - y: 320; rotation: -90 - transformOrigin: Item.TopLeft - source: "flickr.qml" - } -} diff --git a/examples/declarative/flickr/flickr.qml b/examples/declarative/flickr/flickr.qml deleted file mode 100644 index 74c41f185b..0000000000 --- a/examples/declarative/flickr/flickr.qml +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content" - -Item { - id: screen; width: 320; height: 480 - property bool inGridView : true - - Rectangle { - id: background - anchors.fill: parent; color: "#343434"; - - Image { source: "content/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } - ParticleSystem { - id: bgParticles - anchors.fill: parent - ImageParticle { - groups: ["trail"] - source: "content/images/particle.png" - color: "#1A1A6F" - alpha: 0.1 - colorVariation: 0.01 - blueVariation: 0.8 - } - Emitter { - group: "drops" - width: parent.width - emitRate: 0.5 - lifeSpan: 20000 - startTime: 16000 - speed: PointDirection{ - y: {screen.height/18} - } - } - TrailEmitter { - follow: "drops" - group: "trail" - emitRatePerParticle: 18 - size: 32 - endSize: 0 - sizeVariation: 4 - lifeSpan: 1200 - anchors.fill: parent - emitWidth: 16 - emitHeight: 16 - emitShape: EllipseShape{} - } - } - - VisualDataModel{ - id: vdm - delegate: UnifiedDelegate{} - model: RssModel { id: rssModel } - } - - Item { - id: views - width: parent.width - anchors.top: titleBar.bottom; anchors.bottom: toolBar.top - - GridView { - id: photoGridView; model: vdm.parts.grid - cacheBuffer: 1000 - cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height - } - - states: State { - name: "GridView"; when: state.inGridView == true - } - - transitions: Transition { - NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } - } - - ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height } - - Item { id: foreground; anchors.fill: parent } - } - - TitleBar { id: titleBar; width: parent.width; height: 40; opacity: 0.9 } - - ToolBar { - id: toolBar - height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9 - button1Label: "Update"; button2Label: "View mode" - onButton1Clicked: rssModel.reload() - onButton2Clicked: if (screen.inGridView == true) screen.inGridView = false; else screen.inGridView = true - } - - Connections { - target: imageDetails - onClosed: { - if (background.state == "DetailedView") { - background.state = ''; - imageDetails.photoUrl = ""; - } - } - } - - states: State { - name: "DetailedView" - PropertyChanges { target: views; x: -parent.width } - PropertyChanges { target: toolBar; button1Label: "View..." } - PropertyChanges { - target: toolBar - onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state='' - } - PropertyChanges { target: toolBar; button2Label: "Back" } - PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() } - } - - transitions: Transition { - NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } - } - - } -} diff --git a/examples/declarative/flickr/flickr.qmlproject b/examples/declarative/flickr/flickr.qmlproject deleted file mode 100644 index af5179d84b..0000000000 --- a/examples/declarative/flickr/flickr.qmlproject +++ /dev/null @@ -1,17 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "flickr.qml" - //mainFile: "flickr-90.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/i18n/i18n.qml b/examples/declarative/i18n/i18n.qml deleted file mode 100644 index f8bf30d0f0..0000000000 --- a/examples/declarative/i18n/i18n.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -// -// The QML runtime automatically loads a translation from the i18n subdirectory of the root -// QML file, based on the system language. -// -// The files are created/updated by running: -// -// lupdate i18n.qml -ts i18n/base.ts -// -// Translations for new languages are created by copying i18n/base.ts to i18n/qml_.ts -// The .ts files can then be edited with Linguist: -// -// linguist i18n/qml_fr.ts -// -// The run-time translation files are then generated by running: -// -// lrelease i18n/*.ts -// - -Rectangle { - width: 640; height: 480 - - Column { - anchors.fill: parent; spacing: 20 - - Text { - text: "If a translation is available for the system language (eg. French) then the "+ - "string below will translated (eg. 'Bonjour'). Otherwise it will show 'Hello'." - width: parent.width; wrapMode: Text.WordWrap - } - - Text { - text: qsTr("Hello") - font.pointSize: 25; anchors.horizontalCenter: parent.horizontalCenter - } - } -} diff --git a/examples/declarative/i18n/i18n/base.ts b/examples/declarative/i18n/i18n/base.ts deleted file mode 100644 index 82547a1f93..0000000000 --- a/examples/declarative/i18n/i18n/base.ts +++ /dev/null @@ -1,12 +0,0 @@ - - - - - i18n - - - Hello - - - - diff --git a/examples/declarative/i18n/i18n/qml_en_AU.ts b/examples/declarative/i18n/i18n/qml_en_AU.ts deleted file mode 100644 index e991affe7f..0000000000 --- a/examples/declarative/i18n/i18n/qml_en_AU.ts +++ /dev/null @@ -1,12 +0,0 @@ - - - - - i18n - - - Hello - G'day - - - diff --git a/examples/declarative/i18n/i18n/qml_fr.ts b/examples/declarative/i18n/i18n/qml_fr.ts deleted file mode 100644 index 365abd95c2..0000000000 --- a/examples/declarative/i18n/i18n/qml_fr.ts +++ /dev/null @@ -1,12 +0,0 @@ - - - - - i18n - - - Hello - Bonjour - - - diff --git a/examples/declarative/imageelements/borderimage.qml b/examples/declarative/imageelements/borderimage.qml deleted file mode 100644 index 3dd5d1d9bb..0000000000 --- a/examples/declarative/imageelements/borderimage.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: page - width: 1030; height: 540 - - Grid { - anchors.centerIn: parent; spacing: 20 - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round - } - } -} diff --git a/examples/declarative/imageelements/content/BearSheet.png b/examples/declarative/imageelements/content/BearSheet.png deleted file mode 100644 index a084bf0f1e..0000000000 Binary files a/examples/declarative/imageelements/content/BearSheet.png and /dev/null differ diff --git a/examples/declarative/imageelements/content/ImageCell.qml b/examples/declarative/imageelements/content/ImageCell.qml deleted file mode 100644 index fcc6b47af5..0000000000 --- a/examples/declarative/imageelements/content/ImageCell.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - property alias mode: image.fillMode - property alias caption: captionItem.text - - width: parent.cellWidth; height: parent.cellHeight - - Image { - id: image - width: parent.width; height: parent.height - captionItem.height - source: "qt-logo.png" - clip: true // only makes a difference if mode is PreserveAspectCrop - smooth: true - } - - Text { - id: captionItem - anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom - } -} diff --git a/examples/declarative/imageelements/content/MyBorderImage.qml b/examples/declarative/imageelements/content/MyBorderImage.qml deleted file mode 100644 index 178e3706db..0000000000 --- a/examples/declarative/imageelements/content/MyBorderImage.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property alias horizontalMode: image.horizontalTileMode - property alias verticalMode: image.verticalTileMode - property alias source: image.source - - property int minWidth - property int minHeight - property int maxWidth - property int maxHeight - property int margin - - width: 240; height: 240 - - BorderImage { - id: image; anchors.centerIn: parent - - SequentialAnimation on width { - loops: Animation.Infinite - NumberAnimation { - from: container.minWidth; to: container.maxWidth - duration: 2000; easing.type: Easing.InOutQuad - } - NumberAnimation { - from: container.maxWidth; to: container.minWidth - duration: 2000; easing.type: Easing.InOutQuad - } - } - - SequentialAnimation on height { - loops: Animation.Infinite - NumberAnimation { - from: container.minHeight; to: container.maxHeight - duration: 2000; easing.type: Easing.InOutQuad - } - NumberAnimation { - from: container.maxHeight; to: container.minHeight - duration: 2000; easing.type: Easing.InOutQuad - } - } - - border.top: container.margin - border.left: container.margin - border.bottom: container.margin - border.right: container.margin - } -} diff --git a/examples/declarative/imageelements/content/ShadowRectangle.qml b/examples/declarative/imageelements/content/ShadowRectangle.qml deleted file mode 100644 index e6fd13bb26..0000000000 --- a/examples/declarative/imageelements/content/ShadowRectangle.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - property alias color : rectangle.color - - BorderImage { - anchors.fill: rectangle - anchors { leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } - border { left: 10; top: 10; right: 10; bottom: 10 } - source: "shadow.png"; smooth: true - } - - Rectangle { id: rectangle; anchors.fill: parent } -} diff --git a/examples/declarative/imageelements/content/bw.png b/examples/declarative/imageelements/content/bw.png deleted file mode 100644 index 486eaae96e..0000000000 Binary files a/examples/declarative/imageelements/content/bw.png and /dev/null differ diff --git a/examples/declarative/imageelements/content/colors-round.sci b/examples/declarative/imageelements/content/colors-round.sci deleted file mode 100644 index 506f6f5f99..0000000000 --- a/examples/declarative/imageelements/content/colors-round.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:30 -border.top:30 -border.right:30 -border.bottom:30 -horizontalTileRule:Round -verticalTileRule:Round -source:colors.png diff --git a/examples/declarative/imageelements/content/colors-stretch.sci b/examples/declarative/imageelements/content/colors-stretch.sci deleted file mode 100644 index e4989a723c..0000000000 --- a/examples/declarative/imageelements/content/colors-stretch.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left:30 -border.top:30 -border.right:30 -border.bottom:30 -source:colors.png diff --git a/examples/declarative/imageelements/content/colors.png b/examples/declarative/imageelements/content/colors.png deleted file mode 100644 index dfb62f3d64..0000000000 Binary files a/examples/declarative/imageelements/content/colors.png and /dev/null differ diff --git a/examples/declarative/imageelements/content/qt-logo.png b/examples/declarative/imageelements/content/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/examples/declarative/imageelements/content/qt-logo.png and /dev/null differ diff --git a/examples/declarative/imageelements/content/shadow.png b/examples/declarative/imageelements/content/shadow.png deleted file mode 100644 index 431af8545d..0000000000 Binary files a/examples/declarative/imageelements/content/shadow.png and /dev/null differ diff --git a/examples/declarative/imageelements/content/speaker.png b/examples/declarative/imageelements/content/speaker.png deleted file mode 100644 index fb0e857859..0000000000 Binary files a/examples/declarative/imageelements/content/speaker.png and /dev/null differ diff --git a/examples/declarative/imageelements/image.qml b/examples/declarative/imageelements/image.qml deleted file mode 100644 index 4ca26c1630..0000000000 --- a/examples/declarative/imageelements/image.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - width: 490 - height: 285 - - Grid { - property int cellWidth: (width - (spacing * (columns - 1))) / columns - property int cellHeight: (height - (spacing * (rows - 1))) / rows - - anchors.fill: parent - anchors.margins: 30 - - columns: 3 - rows: 2 - spacing: 30 - - ImageCell { mode: Image.Stretch; caption: "Stretch" } - ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" } - ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" } - - ImageCell { mode: Image.Tile; caption: "Tile" } - ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" } - ImageCell { mode: Image.TileVertically; caption: "TileVertically" } - } -} diff --git a/examples/declarative/imageelements/imageelements.qml b/examples/declarative/imageelements/imageelements.qml deleted file mode 100644 index 2ef5154968..0000000000 --- a/examples/declarative/imageelements/imageelements.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../shared" - -Item { - height: 480 - width: 640 - LauncherList { - id: ll - anchors.fill: parent - Component.onCompleted: { - addExample("BorderImage", "An image with scaled borders", Qt.resolvedUrl("borderimage.qml")); - addExample("Image", "A showcase of the options available to Image", Qt.resolvedUrl("image.qml")); - addExample("Shadows", "Rectangles with a drop-shadow effect", Qt.resolvedUrl("shadows.qml")); - addExample("Simple Sprite", "A simple sprite-based animation", Qt.resolvedUrl("simplesprite.qml")); - addExample("Sprite Image", "A sprite-based animation with complex transitions", Qt.resolvedUrl("spriteimage.qml")); - } - } -} diff --git a/examples/declarative/imageelements/imageelements.qmlproject b/examples/declarative/imageelements/imageelements.qmlproject deleted file mode 100644 index 4292a0c112..0000000000 --- a/examples/declarative/imageelements/imageelements.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "imageelements.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/imageelements/shadows.qml b/examples/declarative/imageelements/shadows.qml deleted file mode 100644 index aa5022ab36..0000000000 --- a/examples/declarative/imageelements/shadows.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "gray" - - ShadowRectangle { - anchors.centerIn: parent; width: 250; height: 250 - color: "lightsteelblue" - } - - ShadowRectangle { - anchors.centerIn: parent; width: 200; height: 200 - color: "steelblue" - } - - ShadowRectangle { - anchors.centerIn: parent; width: 150; height: 150 - color: "thistle" - } -} diff --git a/examples/declarative/imageelements/simplesprite.qml b/examples/declarative/imageelements/simplesprite.qml deleted file mode 100644 index f619913bfc..0000000000 --- a/examples/declarative/imageelements/simplesprite.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - width: 400 - height: 400 - Rectangle { - anchors.fill: parent - color: "white" - } - SpriteImage { - anchors.fill: parent - Sprite{ - source: "content/speaker.png" - frames: 60 - frameSync: true - frameWidth: 170 - frameHeight: 170 - } - } -} diff --git a/examples/declarative/imageelements/spriteimage.qml b/examples/declarative/imageelements/spriteimage.qml deleted file mode 100644 index 559bb10a50..0000000000 --- a/examples/declarative/imageelements/spriteimage.qml +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - width: 480 - height: 1280 - MouseArea { - onClicked: anim.start(); - anchors.fill: parent - } - SequentialAnimation { - id: anim - ScriptAction { script: image.goalSprite = "falling"; } - NumberAnimation { target: image; property: "y"; to: 1480; duration: 12000; } - ScriptAction { script: {image.goalSprite = ""; image.jumpTo("still");} } - PropertyAction { target: image; property: "y"; value: 0 } - } - SpriteImage { - id: image - width: 256 - height: 256 - anchors.horizontalCenter: parent.horizontalCenter - interpolate: false - goalSprite: "" - Sprite{ - name: "still" - source: "content/BearSheet.png" - frames: 1 - frameWidth: 256 - frameHeight: 256 - frameDuration: 100 - to: {"still":1, "blink":0.1, "floating":0} - } - Sprite{ - name: "blink" - source: "content/BearSheet.png" - frames: 3 - frameX: 256 - frameY: 1536 - frameWidth: 256 - frameHeight: 256 - frameDuration: 100 - to: {"still":1} - } - Sprite{ - name: "floating" - source: "content/BearSheet.png" - frames: 9 - frameX: 0 - frameY: 0 - frameWidth: 256 - frameHeight: 256 - frameDuration: 160 - to: {"still":0, "flailing":1} - } - Sprite{ - name: "flailing" - source: "content/BearSheet.png" - frames: 8 - frameX: 0 - frameY: 768 - frameWidth: 256 - frameHeight: 256 - frameDuration: 160 - to: {"falling":1} - } - Sprite{ - name: "falling" - source: "content/BearSheet.png" - frames: 5 - frameY: 1280 - frameWidth: 256 - frameHeight: 256 - frameDuration: 160 - to: {"falling":1} - } - } -} diff --git a/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml b/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml deleted file mode 100644 index dc68aa2b30..0000000000 --- a/examples/declarative/keyinteraction/focus/Core/ContextMenu.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - id: container - - property bool open: false - - Item { - anchors.fill: parent - - Rectangle { - anchors.fill: parent - color: "#D1DBBD" - focus: true - Keys.onRightPressed: mainView.focus = true - - Text { - anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; margins: 30 } - color: "black" - font.pixelSize: 14 - text: "Context Menu" - } - } - } -} diff --git a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml deleted file mode 100644 index 75bbe682af..0000000000 --- a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - property alias interactive: gridView.interactive - - onActiveFocusChanged: { - if (activeFocus) - mainView.state = "" - } - - Rectangle { - anchors.fill: parent - clip: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#193441" } - GradientStop { position: 1.0; color: Qt.darker("#193441") } - } - - GridView { - id: gridView - anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20 - cellWidth: 152; cellHeight: 152 - focus: true - model: 12 - - KeyNavigation.down: listMenu - KeyNavigation.left: contextMenu - - delegate: Item { - id: container - width: GridView.view.cellWidth; height: GridView.view.cellHeight - - Rectangle { - id: content - color: "transparent" - smooth: true - anchors.fill: parent; anchors.margins: 20; radius: 10 - - Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; smooth: true } - Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - container.GridView.view.currentIndex = index - container.forceActiveFocus() - } - } - - states: State { - name: "active"; when: container.activeFocus - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - } - - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } - } - } - } -} diff --git a/examples/declarative/keyinteraction/focus/Core/ListMenu.qml b/examples/declarative/keyinteraction/focus/Core/ListMenu.qml deleted file mode 100644 index 7a62f33428..0000000000 --- a/examples/declarative/keyinteraction/focus/Core/ListMenu.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - clip: true - - onActiveFocusChanged: { - if (activeFocus) - mainView.state = "showListViews" - } - - ListView { - id: list1 - y: activeFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20 - focus: true - KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list2 - y: activeFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list3 - y: activeFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: gridMenu; KeyNavigation.left: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - Rectangle { width: parent.width; height: 1; color: "#D1DBBD" } - - Rectangle { - y: 1; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 0.0; color: "#3E606F" } - GradientStop { position: 1.0; color: "transparent" } - } - } - - Rectangle { - y: parent.height - 10; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 1.0; color: "#3E606F" } - GradientStop { position: 0.0; color: "transparent" } - } - } -} diff --git a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml deleted file mode 100644 index b28b02616d..0000000000 --- a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10 - - Rectangle { - id: content - anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 - color: "transparent" - smooth: true - radius: 10 - - Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; smooth: true; radius: 8 } - } - - Text { - id: label - anchors.centerIn: content - text: "List element " + (index + 1) - color: "#193441" - font.pixelSize: 14 - } - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - container.ListView.view.currentIndex = index - container.forceActiveFocus() - } - } - - states: State { - name: "active"; when: container.activeFocus - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - PropertyChanges { target: label; font.pixelSize: 16 } - } - - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } -} diff --git a/examples/declarative/keyinteraction/focus/Core/images/arrow.png b/examples/declarative/keyinteraction/focus/Core/images/arrow.png deleted file mode 100644 index 14978c2e56..0000000000 Binary files a/examples/declarative/keyinteraction/focus/Core/images/arrow.png and /dev/null differ diff --git a/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png b/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/examples/declarative/keyinteraction/focus/Core/images/qt-logo.png and /dev/null differ diff --git a/examples/declarative/keyinteraction/focus/focus.qml b/examples/declarative/keyinteraction/focus/focus.qml deleted file mode 100644 index 9300ad4f6e..0000000000 --- a/examples/declarative/keyinteraction/focus/focus.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "Core" - -Rectangle { - id: window - - width: 800; height: 480 - color: "#3E606F" - - FocusScope { - id: mainView - - width: parent.width; height: parent.height - focus: true - - GridMenu { - id: gridMenu - width: parent.width; height: 320 - - focus: true - interactive: parent.activeFocus - } - - ListMenu { - id: listMenu - y: 320; width: parent.width; height: 320 - } - - Rectangle { - id: shade - anchors.fill: parent - color: "black" - opacity: 0 - } - - states: State { - name: "showListViews" - PropertyChanges { target: gridMenu; y: -160 } - PropertyChanges { target: listMenu; y: 160 } - } - - transitions: Transition { - NumberAnimation { properties: "y"; duration: 600; easing.type: Easing.OutQuint } - } - } - - Image { - source: "Core/images/arrow.png" - rotation: 90 - anchors.verticalCenter: parent.verticalCenter - - MouseArea { - anchors.fill: parent; anchors.margins: -10 - onClicked: contextMenu.focus = true - } - } - - ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height } - - states: State { - name: "contextMenuOpen" - when: !mainView.activeFocus - PropertyChanges { target: contextMenu; x: 0; open: true } - PropertyChanges { target: mainView; x: 130 } - PropertyChanges { target: shade; opacity: 0.25 } - } - - transitions: Transition { - NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: Easing.OutQuint } - } -} diff --git a/examples/declarative/locale/locale.qml b/examples/declarative/locale/locale.qml deleted file mode 100644 index 08d08d6bbd..0000000000 --- a/examples/declarative/locale/locale.qml +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - width: 320 - height: 480 - color: "lightgray" - - property string locale: view.currentItem.locale - - Text { - id: title - text: "Select locale:" - } - - Rectangle { - id: chooser - anchors.top: title.bottom - anchors.topMargin: 5 - width: parent.width-10 - x: 5 - height: parent.height/2 - 10 - color: "#40300030" - ListView { - id: view - clip: true - focus: true - anchors.fill: parent - model: [ - "en_US", - "en_GB", - "fi_FI", - "de_DE", - "ar_SA", - "hi_IN", - "zh_CN", - "th_TH", - "fr_FR", - "nb_NO", - "sv_SE" - ] - delegate: Text { - property string locale: modelData - height: 30 - width: view.width - text: Qt.locale(modelData).name + " ("+ Qt.locale(modelData).nativeCountryName + "/" + Qt.locale(modelData).nativeLanguageName + ")" - MouseArea { - anchors.fill: parent - onClicked: view.currentIndex = index - } - } - highlight: Rectangle { - height: 30 - color: "#60300030" - } - } - } - - Rectangle { - color: "white" - anchors.top: chooser.bottom - anchors.topMargin: 5 - anchors.bottom: parent.bottom - anchors.bottomMargin: 5 - x: 5; width: parent.width - 10 - - Column { - anchors.fill: parent - spacing: 5 - Text { - property var date: new Date() - text: "Date: " + date.toLocaleDateString(Qt.locale(root.locale)) - } - Text { - property var date: new Date() - text: "Time: " + date.toLocaleTimeString(Qt.locale(root.locale)) - } - Text { - property var dow: Qt.locale(root.locale).firstDayOfWeek - text: "First day of week: " + Qt.locale(root.locale).standaloneDayName(dow) - } - Text { - property var num: 10023823 - text: "Number: " + num.toLocaleString(Qt.locale(root.locale)) - } - Text { - property var num: 10023823 - text: "Currency: " + num.toLocaleCurrencyString(Qt.locale(root.locale)) - } - } - } -} diff --git a/examples/declarative/minehunt/MinehuntCore/Explosion.qml b/examples/declarative/minehunt/MinehuntCore/Explosion.qml deleted file mode 100644 index 0983b68db4..0000000000 --- a/examples/declarative/minehunt/MinehuntCore/Explosion.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - property bool explode : false - ParticleSystem { - width: 40 - height: 40 - ImageParticle { - groups: ["star"] - source: "file:MinehuntCore/pics/star.png" // TODO: Use qrc path once QTBUG-21129 is fixed - } - Emitter { - id: particles - enabled: false - anchors.centerIn: parent - group: "star" - speed: AngleDirection { angleVariation: 360; magnitude: 150; magnitudeVariation: 50 } - emitRate: 200 - z: 100 - lifeSpan: 1000 - } - } - states: State { name: "exploding"; when: explode - StateChangeScript { script: particles.burst(200); } - } - -} diff --git a/examples/declarative/minehunt/MinehuntCore/Tile.qml b/examples/declarative/minehunt/MinehuntCore/Tile.qml deleted file mode 100644 index 14c1f51f9e..0000000000 --- a/examples/declarative/minehunt/MinehuntCore/Tile.qml +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Flipable { - id: flipable - property int angle: 0 - - width: 40; height: 40 - transform: Rotation { origin.x: 20; origin.y: 20; axis.x: 1; axis.z: 0; angle: flipable.angle } - - front: Image { - source: "pics/front.png"; width: 40; height: 40 - - Image { - anchors.centerIn: parent - source: "pics/flag.png"; opacity: modelData.hasFlag - - Behavior on opacity { NumberAnimation {} } - } - } - - back: Image { - source: "pics/back.png" - width: 40; height: 40 - - Text { - anchors.centerIn: parent - text: modelData.hint; color: "white"; font.bold: true - opacity: !modelData.hasMine && modelData.hint > 0 - } - - Image { - anchors.centerIn: parent - source: "pics/bomb.png"; opacity: modelData.hasMine - } - - Explosion { id: expl } - } - - states: State { - name: "back"; when: modelData.flipped - PropertyChanges { target: flipable; angle: 180 } - } - - property real pauseDur: 250 - transitions: Transition { - SequentialAnimation { - ScriptAction { - script: { - var ret = Math.abs(flipable.x - field.clickx) - + Math.abs(flipable.y - field.clicky); - if (modelData.hasMine && modelData.flipped) - pauseDur = ret * 3 - else - pauseDur = ret - } - } - PauseAnimation { - duration: pauseDur - } - RotationAnimation { easing.type: Easing.InOutQuad } - ScriptAction { script: if (modelData.hasMine && modelData.flipped) { expl.explode = true } } - } - } - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - field.clickx = flipable.x - field.clicky = flipable.y - var row = Math.floor(index / 9) - var col = index - (Math.floor(index / 9) * 9) - if (mouse.button == undefined || mouse.button == Qt.RightButton) { - flag(row, col) - } else { - flip(row, col) - } - } - onPressAndHold: { - field.clickx = flipable.x - field.clicky = flipable.y - var row = Math.floor(index / 9) - var col = index - (Math.floor(index / 9) * 9) - flag(row, col) - } - } -} diff --git a/examples/declarative/minehunt/MinehuntCore/pics/back.png b/examples/declarative/minehunt/MinehuntCore/pics/back.png deleted file mode 100644 index f6b3f0b4d7..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/back.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/background.png b/examples/declarative/minehunt/MinehuntCore/pics/background.png deleted file mode 100644 index 3734a27744..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/background.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/bomb-color.png b/examples/declarative/minehunt/MinehuntCore/pics/bomb-color.png deleted file mode 100644 index 61ad0a928f..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/bomb-color.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/bomb.png b/examples/declarative/minehunt/MinehuntCore/pics/bomb.png deleted file mode 100644 index a992575518..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/bomb.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/face-sad.png b/examples/declarative/minehunt/MinehuntCore/pics/face-sad.png deleted file mode 100644 index cf00aafe1f..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/face-sad.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.png b/examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.png deleted file mode 100644 index f9c2335df5..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/face-smile-big.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/face-smile.png b/examples/declarative/minehunt/MinehuntCore/pics/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/face-smile.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/flag-color.png b/examples/declarative/minehunt/MinehuntCore/pics/flag-color.png deleted file mode 100644 index aadad0f11a..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/flag-color.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/flag.png b/examples/declarative/minehunt/MinehuntCore/pics/flag.png deleted file mode 100644 index 39cde4df82..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/flag.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/front.png b/examples/declarative/minehunt/MinehuntCore/pics/front.png deleted file mode 100644 index 834331bd49..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/front.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/quit.png b/examples/declarative/minehunt/MinehuntCore/pics/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/quit.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/pics/star.png b/examples/declarative/minehunt/MinehuntCore/pics/star.png deleted file mode 100644 index 3772359188..0000000000 Binary files a/examples/declarative/minehunt/MinehuntCore/pics/star.png and /dev/null differ diff --git a/examples/declarative/minehunt/MinehuntCore/qmldir b/examples/declarative/minehunt/MinehuntCore/qmldir deleted file mode 100644 index a0213a19c4..0000000000 --- a/examples/declarative/minehunt/MinehuntCore/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Explosion 2.0 Explosion.qml -Tile 2.0 Tile.qml diff --git a/examples/declarative/minehunt/README b/examples/declarative/minehunt/README deleted file mode 100644 index 3849ca5fbf..0000000000 --- a/examples/declarative/minehunt/README +++ /dev/null @@ -1,6 +0,0 @@ -Minehunt has to be compiled to run. - -To compile the C++ part, do 'qmake && make'. -To run, simply run the executable. -To deploy on a device, do 'make sis'. - diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp deleted file mode 100644 index 47c0436969..0000000000 --- a/examples/declarative/minehunt/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -#include "minehunt.h" - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - QQuickView canvas; - - qmlRegisterType(); - MinehuntGame* game = new MinehuntGame(); - - canvas.setResizeMode(QQuickView::SizeRootObjectToView); - canvas.engine()->rootContext()->setContextObject(game); - canvas.setSource(QString("qrc:///minehunt.qml")); - QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit())); - - canvas.show(); - return app.exec(); -} diff --git a/examples/declarative/minehunt/minehunt.cpp b/examples/declarative/minehunt/minehunt.cpp deleted file mode 100644 index facbec375a..0000000000 --- a/examples/declarative/minehunt/minehunt.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -#include "minehunt.h" - -void tilesPropAppend(QDeclarativeListProperty* prop, TileData* value) -{ - Q_UNUSED(prop); - Q_UNUSED(value); - return; //Append not supported -} - -int tilesPropCount(QDeclarativeListProperty* prop) -{ - return static_cast*>(prop->data)->count(); -} - -TileData* tilesPropAt(QDeclarativeListProperty* prop, int index) -{ - return static_cast*>(prop->data)->at(index); -} - -QDeclarativeListProperty MinehuntGame::tiles(){ - return QDeclarativeListProperty(this, &_tiles, &tilesPropAppend, - &tilesPropCount, &tilesPropAt, 0); -} - -MinehuntGame::MinehuntGame() -: numCols(9), numRows(9), playing(true), won(false) -{ - setObjectName("mainObject"); - srand(QTime(0,0,0).secsTo(QTime::currentTime())); - - //initialize array - for(int ii = 0; ii < numRows * numCols; ++ii) { - _tiles << new TileData; - } - reset(); - -} - -void MinehuntGame::setBoard() -{ - foreach(TileData* t, _tiles){ - t->setHasMine(false); - t->setHint(-1); - } - //place mines - int mines = nMines; - remaining = numRows*numCols-mines; - while ( mines ) { - int col = int((double(rand()) / double(RAND_MAX)) * numCols); - int row = int((double(rand()) / double(RAND_MAX)) * numRows); - - TileData* t = tile( row, col ); - - if (t && !t->hasMine()) { - t->setHasMine( true ); - mines--; - } - } - - //set hints - for (int r = 0; r < numRows; r++) - for (int c = 0; c < numCols; c++) { - TileData* t = tile(r, c); - if (t && !t->hasMine()) { - int hint = getHint(r,c); - t->setHint(hint); - } - } - - setPlaying(true); -} - -void MinehuntGame::reset() -{ - foreach(TileData* t, _tiles){ - t->unflip(); - t->setHasFlag(false); - } - nMines = 12; - nFlags = 0; - emit numMinesChanged(); - emit numFlagsChanged(); - setPlaying(false); - QTimer::singleShot(600,this, SLOT(setBoard())); -} - -int MinehuntGame::getHint(int row, int col) -{ - int hint = 0; - for (int c = col-1; c <= col+1; c++) - for (int r = row-1; r <= row+1; r++) { - TileData* t = tile(r, c); - if (t && t->hasMine()) - hint++; - } - return hint; -} - -bool MinehuntGame::flip(int row, int col) -{ - if(!playing) - return false; - - TileData *t = tile(row, col); - if (!t || t->hasFlag()) - return false; - - if(t->flipped()){ - int flags = 0; - for (int c = col-1; c <= col+1; c++) - for (int r = row-1; r <= row+1; r++) { - TileData *nearT = tile(r, c); - if(!nearT || nearT == t) - continue; - if(nearT->hasFlag()) - flags++; - } - if(!t->hint() || t->hint() != flags) - return false; - for (int c = col-1; c <= col+1; c++) - for (int r = row-1; r <= row+1; r++) { - TileData *nearT = tile(r, c); - if (nearT && !nearT->flipped() && !nearT->hasFlag()) { - flip( r, c ); - } - } - return true; - } - - t->flip(); - - if (t->hint() == 0) { - for (int c = col-1; c <= col+1; c++) - for (int r = row-1; r <= row+1; r++) { - TileData* t = tile(r, c); - if (t && !t->flipped()) { - flip( r, c ); - } - } - } - - if(t->hasMine()){ - for (int r = 0; r < numRows; r++)//Flip all other mines - for (int c = 0; c < numCols; c++) { - TileData* t = tile(r, c); - if (t && t->hasMine()) { - flip(r, c); - } - } - won = false; - hasWonChanged(); - setPlaying(false); - return true; - } - - remaining--; - if(!remaining){ - won = true; - hasWonChanged(); - setPlaying(false); - return true; - } - return true; -} - -bool MinehuntGame::flag(int row, int col) -{ - TileData *t = tile(row, col); - if(!t || !playing || t->flipped()) - return false; - - t->setHasFlag(!t->hasFlag()); - nFlags += (t->hasFlag()?1:-1); - emit numFlagsChanged(); - return true; -} diff --git a/examples/declarative/minehunt/minehunt.h b/examples/declarative/minehunt/minehunt.h deleted file mode 100644 index a0ae23fa8a..0000000000 --- a/examples/declarative/minehunt/minehunt.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include - -class TileData : public QObject -{ - Q_OBJECT -public: - TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {} - - Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged) - bool hasFlag() const { return _hasFlag; } - - Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged) - bool hasMine() const { return _hasMine; } - - Q_PROPERTY(int hint READ hint NOTIFY hintChanged) - int hint() const { return _hint; } - - Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged()) - bool flipped() const { return _flipped; } - - void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();} - void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();} - void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); } - void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); } - void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); } - -signals: - void flippedChanged(); - void hasFlagChanged(); - void hintChanged(); - void hasMineChanged(); - -private: - bool _hasFlag; - bool _hasMine; - int _hint; - bool _flipped; -}; - -class MinehuntGame : public QObject -{ - Q_OBJECT -public: - MinehuntGame(); - - Q_PROPERTY(QDeclarativeListProperty tiles READ tiles CONSTANT) - QDeclarativeListProperty tiles(); - - Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged) - bool isPlaying() {return playing;} - - Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged) - bool hasWon() {return won;} - - Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged) - int numMines() const{return nMines;} - - Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged) - int numFlags() const{return nFlags;} - -public slots: - Q_INVOKABLE bool flip(int row, int col); - Q_INVOKABLE bool flag(int row, int col); - void setBoard(); - void reset(); - -signals: - void isPlayingChanged(); - void hasWonChanged(); - void numMinesChanged(); - void numFlagsChanged(); - -private: - bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; } - TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; } - int getHint(int row, int col); - void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} - - QList _tiles; - int numCols; - int numRows; - bool playing; - bool won; - int remaining; - int nMines; - int nFlags; -}; diff --git a/examples/declarative/minehunt/minehunt.pro b/examples/declarative/minehunt/minehunt.pro deleted file mode 100644 index 81b6b80486..0000000000 --- a/examples/declarative/minehunt/minehunt.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += declarative quick - -HEADERS += minehunt.h -SOURCES += main.cpp minehunt.cpp -RESOURCES = minehunt.qrc diff --git a/examples/declarative/minehunt/minehunt.qml b/examples/declarative/minehunt/minehunt.qml deleted file mode 100644 index 7c4948a3bb..0000000000 --- a/examples/declarative/minehunt/minehunt.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "MinehuntCore" 2.0 - -Item { - id: field - property int clickx: 0 - property int clicky: 0 - - width: 450; height: 450 - - Image { source: "MinehuntCore/pics/background.png"; anchors.fill: parent; fillMode: Image.Tile } - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - columns: 9; spacing: 1 - - Repeater { - id: repeater - model: tiles - delegate: Tile {} - } - } - - Row { - id: gamedata - x: 20; spacing: 20 - anchors.bottom: field.bottom; anchors.bottomMargin: 15 - - Image { - source: "MinehuntCore/pics/quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - y: 10 - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -20 - onClicked: Qt.quit() - } - } - Column { - spacing: 2 - Image { source: "MinehuntCore/pics/bomb-color.png" } - Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numMines } - } - - Column { - spacing: 2 - Image { source: "MinehuntCore/pics/flag-color.png" } - Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numFlags } - } - } - - Image { - anchors.bottom: field.bottom; anchors.bottomMargin: 15 - anchors.right: field.right; anchors.rightMargin: 20 - source: isPlaying ? 'MinehuntCore/pics/face-smile.png' : - hasWon ? 'MinehuntCore/pics/face-smile-big.png': 'MinehuntCore/pics/face-sad.png' - - MouseArea { anchors.fill: parent; onPressed: reset() } - } - Text { - anchors.centerIn: parent; width: parent.width - 20 - horizontalAlignment: Text.AlignHCenter - wrapMode: Text.WordWrap - text: "Minehunt demo has to be compiled to run.\n\nPlease see README." - color: "white"; font.bold: true; font.pixelSize: 14 - visible: tiles == undefined - } - -} diff --git a/examples/declarative/minehunt/minehunt.qmlproject b/examples/declarative/minehunt/minehunt.qmlproject deleted file mode 100644 index 5aeb78f1ea..0000000000 --- a/examples/declarative/minehunt/minehunt.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "minehunt.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/minehunt/minehunt.qrc b/examples/declarative/minehunt/minehunt.qrc deleted file mode 100644 index fa8e27d383..0000000000 --- a/examples/declarative/minehunt/minehunt.qrc +++ /dev/null @@ -1,20 +0,0 @@ - - - minehunt.qml - MinehuntCore/Explosion.qml - MinehuntCore/Tile.qml - MinehuntCore/qmldir - MinehuntCore/pics/background.png - MinehuntCore/pics/back.png - MinehuntCore/pics/bomb-color.png - MinehuntCore/pics/bomb.png - MinehuntCore/pics/face-sad.png - MinehuntCore/pics/face-smile-big.png - MinehuntCore/pics/face-smile.png - MinehuntCore/pics/flag-color.png - MinehuntCore/pics/flag.png - MinehuntCore/pics/front.png - MinehuntCore/pics/quit.png - MinehuntCore/pics/star.png - - diff --git a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro deleted file mode 100644 index eaf2b30c89..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = app -TARGET = abstractitemmodel -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative quick - -HEADERS = model.h -SOURCES = main.cpp \ - model.cpp -RESOURCES += abstractitemmodel.qrc diff --git a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc b/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc deleted file mode 100644 index 4ae861cb3d..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/abstractitemmodel.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - view.qml - - - diff --git a/examples/declarative/modelviews/abstractitemmodel/main.cpp b/examples/declarative/modelviews/abstractitemmodel/main.cpp deleted file mode 100644 index b6ca2df26e..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/main.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "model.h" - -#include -#include -#include -#include -#include -#include - -//![0] -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - - AnimalModel model; - model.addAnimal(Animal("Wolf", "Medium")); - model.addAnimal(Animal("Polar bear", "Large")); - model.addAnimal(Animal("Quoll", "Small")); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/modelviews/abstractitemmodel/model.cpp b/examples/declarative/modelviews/abstractitemmodel/model.cpp deleted file mode 100644 index 8f7649c0d4..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/model.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "model.h" - -Animal::Animal(const QString &type, const QString &size) - : m_type(type), m_size(size) -{ -} - -QString Animal::type() const -{ - return m_type; -} - -QString Animal::size() const -{ - return m_size; -} - -//![0] -AnimalModel::AnimalModel(QObject *parent) - : QAbstractListModel(parent) -{ - QHash roles; - roles[TypeRole] = "type"; - roles[SizeRole] = "size"; - setRoleNames(roles); -} -//![0] - -void AnimalModel::addAnimal(const Animal &animal) -{ - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_animals << animal; - endInsertRows(); -} - -int AnimalModel::rowCount(const QModelIndex & parent) const { - return m_animals.count(); -} - -QVariant AnimalModel::data(const QModelIndex & index, int role) const { - if (index.row() < 0 || index.row() >= m_animals.count()) - return QVariant(); - - const Animal &animal = m_animals[index.row()]; - if (role == TypeRole) - return animal.type(); - else if (role == SizeRole) - return animal.size(); - return QVariant(); -} - diff --git a/examples/declarative/modelviews/abstractitemmodel/model.h b/examples/declarative/modelviews/abstractitemmodel/model.h deleted file mode 100644 index 1378c4487e..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/model.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![0] -class Animal -{ -public: - Animal(const QString &type, const QString &size); -//![0] - - QString type() const; - QString size() const; - -private: - QString m_type; - QString m_size; -//![1] -}; - -class AnimalModel : public QAbstractListModel -{ - Q_OBJECT -public: - enum AnimalRoles { - TypeRole = Qt::UserRole + 1, - SizeRole - }; - - AnimalModel(QObject *parent = 0); -//![1] - - void addAnimal(const Animal &animal); - - int rowCount(const QModelIndex & parent = QModelIndex()) const; - - QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; - -private: - QList m_animals; -//![2] -}; -//![2] - - diff --git a/examples/declarative/modelviews/abstractitemmodel/view.qml b/examples/declarative/modelviews/abstractitemmodel/view.qml deleted file mode 100644 index 64f5871d4b..0000000000 --- a/examples/declarative/modelviews/abstractitemmodel/view.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//![0] -ListView { - width: 200; height: 250 - - model: myModel - delegate: Text { text: "Animal: " + type + ", " + size } -} -//![0] - diff --git a/examples/declarative/modelviews/gridview/gridview-example.qml b/examples/declarative/modelviews/gridview/gridview-example.qml deleted file mode 100644 index ea3bb5cec9..0000000000 --- a/examples/declarative/modelviews/gridview/gridview-example.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 300; height: 400 - color: "white" - - ListModel { - id: appModel - ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } - ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } - ListElement { name: "Camera"; icon: "pics/Camera_48.png" } - ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } - ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } - ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } - ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } - } - - Component { - id: appDelegate - - Item { - width: 100; height: 100 - - Image { - id: myIcon - y: 20; anchors.horizontalCenter: parent.horizontalCenter - source: icon - } - Text { - anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } - text: name - } - MouseArea { - anchors.fill: parent - onClicked: parent.GridView.view.currentIndex = index - } - } - } - - Component { - id: appHighlight - Rectangle { width: 80; height: 80; color: "lightsteelblue" } - } - - GridView { - anchors.fill: parent - cellWidth: 100; cellHeight: 100 - highlight: appHighlight - focus: true - model: appModel - delegate: appDelegate - } -} diff --git a/examples/declarative/modelviews/gridview/pics/AddressBook_48.png b/examples/declarative/modelviews/gridview/pics/AddressBook_48.png deleted file mode 100644 index 1ab7c8eec1..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/AddressBook_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png b/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png deleted file mode 100644 index f4b8689f87..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/AudioPlayer_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/Camera_48.png b/examples/declarative/modelviews/gridview/pics/Camera_48.png deleted file mode 100644 index c76b524945..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/Camera_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/DateBook_48.png b/examples/declarative/modelviews/gridview/pics/DateBook_48.png deleted file mode 100644 index 58f5787fb8..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/DateBook_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/EMail_48.png b/examples/declarative/modelviews/gridview/pics/EMail_48.png deleted file mode 100644 index d6d84a61be..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/EMail_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/TodoList_48.png b/examples/declarative/modelviews/gridview/pics/TodoList_48.png deleted file mode 100644 index 0988448d9b..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/TodoList_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png b/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png deleted file mode 100644 index 52638c50a7..0000000000 Binary files a/examples/declarative/modelviews/gridview/pics/VideoPlayer_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/PetsModel.qml b/examples/declarative/modelviews/listview/content/PetsModel.qml deleted file mode 100644 index 4f2087d95e..0000000000 --- a/examples/declarative/modelviews/listview/content/PetsModel.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -} diff --git a/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml b/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml deleted file mode 100644 index b20d8f64f1..0000000000 --- a/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: container - - property int repeatDelay: 300 - property int repeatDuration: 75 - property bool pressed: false - - signal clicked - - scale: pressed ? 0.9 : 1 - - function release() { - autoRepeatClicks.stop() - container.pressed = false - } - - SequentialAnimation on pressed { - id: autoRepeatClicks - running: false - - PropertyAction { target: container; property: "pressed"; value: true } - ScriptAction { script: container.clicked() } - PauseAnimation { duration: repeatDelay } - - SequentialAnimation { - loops: Animation.Infinite - ScriptAction { script: container.clicked() } - PauseAnimation { duration: repeatDuration } - } - } - - MouseArea { - anchors.fill: parent - - onPressed: autoRepeatClicks.start() - onReleased: container.release() - onCanceled: container.release() - } -} - diff --git a/examples/declarative/modelviews/listview/content/RecipesModel.qml b/examples/declarative/modelviews/listview/content/RecipesModel.qml deleted file mode 100644 index 86210ba436..0000000000 --- a/examples/declarative/modelviews/listview/content/RecipesModel.qml +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - ListElement { - title: "Pancakes" - picture: "content/pics/pancakes.jpg" - ingredients: " -
            -
          • 1 cup (150g) self-raising flour -
          • 1 tbs caster sugar -
          • 3/4 cup (185ml) milk -
          • 1 egg -
          - " - method: " -
            -
          1. Sift flour and sugar together into a bowl. Add a pinch of salt. -
          2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. -
          3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. -
          4. Turn over and cook other side until golden. -
          - " - } - ListElement { - title: "Fruit Salad" - picture: "content/pics/fruit-salad.jpg" - ingredients: "* Seasonal Fruit" - method: "* Chop fruit and place in a bowl." - } - ListElement { - title: "Vegetable Soup" - picture: "content/pics/vegetable-soup.jpg" - ingredients: " -
            -
          • 1 onion -
          • 1 turnip -
          • 1 potato -
          • 1 carrot -
          • 1 head of celery -
          • 1 1/2 litres of water -
          - " - method: " -
            -
          1. Chop vegetables. -
          2. Boil in water until vegetables soften. -
          3. Season with salt and pepper to taste. -
          - " - } - ListElement { - title: "Hamburger" - picture: "content/pics/hamburger.jpg" - ingredients: " -
            -
          • 500g minced beef -
          • Seasoning -
          • lettuce, tomato, onion, cheese -
          • 1 hamburger bun for each burger -
          - " - method: " -
            -
          1. Mix the beef, together with seasoning, in a food processor. -
          2. Shape the beef into burgers. -
          3. Grill the burgers for about 5 mins on each side (until cooked through) -
          4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. -
          - " - } - ListElement { - title: "Lemonade" - picture: "content/pics/lemonade.jpg" - ingredients: " -
            -
          • 1 cup Lemon Juice -
          • 1 cup Sugar -
          • 6 Cups of Water (2 cups warm water, 4 cups cold water) -
          - " - method: " -
            -
          1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. -
          2. Pour in lemon juice, stir again, and add 4 cups of cold water. -
          3. Chill or serve over ice cubes. -
          - " - } -} diff --git a/examples/declarative/modelviews/listview/content/TextButton.qml b/examples/declarative/modelviews/listview/content/TextButton.qml deleted file mode 100644 index 980ee21553..0000000000 --- a/examples/declarative/modelviews/listview/content/TextButton.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property alias text: label.text - - signal clicked - - width: label.width + 20; height: label.height + 6 - smooth: true - radius: 10 - - gradient: Gradient { - GradientStop { id: gradientStop; position: 0.0; color: palette.light } - GradientStop { position: 1.0; color: palette.button } - } - - SystemPalette { id: palette } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { container.clicked() } - } - - Text { - id: label - anchors.centerIn: parent - } - - states: State { - name: "pressed" - when: mouseArea.pressed - PropertyChanges { target: gradientStop; color: palette.dark } - } -} - diff --git a/examples/declarative/modelviews/listview/content/ToggleButton.qml b/examples/declarative/modelviews/listview/content/ToggleButton.qml deleted file mode 100644 index 0754d9849b..0000000000 --- a/examples/declarative/modelviews/listview/content/ToggleButton.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - property alias label: text.text - property bool active: false - signal toggled - width: 149 - height: 30 - radius: 3 - color: active ? "green" : "lightgray" - border.width: 1 - Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 } - MouseArea { - anchors.fill: parent - onClicked: { active = !active; root.toggled() } - } -} diff --git a/examples/declarative/modelviews/listview/content/pics/arrow-down.png b/examples/declarative/modelviews/listview/content/pics/arrow-down.png deleted file mode 100644 index 29d1d4439a..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/arrow-down.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/arrow-up.png b/examples/declarative/modelviews/listview/content/pics/arrow-up.png deleted file mode 100644 index e437312217..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/arrow-up.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg b/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg deleted file mode 100644 index da5a6b10a2..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/fruit-salad.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/hamburger.jpg b/examples/declarative/modelviews/listview/content/pics/hamburger.jpg deleted file mode 100644 index d0a15be1bf..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/hamburger.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/lemonade.jpg b/examples/declarative/modelviews/listview/content/pics/lemonade.jpg deleted file mode 100644 index db445c9ac8..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/lemonade.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/list-delete.png b/examples/declarative/modelviews/listview/content/pics/list-delete.png deleted file mode 100644 index df2a147d24..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/list-delete.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/minus-sign.png b/examples/declarative/modelviews/listview/content/pics/minus-sign.png deleted file mode 100644 index d6f233d739..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/minus-sign.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/moreDown.png b/examples/declarative/modelviews/listview/content/pics/moreDown.png deleted file mode 100644 index 31a35d5c20..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/moreDown.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/moreUp.png b/examples/declarative/modelviews/listview/content/pics/moreUp.png deleted file mode 100644 index fefb9c9098..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/moreUp.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/pancakes.jpg b/examples/declarative/modelviews/listview/content/pics/pancakes.jpg deleted file mode 100644 index 60c439638e..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/pancakes.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/plus-sign.png b/examples/declarative/modelviews/listview/content/pics/plus-sign.png deleted file mode 100644 index 40df1134f8..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/plus-sign.png and /dev/null differ diff --git a/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg deleted file mode 100644 index 9dce332041..0000000000 Binary files a/examples/declarative/modelviews/listview/content/pics/vegetable-soup.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/listview/dynamiclist.qml b/examples/declarative/modelviews/listview/dynamiclist.qml deleted file mode 100644 index ee7c6329bc..0000000000 --- a/examples/declarative/modelviews/listview/dynamiclist.qml +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import "content" - -// This example shows how items can be dynamically added to and removed from -// a ListModel, and how these list modifications can be animated. - -Rectangle { - id: container - width: 500; height: 400 - color: "#343434" - - // The model: - ListModel { - id: fruitModel - - ListElement { - name: "Apple"; cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Banana"; cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } - ListElement { - name: "Cumquat"; cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Durian"; cost: 9.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Smelly" } - ] - } - } - - // The delegate for each fruit in the model: - Component { - id: listDelegate - - Item { - id: delegateItem - width: listView.width; height: 55 - clip: true - - Row { - anchors.verticalCenter: parent.verticalCenter - spacing: 10 - - Column { - Image { - source: "content/pics/arrow-up.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) } - } - Image { source: "content/pics/arrow-down.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) } - } - } - - Column { - anchors.verticalCenter: parent.verticalCenter - - Text { - text: name - font.pixelSize: 15 - color: "white" - } - Row { - spacing: 5 - Repeater { - model: attributes - Text { text: description; color: "White" } - } - } - } - } - - Row { - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - spacing: 10 - - PressAndHoldButton { - anchors.verticalCenter: parent.verticalCenter - source: "content/pics/plus-sign.png" - onClicked: fruitModel.setProperty(index, "cost", cost + 0.25) - } - - Text { - id: costText - anchors.verticalCenter: parent.verticalCenter - text: '$' + Number(cost).toFixed(2) - font.pixelSize: 15 - color: "white" - font.bold: true - } - - PressAndHoldButton { - anchors.verticalCenter: parent.verticalCenter - source: "content/pics/minus-sign.png" - onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) - } - - Image { - source: "content/pics/list-delete.png" - MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } - } - } - - // Animate adding and removing of items: - - ListView.onAdd: SequentialAnimation { - PropertyAction { target: delegateItem; property: "height"; value: 0 } - NumberAnimation { target: delegateItem; property: "height"; to: 55; duration: 250; easing.type: Easing.InOutQuad } - } - - ListView.onRemove: SequentialAnimation { - PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true } - NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad } - - // Make sure delayRemove is set back to false so that the item can be destroyed - PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false } - } - } - } - - // The view: - ListView { - id: listView - anchors.fill: parent; anchors.margins: 20 - model: fruitModel - delegate: listDelegate - } - - Row { - anchors { left: parent.left; bottom: parent.bottom; margins: 20 } - spacing: 10 - - TextButton { - text: "Add an item" - onClicked: { - fruitModel.append({ - "name": "Pizza Margarita", - "cost": 5.95, - "attributes": [{"description": "Cheese"}, {"description": "Tomato"}] - }) - } - } - - TextButton { - text: "Remove all items" - onClicked: fruitModel.clear() - } - } -} - diff --git a/examples/declarative/modelviews/listview/expandingdelegates.qml b/examples/declarative/modelviews/listview/expandingdelegates.qml deleted file mode 100644 index 43a9662422..0000000000 --- a/examples/declarative/modelviews/listview/expandingdelegates.qml +++ /dev/null @@ -1,202 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -// This example illustrates expanding a list item to show a more detailed view. - -Rectangle { - id: page - width: 400; height: 240 - color: "black" - - // Delegate for the recipes. This delegate has two modes: - // 1. List mode (default), which just shows the picture and title of the recipe. - // 2. Details mode, which also shows the ingredients and method. - Component { - id: recipeDelegate - - Item { - id: recipe - - // Create a property to contain the visibility of the details. - // We can bind multiple element's opacity to this one property, - // rather than having a "PropertyChanges" line for each element we - // want to fade. - property real detailsOpacity : 0 - - width: listView.width - height: 70 - - // A simple rounded rectangle for the background - Rectangle { - id: background - x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 - color: "ivory" - border.color: "orange" - radius: 5 - } - - // This mouse region covers the entire delegate. - // When clicked it changes mode to 'Details'. If we are already - // in Details mode, then no change will happen. - MouseArea { - anchors.fill: parent - onClicked: recipe.state = 'Details'; - } - - // Lay out the page: picture, title and ingredients at the top, and method at the - // bottom. Note that elements that should not be visible in the list - // mode have their opacity set to recipe.detailsOpacity. - Row { - id: topLayout - x: 10; y: 10; height: recipeImage.height; width: parent.width - spacing: 10 - - Image { - id: recipeImage - width: 50; height: 50 - source: picture - } - - Column { - width: background.width - recipeImage.width - 20; height: recipeImage.height - spacing: 5 - - Text { - text: title - font.bold: true; font.pointSize: 16 - } - - Text { - text: "Ingredients" - font.pointSize: 12; font.bold: true - opacity: recipe.detailsOpacity - } - - Text { - text: ingredients - wrapMode: Text.WordWrap - width: parent.width - opacity: recipe.detailsOpacity - } - } - } - - Item { - id: details - x: 10; width: parent.width - 20 - anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } - opacity: recipe.detailsOpacity - - Text { - id: methodTitle - anchors.top: parent.top - text: "Method" - font.pointSize: 12; font.bold: true - } - - Flickable { - id: flick - width: parent.width - anchors { top: methodTitle.bottom; bottom: parent.bottom } - contentHeight: methodText.height - clip: true - - Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } - } - - Image { - anchors { right: flick.right; top: flick.top } - source: "content/pics/moreUp.png" - opacity: flick.atYBeginning ? 0 : 1 - } - - Image { - anchors { right: flick.right; bottom: flick.bottom } - source: "content/pics/moreDown.png" - opacity: flick.atYEnd ? 0 : 1 - } - } - - // A button to close the detailed view, i.e. set the state back to default (''). - TextButton { - y: 10 - anchors { right: background.right; rightMargin: 10 } - opacity: recipe.detailsOpacity - text: "Close" - - onClicked: recipe.state = ''; - } - - states: State { - name: "Details" - - PropertyChanges { target: background; color: "white" } - PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger - PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible - PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view - - // Move the list so that this item is at the top. - PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } - - // Disallow flicking while we're in detailed view - PropertyChanges { target: recipe.ListView.view; interactive: false } - } - - transitions: Transition { - // Make the state changes smooth - ParallelAnimation { - ColorAnimation { property: "color"; duration: 500 } - NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" } - } - } - } - } - - // The actual list - ListView { - id: listView - anchors.fill: parent - model: RecipesModel {} - delegate: recipeDelegate - } -} diff --git a/examples/declarative/modelviews/listview/highlight.qml b/examples/declarative/modelviews/listview/highlight.qml deleted file mode 100644 index d8f76080e6..0000000000 --- a/examples/declarative/modelviews/listview/highlight.qml +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example shows how to create your own highlight delegate for a ListView -// that uses a SpringAnimation to provide custom movement when the -// highlight bar is moved between items. - -import QtQuick 2.0 -import "content" - -Rectangle { - width: 200; height: 300 - - // Define a delegate component. A component will be - // instantiated for each visible item in the list. - Component { - id: petDelegate - Item { - id: wrapper - width: 200; height: 55 - Column { - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } - // indent the item if it is the current item - states: State { - name: "Current" - when: wrapper.ListView.isCurrentItem - PropertyChanges { target: wrapper; x: 20 } - } - transitions: Transition { - NumberAnimation { properties: "x"; duration: 200 } - } - } - } - - // Define a highlight with customised movement between items. - Component { - id: highlightBar - Rectangle { - width: 200; height: 50 - color: "#FFFF88" - y: listView.currentItem.y; - Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } } - } - } - - ListView { - id: listView - width: 200; height: parent.height - - model: PetsModel {} - delegate: petDelegate - focus: true - - // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem - // to false so the highlight delegate can control how the highlight is moved. - highlight: highlightBar - highlightFollowsCurrentItem: false - } -} diff --git a/examples/declarative/modelviews/listview/highlightranges.qml b/examples/declarative/modelviews/listview/highlightranges.qml deleted file mode 100644 index a536ddcbb2..0000000000 --- a/examples/declarative/modelviews/listview/highlightranges.qml +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: root - property int current: 0 - width: 600; height: 300 - - // This example shows the same model in three different ListView items, - // with different highlight ranges. The highlight ranges are set by the - // preferredHighlightBegin and preferredHighlightEnd properties in ListView. - // - // The first ListView does not set a highlight range, so its currentItem - // can move freely within the visible area. If it moves outside the - // visible area, the view is automatically scrolled to keep the current - // item visible. - // - // The second ListView sets a highlight range which attempts to keep the - // current item within the the bounds of the range. However, - // items will not scroll beyond the beginning or end of the view, - // forcing the highlight to move outside the range at the ends. - // - // The third ListView sets the highlightRangeMode to StrictlyEnforceRange - // and sets a range smaller than the height of an item. This - // forces the current item to change when the view is flicked, - // since the highlight is unable to move. - // - // All ListViews bind their currentIndex to the root.current property. - // The first ListView sets root.current whenever its currentIndex changes - // due to keyboard interaction. - // Flicking the third ListView with the mouse also changes root.current. - - ListView { - id: list1 - width: 200; height: parent.height - model: PetsModel {} - delegate: petDelegate - - highlight: Rectangle { color: "lightsteelblue" } - currentIndex: root.current - onCurrentIndexChanged: root.current = currentIndex - focus: true - } - - ListView { - id: list2 - x: list1.width - width: 200; height: parent.height - model: PetsModel {} - delegate: petDelegate - - highlight: Rectangle { color: "yellow" } - currentIndex: root.current - preferredHighlightBegin: 80; preferredHighlightEnd: 220 - highlightRangeMode: ListView.ApplyRange - } - - ListView { - id: list3 - x: list1.width + list2.width - width: 200; height: parent.height - model: PetsModel {} - delegate: petDelegate - - highlight: Rectangle { color: "yellow" } - currentIndex: root.current - onCurrentIndexChanged: root.current = currentIndex - preferredHighlightBegin: 125; preferredHighlightEnd: 125 - highlightRangeMode: ListView.StrictlyEnforceRange - } - - // The delegate for each list - Component { - id: petDelegate - Column { - width: 200 - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } - } -} diff --git a/examples/declarative/modelviews/listview/sections.qml b/examples/declarative/modelviews/listview/sections.qml deleted file mode 100644 index 2e63a86bb6..0000000000 --- a/examples/declarative/modelviews/listview/sections.qml +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example shows how a ListView can be separated into sections using -// the ListView.section attached property. - -import QtQuick 2.0 -import "content" - -Rectangle { - id: container - width: 300 - height: 360 - - ListModel { - id: animalsModel - ListElement { name: "Ant"; size: "Tiny" } - ListElement { name: "Flea"; size: "Tiny" } - ListElement { name: "Parrot"; size: "Small" } - ListElement { name: "Guinea pig"; size: "Small" } - ListElement { name: "Rat"; size: "Small" } - ListElement { name: "Butterfly"; size: "Small" } - ListElement { name: "Dog"; size: "Medium" } - ListElement { name: "Cat"; size: "Medium" } - ListElement { name: "Pony"; size: "Medium" } - ListElement { name: "Koala"; size: "Medium" } - ListElement { name: "Horse"; size: "Large" } - ListElement { name: "Tiger"; size: "Large" } - ListElement { name: "Giraffe"; size: "Large" } - ListElement { name: "Elephant"; size: "Huge" } - ListElement { name: "Whale"; size: "Huge" } - } - -//! [0] - // The delegate for each section header - Component { - id: sectionHeading - Rectangle { - width: container.width - height: childrenRect.height - color: "lightsteelblue" - - Text { - text: section - font.bold: true - font.pixelSize: 20 - } - } - } - - ListView { - id: view - anchors.top: parent.top - anchors.bottom: buttonBar.top - width: parent.width - model: animalsModel - delegate: Text { text: name; font.pixelSize: 18 } - - section.property: "size" - section.criteria: ViewSection.FullString - section.delegate: sectionHeading - } -//! [0] - - Row { - id: buttonBar - anchors.bottom: parent.bottom - anchors.bottomMargin: 1 - spacing: 1 - ToggleButton { - label: "CurrentLabelAtStart" - onToggled: { - if (active) - view.section.labelPositioning |= ViewSection.CurrentLabelAtStart - else - view.section.labelPositioning &= ~ViewSection.CurrentLabelAtStart - } - } - ToggleButton { - label: "NextLabelAtEnd" - onToggled: { - if (active) - view.section.labelPositioning |= ViewSection.NextLabelAtEnd - else - view.section.labelPositioning &= ~ViewSection.NextLabelAtEnd - } - } - } -} - diff --git a/examples/declarative/modelviews/modelviews.pro b/examples/declarative/modelviews/modelviews.pro deleted file mode 100644 index 7748da0471..0000000000 --- a/examples/declarative/modelviews/modelviews.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - abstractitemmodel \ - objectlistmodel \ - stringlistmodel - - diff --git a/examples/declarative/modelviews/modelviews.qml b/examples/declarative/modelviews/modelviews.qml deleted file mode 100644 index 86b10ca4ba..0000000000 --- a/examples/declarative/modelviews/modelviews.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../shared" - -Item { - height: 480 - width: 480 - LauncherList { - id: ll - anchors.fill: parent - Component.onCompleted: { - addExample("Dynamic List", "A ListView harboring dynamic data", Qt.resolvedUrl("listview/dynamiclist.qml")); - addExample("Expanding Delegates", "Delegates that expand to fill the list when clicked", Qt.resolvedUrl("listview/expandingdelegates.qml")); - addExample("Highlight", "Adding a highlight to the current item", Qt.resolvedUrl("listview/highlight.qml")); - addExample("Sections", "A ListView with section headers", Qt.resolvedUrl("listview/sections.qml")); - addExample("GridView", "A view laid out in a grid", Qt.resolvedUrl("gridview/gridview-example.qml")); - addExample("PathView", "A view laid out along a path", Qt.resolvedUrl("pathview/pathview-example.qml")); - addExample("Package", "Using a package to transition items between views", Qt.resolvedUrl("package/view.qml")); - addExample("Parallax", "Adds a background and a parallax effect to a ListView", Qt.resolvedUrl("parallax/parallax.qml")); - addExample("Slideshow", "A model demonstrating delayed image loading", Qt.resolvedUrl("visualdatamodel/slideshow.qml")); - addExample("Sorted Model", "Two views on a model, one of which is sorted", Qt.resolvedUrl("visualdatamodel/sortedmodel.qml")); - addExample("VisualItemModel", "A model that consists of the actual Items", Qt.resolvedUrl("visualitemmodel/visualitemmodel.qml")); - } - } -} diff --git a/examples/declarative/modelviews/modelviews.qmlproject b/examples/declarative/modelviews/modelviews.qmlproject deleted file mode 100644 index 40f9e568fd..0000000000 --- a/examples/declarative/modelviews/modelviews.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "modelviews.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/modelviews/objectlistmodel/dataobject.cpp b/examples/declarative/modelviews/objectlistmodel/dataobject.cpp deleted file mode 100644 index 7216283616..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/dataobject.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "dataobject.h" - -DataObject::DataObject(QObject *parent) - : QObject(parent) -{ -} - -DataObject::DataObject(const QString &name, const QString &color, QObject *parent) - : QObject(parent), m_name(name), m_color(color) -{ -} - -QString DataObject::name() const -{ - return m_name; -} - -void DataObject::setName(const QString &name) -{ - if (name != m_name) { - m_name = name; - emit nameChanged(); - } -} - -QString DataObject::color() const -{ - return m_color; -} - -void DataObject::setColor(const QString &color) -{ - if (color != m_color) { - m_color = color; - emit colorChanged(); - } -} diff --git a/examples/declarative/modelviews/objectlistmodel/dataobject.h b/examples/declarative/modelviews/objectlistmodel/dataobject.h deleted file mode 100644 index bea92a273c..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/dataobject.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DATAOBJECT_H -#define DATAOBJECT_H - -#include - -//![0] -class DataObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) -//![0] - -public: - DataObject(QObject *parent=0); - DataObject(const QString &name, const QString &color, QObject *parent=0); - - QString name() const; - void setName(const QString &name); - - QString color() const; - void setColor(const QString &color); - -signals: - void nameChanged(); - void colorChanged(); - -private: - QString m_name; - QString m_color; -//![1] -}; -//![1] - -#endif // DATAOBJECT_H diff --git a/examples/declarative/modelviews/objectlistmodel/main.cpp b/examples/declarative/modelviews/objectlistmodel/main.cpp deleted file mode 100644 index c8542976c3..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/main.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include -#include -#include -#include - -#include "dataobject.h" - -/* - This example illustrates exposing a QList as a - model in QML -*/ - -//![0] -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - - QList dataList; - dataList.append(new DataObject("Item 1", "red")); - dataList.append(new DataObject("Item 2", "green")); - dataList.append(new DataObject("Item 3", "blue")); - dataList.append(new DataObject("Item 4", "yellow")); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro deleted file mode 100644 index 74dc5b1016..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.pro +++ /dev/null @@ -1,6 +0,0 @@ -QT += declarative quick - -SOURCES += main.cpp \ - dataobject.cpp -HEADERS += dataobject.h -RESOURCES += objectlistmodel.qrc diff --git a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc deleted file mode 100644 index 17e9301471..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/objectlistmodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/modelviews/objectlistmodel/view.qml b/examples/declarative/modelviews/objectlistmodel/view.qml deleted file mode 100644 index 3954e79829..0000000000 --- a/examples/declarative/modelviews/objectlistmodel/view.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -ListView { - width: 100; height: 100 - - model: myModel - delegate: Rectangle { - height: 25 - width: 100 - color: model.modelData.color - Text { text: name } - } -} -//![0] diff --git a/examples/declarative/modelviews/package/Delegate.qml b/examples/declarative/modelviews/package/Delegate.qml deleted file mode 100644 index 97c7840cb4..0000000000 --- a/examples/declarative/modelviews/package/Delegate.qml +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -Package { - Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } - Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } - - Rectangle { - id: wrapper - width: 200; height: 25 - color: 'lightsteelblue' - - Text { text: display; anchors.centerIn: parent } - MouseArea { - anchors.fill: parent - onClicked: { - if (wrapper.state == 'inList') - wrapper.state = 'inGrid'; - else - wrapper.state = 'inList'; - } - } - - state: 'inList' - states: [ - State { - name: 'inList' - ParentChange { target: wrapper; parent: listDelegate } - }, - State { - name: 'inGrid' - ParentChange { - target: wrapper; parent: gridDelegate - x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height - } - } - ] - - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } -} -//![0] diff --git a/examples/declarative/modelviews/package/view.qml b/examples/declarative/modelviews/package/view.qml deleted file mode 100644 index 5b2fd9481c..0000000000 --- a/examples/declarative/modelviews/package/view.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - color: "white" - width: 400 - height: 200 - - ListModel { - id: myModel - ListElement { display: "One" } - ListElement { display: "Two" } - ListElement { display: "Three" } - ListElement { display: "Four" } - ListElement { display: "Five" } - ListElement { display: "Six" } - ListElement { display: "Seven" } - ListElement { display: "Eight" } - } - //![0] - VisualDataModel { - id: visualModel - delegate: Delegate {} - model: myModel - } - - ListView { - width: 200; height:200 - model: visualModel.parts.list - } - GridView { - x: 200; width: 200; height:200 - cellHeight: 50 - model: visualModel.parts.grid - } - //![0] -} diff --git a/examples/declarative/modelviews/parallax/content/ParallaxView.qml b/examples/declarative/modelviews/parallax/content/ParallaxView.qml deleted file mode 100644 index 2acf50dcef..0000000000 --- a/examples/declarative/modelviews/parallax/content/ParallaxView.qml +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - - property alias background: background.source - property int currentIndex: 0 - default property alias content: visualModel.children - - Image { - id: background - fillMode: Image.TileHorizontally - x: -list.contentX / 2 - width: Math.max(list.contentWidth, parent.width) - } - - ListView { - id: list - anchors.fill: parent - - currentIndex: root.currentIndex - onCurrentIndexChanged: root.currentIndex = currentIndex - - orientation: Qt.Horizontal - boundsBehavior: Flickable.DragOverBounds - model: VisualItemModel { id: visualModel } - - highlightRangeMode: ListView.StrictlyEnforceRange - snapMode: ListView.SnapOneItem - } - - ListView { - id: selector - - height: 50 - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - width: Math.min(count * 50, parent.width - 20) - interactive: width == parent.width - 20 - orientation: Qt.Horizontal - - currentIndex: root.currentIndex - onCurrentIndexChanged: root.currentIndex = currentIndex - - model: visualModel.children - delegate: Item { - width: 50; height: 50 - id: delegateRoot - - Image { - id: image - source: modelData.icon - smooth: true - scale: 0.8 - } - - MouseArea { - anchors.fill: parent - onClicked: { root.currentIndex = index } - } - - states: State { - name: "Selected" - when: delegateRoot.ListView.isCurrentItem == true - PropertyChanges { - target: image - scale: 1 - y: -5 - } - } - transitions: Transition { - NumberAnimation { properties: "scale,y" } - } - } - - Rectangle { - color: "#60FFFFFF" - x: -10; y: -10; z: -1 - width: parent.width + 20; height: parent.height + 20 - radius: 10 - } - } -} diff --git a/examples/declarative/modelviews/parallax/content/Smiley.qml b/examples/declarative/modelviews/parallax/content/Smiley.qml deleted file mode 100644 index 982b6c5d2b..0000000000 --- a/examples/declarative/modelviews/parallax/content/Smiley.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -// This is taken from the declarative animation/basics/property-animation.qml -// example - -Item { - id: window - width: 320; height: 480 - - Image { - anchors.horizontalCenter: parent.horizontalCenter - y: smiley.minHeight + 58 - source: "pics/shadow.png" - - scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) - } - - Image { - id: smiley - property int maxHeight: window.height / 3 - property int minHeight: 2 * window.height / 3 - - anchors.horizontalCenter: parent.horizontalCenter - y: minHeight - source: "pics/face-smile.png" - - SequentialAnimation on y { - loops: Animation.Infinite - - NumberAnimation { - from: smiley.minHeight; to: smiley.maxHeight - easing.type: Easing.OutExpo; duration: 300 - } - - NumberAnimation { - from: smiley.maxHeight; to: smiley.minHeight - easing.type: Easing.OutBounce; duration: 1000 - } - - PauseAnimation { duration: 500 } - } - } -} - diff --git a/examples/declarative/modelviews/parallax/content/pics/background.jpg b/examples/declarative/modelviews/parallax/content/pics/background.jpg deleted file mode 100644 index 61cca2f138..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/background.jpg and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/content/pics/face-smile.png b/examples/declarative/modelviews/parallax/content/pics/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/face-smile.png and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/content/pics/home-page.png b/examples/declarative/modelviews/parallax/content/pics/home-page.png deleted file mode 100644 index bd090c3708..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/home-page.png and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/content/pics/home-page.svg b/examples/declarative/modelviews/parallax/content/pics/home-page.svg deleted file mode 100644 index 4f16958844..0000000000 --- a/examples/declarative/modelviews/parallax/content/pics/home-page.svg +++ /dev/null @@ -1,445 +0,0 @@ - -image/svg+xmlGo HomeJakub Steinerhttp://jimmac.musichall.czhomereturngodefaultuserdirectoryTuomas Kuosmanen - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/modelviews/parallax/content/pics/shadow.png b/examples/declarative/modelviews/parallax/content/pics/shadow.png deleted file mode 100644 index 8270565e87..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/shadow.png and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/content/pics/yast-joystick.png b/examples/declarative/modelviews/parallax/content/pics/yast-joystick.png deleted file mode 100644 index 858cea0301..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/yast-joystick.png and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/content/pics/yast-wol.png b/examples/declarative/modelviews/parallax/content/pics/yast-wol.png deleted file mode 100644 index 7712180a3b..0000000000 Binary files a/examples/declarative/modelviews/parallax/content/pics/yast-wol.png and /dev/null differ diff --git a/examples/declarative/modelviews/parallax/parallax.qml b/examples/declarative/modelviews/parallax/parallax.qml deleted file mode 100644 index 6981095a80..0000000000 --- a/examples/declarative/modelviews/parallax/parallax.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../../toys/clocks/content" // for loading the Clock element -import "content" - -Rectangle { - width: 320; height: 480 - - ParallaxView { - id: parallax - anchors.fill: parent - background: "content/pics/background.jpg" - - Item { - property url icon: "content/pics/yast-wol.png" - width: 320; height: 480 - Clock { anchors.centerIn: parent } - } - - Item { - property url icon: "content/pics/home-page.png" - width: 320; height: 480 - Smiley { } - } - - Item { - property url icon: "content/pics/yast-joystick.png" - width: 320; height: 480 - - Loader { - anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter } - width: 300; height: 400 - clip: true; - source: "../../samegame/samegame.qml" - } - } - } -} diff --git a/examples/declarative/modelviews/pathview/pathview-example.qml b/examples/declarative/modelviews/pathview/pathview-example.qml deleted file mode 100644 index 6161343830..0000000000 --- a/examples/declarative/modelviews/pathview/pathview-example.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 400; height: 240 - color: "white" - - ListModel { - id: appModel - ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } - ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } - ListElement { name: "Camera"; icon: "pics/Camera_48.png" } - ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } - ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } - ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } - ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } - } - - Component { - id: appDelegate - Item { - width: 100; height: 100 - scale: PathView.iconScale - - Image { - id: myIcon - y: 20; anchors.horizontalCenter: parent.horizontalCenter - source: icon - smooth: true - } - Text { - anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } - text: name - smooth: true - } - - MouseArea { - anchors.fill: parent - onClicked: view.currentIndex = index - } - } - } - - Component { - id: appHighlight - Rectangle { width: 80; height: 80; color: "lightsteelblue" } - } - - PathView { - id: view - anchors.fill: parent - highlight: appHighlight - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - focus: true - model: appModel - delegate: appDelegate - path: Path { - startX: 10 - startY: 50 - PathAttribute { name: "iconScale"; value: 0.5 } - PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } - PathAttribute { name: "iconScale"; value: 1.0 } - PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } - PathAttribute { name: "iconScale"; value: 0.5 } - } - } -} diff --git a/examples/declarative/modelviews/pathview/pics/AddressBook_48.png b/examples/declarative/modelviews/pathview/pics/AddressBook_48.png deleted file mode 100644 index 1ab7c8eec1..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/AddressBook_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png b/examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png deleted file mode 100644 index f4b8689f87..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/AudioPlayer_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/Camera_48.png b/examples/declarative/modelviews/pathview/pics/Camera_48.png deleted file mode 100644 index c76b524945..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/Camera_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/DateBook_48.png b/examples/declarative/modelviews/pathview/pics/DateBook_48.png deleted file mode 100644 index 58f5787fb8..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/DateBook_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/EMail_48.png b/examples/declarative/modelviews/pathview/pics/EMail_48.png deleted file mode 100644 index d6d84a61be..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/EMail_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/TodoList_48.png b/examples/declarative/modelviews/pathview/pics/TodoList_48.png deleted file mode 100644 index 0988448d9b..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/TodoList_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png b/examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png deleted file mode 100644 index 52638c50a7..0000000000 Binary files a/examples/declarative/modelviews/pathview/pics/VideoPlayer_48.png and /dev/null differ diff --git a/examples/declarative/modelviews/stringlistmodel/main.cpp b/examples/declarative/modelviews/stringlistmodel/main.cpp deleted file mode 100644 index 47d7fdaa8c..0000000000 --- a/examples/declarative/modelviews/stringlistmodel/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include -#include -#include -#include -#include - - -/* - This example illustrates exposing a QStringList as a - model in QML -*/ - -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - -//![0] - QStringList dataList; - dataList.append("Item 1"); - dataList.append("Item 2"); - dataList.append("Item 3"); - dataList.append("Item 4"); - - QQuickView view; - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro deleted file mode 100644 index 540d8c71f0..0000000000 --- a/examples/declarative/modelviews/stringlistmodel/stringlistmodel.pro +++ /dev/null @@ -1,4 +0,0 @@ -QT += declarative quick - -SOURCES += main.cpp -RESOURCES += stringlistmodel.qrc diff --git a/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc deleted file mode 100644 index 17e9301471..0000000000 --- a/examples/declarative/modelviews/stringlistmodel/stringlistmodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/modelviews/stringlistmodel/view.qml b/examples/declarative/modelviews/stringlistmodel/view.qml deleted file mode 100644 index 945763c295..0000000000 --- a/examples/declarative/modelviews/stringlistmodel/view.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -//![0] - -ListView { - width: 100; height: 100 - - model: myModel - delegate: Rectangle { - height: 25 - width: 100 - Text { text: modelData } - } -} -//![0] diff --git a/examples/declarative/modelviews/visualdatamodel/dragselection.qml b/examples/declarative/modelviews/visualdatamodel/dragselection.qml deleted file mode 100644 index c3186a5ad8..0000000000 --- a/examples/declarative/modelviews/visualdatamodel/dragselection.qml +++ /dev/null @@ -1,200 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - - width: 320 - height: 480 - - property bool dragging: false - - Component { - id: packageDelegate - Package { - id: packageRoot - - MouseArea { - id: visibleContainer - Package.name: "visible" - - width: 64 - height: 64 - enabled: packageRoot.VisualDataModel.inSelected - - drag.target: draggable - - Item { - id: draggable - - width: 64 - height: 64 - - Drag.active: visibleContainer.drag.active - - anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } - - states: State { - when: visibleContainer.drag.active - AnchorChanges { target: draggable; anchors { horizontalCenter: undefined; verticalCenter: undefined} } - ParentChange { target: selectionView; parent: draggable; x: 0; y: 0 } - PropertyChanges { target: root; dragging: true } - ParentChange { target: draggable; parent: root } - } - } - DropArea { - anchors.fill: parent - onEntered: selectedItems.move(0, visualModel.items.get(packageRoot.VisualDataModel.itemsIndex), selectedItems.count) - } - } - Item { - id: selectionContainer - Package.name: "selection" - - width: 64 - height: 64 - - visible: PathView.onPath - } - Rectangle { - id: content - parent: visibleContainer - - width: 58 - height: 58 - - radius: 8 - - gradient: Gradient { - GradientStop { id: gradientStart; position: 0.0; color: "#8AC953" } - GradientStop { id: gradientEnd; position: 1.0; color: "#8BC953" } - } - - border.width: 2 - border.color: "#007423" - - state: root.dragging && packageRoot.VisualDataModel.inSelected ? "selected" : "visible" - - Text { - anchors.fill: parent - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: "white" - text: modelData - font.pixelSize: 18 - } - - Rectangle { - anchors { right: parent.right; top: parent.top; margins: 3 } - width: 12; height: 12 - color: packageRoot.VisualDataModel.inSelected ? "black" : "white" - radius: 6 - - border.color: "white" - border.width: 2 - - MouseArea { - anchors.fill: parent - onClicked: packageRoot.VisualDataModel.inSelected = !packageRoot.VisualDataModel.inSelected - } - } - - states: [ - State { - name: "selected" - ParentChange { target: content; parent: selectionContainer; x: 3; y: 3 } - PropertyChanges { target: packageRoot; VisualDataModel.inItems: visibleContainer.drag.active } - PropertyChanges { target: gradientStart; color: "#017423" } - PropertyChanges { target: gradientStart; color: "#007423" } - }, State { - name: "visible" - PropertyChanges { target: packageRoot; VisualDataModel.inItems: true } - ParentChange { target: content; parent: visibleContainer; x: 3; y: 3 } - PropertyChanges { target: gradientStart; color: "#8AC953" } - PropertyChanges { target: gradientStart; color: "#8BC953" } - } - ] - transitions: Transition { - PropertyAction { target: packageRoot; properties: "VisualDataModel.inItems" } - ParentAnimation { - target: content - NumberAnimation { target: content; properties: "x,y"; duration: 500 } - } - ColorAnimation { targets: [gradientStart, gradientEnd]; duration: 500 } - } - } - } - } - - VisualDataModel { - id: visualModel - model: 35 - delegate: packageDelegate - - groups: VisualDataGroup { id: selectedItems; name: "selected" } - - Component.onCompleted: parts.selection.filterOnGroup = "selected" - } - - PathView { - id: selectionView - - height: 64 - width: 64 - - model: visualModel.parts.selection - - path: Path { - startX: 0 - startY: 0 - PathLine { x: 64; y: 64 } - } - } - - GridView { - id: itemsView - anchors { fill: parent } - cellWidth: 64 - cellHeight: 64 - model: visualModel.parts.visible - } -} diff --git a/examples/declarative/modelviews/visualdatamodel/slideshow.qml b/examples/declarative/modelviews/visualdatamodel/slideshow.qml deleted file mode 100644 index 040c6be307..0000000000 --- a/examples/declarative/modelviews/visualdatamodel/slideshow.qml +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -Rectangle { - id: root - - property Item displayItem: null - - width: 300; height: 400 - - color: "black" - - VisualDataModel { - id: visualModel - - model: XmlListModel { - source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2" - query: "/rss/channel/item" - namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - - XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } - XmlRole { name: "url"; query: "media:content/@url/string()" } - } - - delegate: Item { - id: delegateItem - - width: 76; height: 76 - - Rectangle { - id: image - x: 0; y: 0; width: 76; height: 76 - border.width: 1 - border.color: "white" - color: "black" - - Image { - anchors.fill: parent - anchors.leftMargin: 1 - anchors.topMargin: 1 - - source: imagePath - fillMode: Image.PreserveAspectFit - - } - - MouseArea { - id: clickArea - anchors.fill: parent - - onClicked: root.displayItem = root.displayItem !== delegateItem ? delegateItem : null - } - - states: [ - State { - when: root.displayItem === delegateItem - name: "inDisplay"; - ParentChange { target: image; parent: imageContainer; x: 75; y: 75; width: 150; height: 150 } - PropertyChanges { target: image; z: 2 } - PropertyChanges { target: delegateItem; VisualDataModel.inItems: false } - }, - State { - when: root.displayItem !== delegateItem - name: "inList"; - ParentChange { target: image; parent: delegateItem; x: 2; y: 2; width: 75; height: 75 } - PropertyChanges { target: image; z: 1 } - PropertyChanges { target: delegateItem; VisualDataModel.inItems: true } - } - ] - - transitions: [ - Transition { - from: "inList" - SequentialAnimation { - PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: true } - ParentAnimation { - target: image; - via: root - NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } - } - } - }, Transition { - from: "inDisplay" - SequentialAnimation { - ParentAnimation { - target: image - NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } - } - PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: false } - } - } - ] - } - } - } - - - PathView { - id: imagePath - - anchors { left: parent.left; top: imageContainer.bottom; right: parent.right; bottom: parent.bottom } - model: visualModel - - pathItemCount: 7 - path: Path { - startX: -50; startY: 0 - PathQuad { x: 150; y: 50; controlX: 0; controlY: 50 } - PathQuad { x: 350; y: 0; controlX: 300; controlY: 50 } - } - } - - Item { - id: imageContainer - anchors { fill: parent; bottomMargin: 100 } - } -} diff --git a/examples/declarative/modelviews/visualdatamodel/sortedmodel.qml b/examples/declarative/modelviews/visualdatamodel/sortedmodel.qml deleted file mode 100644 index 8d3b0a58e5..0000000000 --- a/examples/declarative/modelviews/visualdatamodel/sortedmodel.qml +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 480; height: 640 - - Component { - id: numberDelegate - - Text { - id: numberText - anchors { left: parent.left; right: parent.right } - text: number - - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 18 - - Text { - anchors { left: parent.left; baseline: parent.baseline } - text: index - - horizontalAlignment: Text.AlignLeft - font.pixelSize: 12 - } - Text { - anchors { right: parent.right; baseline: parent.baseline } - text: numberText.VisualDataModel.itemsIndex - - horizontalAlignment: Text.AlignRight - font.pixelSize: 12 - } - } - } - - ListView { - anchors { - left: parent.left; top: parent.top; - right: parent.horizontalCenter; bottom: button.top - leftMargin: 2; topMargin: 2; rightMargin: 1; bottomMargin: 2 - } - - model: ListModel { - id: unsortedModel - } - delegate: numberDelegate - } - ListView { - anchors { - left: parent.horizontalCenter; top: parent.top; - right: parent.right; bottom: button.top - leftMargin: 1; topMargin: 2; rightMargin: 2; bottomMargin: 2 - } - model: VisualDataModel { - model: unsortedModel - delegate: numberDelegate - - items.onChanged: { - for (var i = 0; i < inserted.length; ++i) { - for (var j = inserted[i].index; j < inserted[i].index + inserted[i].count; ++j) { - var number = items.get(j).model.number - for (var l = 0, k = 0; l < unsortedModel.count; ++l) { - if (l == inserted[k].index) { - l += inserted[k].count - 1 - ++k - } else if (number < items.get(l).model.number) { - items.move(j, l, 1) - break - } - } - inserted[i].index += 1; - inserted[i].count -= 1; - } - } - } - } - } - - Rectangle { - id: button - - anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 } - height: moreText.implicitHeight + 4 - - color: "black" - - Text { - id: moreText - - anchors.fill: parent - text: "More" - color: "white" - font.pixelSize: 18 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - MouseArea { - anchors.fill: parent - - onClicked: unsortedModel.append({ "number": Math.floor(Math.random() * 100) }) - } - } -} diff --git a/examples/declarative/modelviews/visualdatamodel/visualdatamodel.qmlproject b/examples/declarative/modelviews/visualdatamodel/visualdatamodel.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/modelviews/visualdatamodel/visualdatamodel.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml b/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml deleted file mode 100644 index 3425150d9a..0000000000 --- a/examples/declarative/modelviews/visualitemmodel/visualitemmodel.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example demonstrates placing items in a view using -// a VisualItemModel - -import QtQuick 2.0 - -Rectangle { - color: "lightgray" - width: 240 - height: 320 - property bool printDestruction: false - - VisualItemModel { - id: itemModel - - Rectangle { - width: view.width; height: view.height - color: "#FFFEF0" - Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: if (printDestruction) print("destroyed 1") - } - Rectangle { - width: view.width; height: view.height - color: "#F0FFF7" - Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: if (printDestruction) print("destroyed 2") - } - Rectangle { - width: view.width; height: view.height - color: "#F4F0FF" - Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: if (printDestruction) print("destroyed 3") - } - } - - ListView { - id: view - anchors { fill: parent; bottomMargin: 30 } - model: itemModel - preferredHighlightBegin: 0; preferredHighlightEnd: 0 - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem; flickDeceleration: 2000 - cacheBuffer: 200 - } - - Rectangle { - width: 240; height: 30 - anchors { top: view.bottom; bottom: parent.bottom } - color: "gray" - - Row { - anchors.centerIn: parent - spacing: 20 - - Repeater { - model: itemModel.count - - Rectangle { - width: 5; height: 5 - radius: 3 - color: view.currentIndex == index ? "blue" : "white" - - MouseArea { - width: 20; height: 20 - anchors.centerIn: parent - onClicked: view.currentIndex = index - } - } - } - } - } -} diff --git a/examples/declarative/openglunderqml/main.cpp b/examples/declarative/openglunderqml/main.cpp deleted file mode 100644 index 3b682deaec..0000000000 --- a/examples/declarative/openglunderqml/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include - -#include "squircle.h" - -int main(int argc, char **argv) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("QtQuick", 2, 0, "Squircle"); - - QQuickView view; - view.setSource(QUrl("main.qml")); - view.show(); - - return app.exec(); - -} diff --git a/examples/declarative/openglunderqml/main.qml b/examples/declarative/openglunderqml/main.qml deleted file mode 100644 index 1485cbbdb8..0000000000 --- a/examples/declarative/openglunderqml/main.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - - width: 400 - height: 300 - - Squircle { - SequentialAnimation on t { - NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad } - NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad } - loops: Animation.Infinite - running: true - } - } - - Rectangle { - color: Qt.rgba(1, 1, 1, 0.8); - radius: 10 - border.width: 1 - border.color: "white" - anchors.fill: label - anchors.margins: -10 - } - - Text { - id: label - color: "black" - wrapMode: Text.WordWrap - text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickCanvas. This text label and its border is rendered using QML" - anchors.right: parent.right - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.margins: 20 - } - -} diff --git a/examples/declarative/openglunderqml/openglunderqml.pro b/examples/declarative/openglunderqml/openglunderqml.pro deleted file mode 100644 index 117ad0c33e..0000000000 --- a/examples/declarative/openglunderqml/openglunderqml.pro +++ /dev/null @@ -1,6 +0,0 @@ -QT += declarative quick - -HEADERS += squircle.h -SOURCES += squircle.cpp main.cpp - -OTHER_FILES += main.qml diff --git a/examples/declarative/openglunderqml/squircle.cpp b/examples/declarative/openglunderqml/squircle.cpp deleted file mode 100644 index b56f0baaf6..0000000000 --- a/examples/declarative/openglunderqml/squircle.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "squircle.h" - -#include -#include -#include - -Squircle::Squircle() - : m_program(0) -{ - setFlag(ItemHasContents); -} - -void Squircle::itemChange(ItemChange change, const ItemChangeData &) -{ - // The ItemSceneChange event is sent when we are first attached to a canvas. - if (change == ItemSceneChange) { - QQuickCanvas *c = canvas(); - - // Connect our the beforeRendering signal to our paint function. - // Since this call is executed on the rendering thread it must be - // a Qt::DirectConnection - connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection); - - // If we allow QML to do the clearing, they would clear what we paint - // and nothing would show. - c->setClearBeforeRendering(false); - } -} - - -void Squircle::paint() -{ - if (!m_program) { - m_program = new QOpenGLShaderProgram(); - m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, - "attribute highp vec4 vertices;" - "varying highp vec2 coords;" - "void main() {" - " gl_Position = vertices;" - " coords = vertices.xy;" - "}"); - m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, - "uniform lowp float t;" - "varying highp vec2 coords;" - "void main() {" - " lowp float i = 1. - (pow(coords.x, 4.) + pow(coords.y, 4.));" - " i = smoothstep(t - 0.3, t + 0.3, i);" - " gl_FragColor = vec4(coords / 2. + .5, i, i);" - "}"); - - m_program->bindAttributeLocation("vertices", 0); - m_program->link(); - } - - m_program->bind(); - - m_program->enableAttributeArray(0); - - float values[] = { - -1, -1, - 1, -1, - -1, 1, - 1, 1 - }; - m_program->setAttributeArray(0, GL_FLOAT, values, 2); - m_program->setUniformValue("t", (float) m_t); - - glDisable(GL_DEPTH_TEST); - - glClearColor(0, 0, 0, 1); - glClear(GL_COLOR_BUFFER_BIT); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - m_program->disableAttributeArray(0); - m_program->release(); -} - - diff --git a/examples/declarative/openglunderqml/squircle.h b/examples/declarative/openglunderqml/squircle.h deleted file mode 100644 index 283131a662..0000000000 --- a/examples/declarative/openglunderqml/squircle.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SQUIRCLE_H -#define SQUIRCLE_H - -#include -#include - -class Squircle : public QQuickItem -{ - Q_OBJECT - - Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged) - -public: - Squircle(); - - qreal t() const { return m_t; } - void setT(qreal t) { m_t = t; emit tChanged(); } - - void itemChange(ItemChange change, const ItemChangeData &); - -signals: - void tChanged(); - -public slots: - void paint(); - -private: - QOpenGLShaderProgram *m_program; - - qreal m_t; - bool m_render_under; - bool m_render_over; -}; - -#endif // SQUIRCLE_H diff --git a/examples/declarative/painteditem/painteditem.pro b/examples/declarative/painteditem/painteditem.pro deleted file mode 100644 index e3afd6b0f0..0000000000 --- a/examples/declarative/painteditem/painteditem.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = \ - smile \ - textballoons diff --git a/examples/declarative/painteditem/smile/main.cpp b/examples/declarative/painteditem/smile/main.cpp deleted file mode 100644 index 1e6b42351d..0000000000 --- a/examples/declarative/painteditem/smile/main.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -class MyPaintItem : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged) -public: - MyPaintItem() - : QQuickPaintedItem() - , m_face(QLatin1String(":-)")) - { - setAntialiasing(true); - } - QString face() const {return m_face;} - void setFace(const QString &face) { - if (m_face != face) { - m_face = face; - emit faceChanged(); - } - } - virtual void paint(QPainter *p) - { - QRectF rect(0, 0, width(), height()); - rect.adjust(10, 10, -10, -10); - p->setPen(QPen(Qt::black, 20)); - p->setBrush(Qt::yellow); - p->drawEllipse(rect); - p->setPen(Qt::black); - p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2))); - p->drawText(rect, Qt::AlignCenter, m_face); - } -signals: - void faceChanged(); -private: - QString m_face; -}; - -int main(int argc, char ** argv) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("MyModule", 1, 0, "MyPaintItem"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("smile.qml")); - view.show(); - view.raise(); - - return app.exec(); -} - -#include "main.moc" diff --git a/examples/declarative/painteditem/smile/smile.pro b/examples/declarative/painteditem/smile/smile.pro deleted file mode 100644 index 780d351fe6..0000000000 --- a/examples/declarative/painteditem/smile/smile.pro +++ /dev/null @@ -1,11 +0,0 @@ -TEMPLATE = app -TARGET = painteditem - -QT += declarative quick - -macx: CONFIG -= app_bundle - -SOURCES += main.cpp - -CONFIG += console - diff --git a/examples/declarative/painteditem/smile/smile.qml b/examples/declarative/painteditem/smile/smile.qml deleted file mode 100644 index 33919bc04f..0000000000 --- a/examples/declarative/painteditem/smile/smile.qml +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import MyModule 1.0 - -Rectangle { - width: 500 - height: 500 - gradient: Gradient { - GradientStop { position: 0.0; color: "#00249a" } - GradientStop { position: 0.7; color: "#ffd94f" } - GradientStop { position: 1.0; color: "#ffa322" } - } - MyPaintItem { - renderTarget:PaintedItem.Image - clip:true - width:240 - height:240 - anchors.left : parent.left - anchors.top :parent.top - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } - MyPaintItem { - clip:true - renderTarget:PaintedItem.Image - width:240 - height:240 - anchors.right : parent.right - anchors.top :parent.top - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } - MyPaintItem { - clip:true - renderTarget:PaintedItem.Image - width:240 - height:240 - anchors.left : parent.left - anchors.bottom :parent.bottom - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } - MyPaintItem { - clip:true - renderTarget:PaintedItem.Image - width:240 - height:240 - anchors.right : parent.right - anchors.bottom :parent.bottom - anchors.margins: 10 - smooth: true - MouseArea { - anchors.fill:parent - onClicked: { - if (parent.face == ":-)") - parent.face = ":-("; - else - parent.face = ":-)"; - parent.update() - } - } - } -} \ No newline at end of file diff --git a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h deleted file mode 100644 index f444d31f4e..0000000000 --- a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/plugin.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include "../textballoon.h" - -class TextBalloonPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "textballoon.json") -public: - void registerTypes(const char *uri) - { - qmlRegisterType(uri, 1, 0, "TextBalloon"); - } -}; diff --git a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/qmldir b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/qmldir deleted file mode 100644 index e8a08ae9d3..0000000000 --- a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmltextballoonplugin diff --git a/examples/declarative/painteditem/textballoons/textballoon.cpp b/examples/declarative/painteditem/textballoons/textballoon.cpp deleted file mode 100644 index d097adfe1b..0000000000 --- a/examples/declarative/painteditem/textballoons/textballoon.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "textballoon.h" - -//! [0] -TextBalloon::TextBalloon(QQuickItem *parent) - : QQuickPaintedItem(parent) - , rightAligned(false) -{ -} -//! [0] - -//! [1] -void TextBalloon::paint(QPainter *painter) -{ - QBrush brush(QColor("#007430")); - - painter->setBrush(brush); - painter->setPen(Qt::NoPen); - painter->setRenderHint(QPainter::Antialiasing); - - painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height() - 10, 10, 10); - - if (rightAligned) - { - const QPointF points[3] = { - QPointF(boundingRect().width() - 10.0, boundingRect().height() - 10.0), - QPointF(boundingRect().width() - 20.0, boundingRect().height()), - QPointF(boundingRect().width() - 30.0, boundingRect().height() - 10.0), - }; - painter->drawConvexPolygon(points, 3); - } - else - { - const QPointF points[3] = { - QPointF(10.0, boundingRect().height() - 10.0), - QPointF(20.0, boundingRect().height()), - QPointF(30.0, boundingRect().height() - 10.0), - }; - painter->drawConvexPolygon(points, 3); - } -} -//! [1] - -bool TextBalloon::isRightAligned() -{ - return this->rightAligned; -} - -void TextBalloon::setRightAligned(bool rightAligned) -{ - this->rightAligned = rightAligned; -} diff --git a/examples/declarative/painteditem/textballoons/textballoon.h b/examples/declarative/painteditem/textballoons/textballoon.h deleted file mode 100644 index 93ed0a7105..0000000000 --- a/examples/declarative/painteditem/textballoons/textballoon.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TEXTBALLOON_H -#define TEXTBALLOON_H - -#include - -//! [0] -class TextBalloon : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged) - - public: - TextBalloon(QQuickItem *parent = 0); - void paint(QPainter *painter); - - bool isRightAligned(); - void setRightAligned(bool rightAligned); - - private: - bool rightAligned; - - signals: - void rightAlignedChanged(); -}; -//! [0] - -#endif diff --git a/examples/declarative/painteditem/textballoons/textballoons.pro b/examples/declarative/painteditem/textballoons/textballoons.pro deleted file mode 100644 index e0b9404f65..0000000000 --- a/examples/declarative/painteditem/textballoons/textballoons.pro +++ /dev/null @@ -1,25 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative quick - -TARGET = qmltextballoonplugin - -HEADERS += TextBalloonPlugin/plugin.h \ - textballoon.h - -SOURCES += textballoon.cpp - -OTHER_FILES += textballoon.json - -DESTDIR = TextBalloonPlugin - -qdeclarativesources.files += \ - TextBalloonPlugin/qmldir - -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin - -sources.files = textballoons.qml -sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons -target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin - -INSTALLS = qdeclarativesources sources target diff --git a/examples/declarative/painteditem/textballoons/textballoons.qml b/examples/declarative/painteditem/textballoons/textballoons.qml deleted file mode 100644 index b00ce2bfed..0000000000 --- a/examples/declarative/painteditem/textballoons/textballoons.qml +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import TextBalloonPlugin 1.0 - -Item { - height: 480 - width: 640 - - //! [0] - ListModel { - id: balloonModel - ListElement { - balloonWidth: 200 - } - ListElement { - balloonWidth: 350 - } - } - - ListView { - anchors.bottom: controls.top - anchors.bottomMargin: 2 - anchors.top: parent.top - id: balloonView - delegate: TextBalloon { - anchors.right: index % 2 == 0 ? undefined : parent.right - height: 60 - rightAligned: index % 2 == 0 ? false : true - width: balloonWidth - } - model: balloonModel - spacing: 5 - width: parent.width - } - //! [0] - - //! [1] - Rectangle { - id: controls - - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.margins: 1 - anchors.right: parent.right - border.width: 2 - color: "white" - height: parent.height * 0.15 - - Text { - anchors.centerIn: parent - text: "Add another balloon" - } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - onClicked: { - balloonModel.append({"balloonWidth": Math.floor(Math.random() * 300 + 100)}) - balloonView.positionViewAtIndex(balloonView.count -1, ListView.End) - } - onEntered: { - parent.color = "#8ac953" - } - onExited: { - parent.color = "white" - } - } - } - //! [1] -} diff --git a/examples/declarative/particles/affectors/age.qml b/examples/declarative/particles/affectors/age.qml deleted file mode 100644 index 1e7774b63b..0000000000 --- a/examples/declarative/particles/affectors/age.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root - width: 360 - height: 600 - color: "white" - - ParticleSystem { id: particles } - - ImageParticle { - system: particles - sprites: Sprite { - name: "snow" - source: "../images/snowflake.png" - frames: 51 - frameDuration: 40 - frameDurationVariation: 8 - } - } - - Emitter { - system: particles - emitRate: 20 - lifeSpan: 8000 - speed: PointDirection { y:80; yVariation: 40; } - acceleration: PointDirection { y: 4 } - size: 36 - endSize: 12 - sizeVariation: 8 - width: parent.width - height: 100 - } - - MouseArea { - id: ma - anchors.fill: parent - hoverEnabled: true - } - - Rectangle { - color: "#803333AA" - border.color: "black" - x: ma.mouseX - 36 - y: ma.mouseY - 36 - width: 72 - height: 72 - Age { - anchors.fill: parent - system: particles - once: true - lifeLeft: 1200 - advancePosition: false - } - } -} diff --git a/examples/declarative/particles/affectors/attractor.qml b/examples/declarative/particles/affectors/attractor.qml deleted file mode 100644 index 460a497a92..0000000000 --- a/examples/declarative/particles/affectors/attractor.qml +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root - width: 360 - height: 540 - color: "black" - property bool spacePressed: false - focus: true - Image { - source: "../images/finalfrontier.png" - anchors.centerIn:parent - } - Keys.onPressed: { - if (event.key == Qt.Key_Space) { - spacePressed = true; - event.accepted = true; - } - } - Keys.onReleased: { - if (event.key == Qt.Key_Space) { - spacePressed = false; - event.accepted = true; - } - } - - Emitter { - group: "stars" - system: particles - emitRate: 40 - lifeSpan: 4000 - enabled: true - size: 30 - sizeVariation: 10 - speed: PointDirection { x: 220; xVariation: 40 } - height: parent.height - } - Emitter { - group: "roids" - system: particles - emitRate: 10 - lifeSpan: 4000 - enabled: true - size: 30 - sizeVariation: 10 - speed: PointDirection { x: 220; xVariation: 40 } - height: parent.height - } - ParticleSystem { - id: particles - anchors.fill: parent - } - ImageParticle { - id: stars - groups: ["stars"] - system: particles - source: "../images/star.png" - color: "white" - colorVariation: 0.1 - alpha: 0 - } - ImageParticle { - id: roids - groups: ["roids"] - system: particles - sprites: Sprite { - id: spinState - name: "spinning" - source: "../images/meteor.png" - frames: 35 - frameDuration: 60 - } - } - ImageParticle { - id: shot - groups: ["shot"] - system: particles - source: "../images/star.png" - - color: "#0FF06600" - colorVariation: 0.3 - } - ImageParticle { - id: engine - groups: ["engine"] - system: particles - source: "../images/particle4.png" - - color: "orange" - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { - from: "red" - to: "cyan" - duration: 1000 - } - ColorAnimation { - from: "cyan" - to: "red" - duration: 1000 - } - } - - colorVariation: 0.2 - } - Attractor { - id: gs; pointX: root.width/2; pointY: root.height/2; strength: 4000000; - system: particles - affectedParameter: Attractor.Acceleration - proportionalToDistance: Attractor.InverseQuadratic - } - Age { - system: particles - x: gs.pointX - 8; - y: gs.pointY - 8; - width: 16 - height: 16 - } - Rectangle { - color: "black" - width: 8 - height: 8 - radius: 4 - x: gs.pointX - 4 - y: gs.pointY - 4 - } - - Image { - source:"../images/rocket2.png" - id: ship - width: 45 - height: 22 - MouseArea { - id: ma - anchors.fill: parent; - drag.axis: Drag.XandYAxis - drag.target: ship - } - } - Emitter { - group: "engine" - system: particles - emitRate: 200 - lifeSpan: 1000 - size: 10 - endSize: 4 - sizeVariation: 4 - speed: PointDirection { x: -128; xVariation: 32 } - height: ship.height - y: ship.y - x: ship.x - width: 20 - } - Emitter { - group: "shot" - system: particles - emitRate: 32 - lifeSpan: 2000 - enabled: spacePressed - size: 40 - speed: PointDirection { x: 256; } - x: ship.x + ship.width - y: ship.y + ship.height/2 - } - - Text { - color: "white" - anchors.bottom: parent.bottom - text:"Drag the ship, Spacebar to fire." - } -} - diff --git a/examples/declarative/particles/affectors/customaffector.qml b/examples/declarative/particles/affectors/customaffector.qml deleted file mode 100644 index 3f98cd5b43..0000000000 --- a/examples/declarative/particles/affectors/customaffector.qml +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - width: 360 - height: 600 - - Image { - source: "../images/backgroundLeaves.jpg" - anchors.fill: parent - } - ParticleSystem { - id: sys - } - Emitter { - system: sys - width: parent.width - emitRate: 4 - lifeSpan: 14000 - size: 80 - speed: PointDirection { y: 60 } - } - Wander { - system: sys - anchors.fill: parent - anchors.bottomMargin: 100 - xVariance: 60 - pace: 60 - } - - Affector { - system: sys - property real coefficient: 0.1 - property real speed: 1.5 - width: parent.width - height: parent.height - 100 - onAffectParticles: { - /* //Linear movement - if (particle.r == 0) { - particle.r = Math.random() > 0.5 ? -1 : 1; - }else if (particle.r == 1) { - particle.rotation += speed * dt; - if(particle.rotation >= maxAngle) - particle.r = -1; - }else if (particle.r == -1) { - particle.rotation -= speed * dt; - if(particle.rotation <= -1 * maxAngle) - particle.r = 1; - } - */ - //Wobbly movement - for (var i=0; i 1.) - currentSize = 0.; - - highp vec2 pos = qt_ParticlePos - - currentSize / 2. + currentSize * qt_ParticleTex // adjust size - + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector.. - + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.); - - gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1); - - highp float fadeIn = min(t * 20., 1.); - highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.)); - - fFade = fadeIn * fadeOut * qt_Opacity; - fPos = vec2(pos.x/1024., pos.y/768.); - } - " - fragmentShader: " - varying highp vec2 fPos; - varying lowp float fFade; - varying highp vec2 qt_TexCoord0; - void main() {//*2 because this generates dark colors mostly - highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0); - highp float dist = length(circlePos); - highp float circleFactor = max(min(1.0 - dist, 1.0), 0.0); - gl_FragColor = vec4(fPos.x*2.0 - fPos.y, fPos.y*2.0 - fPos.x, fPos.x*fPos.y*2.0, 0.0) * circleFactor * fFade; - }" - - } -} diff --git a/examples/declarative/particles/customparticle/imagecolors.qml b/examples/declarative/particles/customparticle/imagecolors.qml deleted file mode 100644 index 94e5123a0c..0000000000 --- a/examples/declarative/particles/customparticle/imagecolors.qml +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: root - color: "white" - width: 310 - height: 300 - anchors.centerIn: parent - ParticleSystem { id: sys } - CustomParticle { - system: sys - property real maxWidth: root.width - property real maxHeight: root.height - ShaderEffectSource { - id: pictureSource - sourceItem: picture - hideSource: true - } - Image { - id: picture - source: "../images/starfish_3.png" - } - ShaderEffectSource { - id: particleSource - sourceItem: particle - hideSource: true - } - Image { - id: particle - source: "../images/particle4.png" - } - vertexShader:" - uniform highp float maxWidth; - uniform highp float maxHeight; - varying highp vec2 fTex2; - varying lowp float fFade; - uniform lowp float qt_Opacity; - - void main() { - fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight); - highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y; - fFade = min(t*4., (1.-t*t)*.75) * qt_Opacity; - defaultMain(); - } - " - property variant particleTexture: particleSource - property variant pictureTexture: pictureSource - fragmentShader: " - uniform sampler2D particleTexture; - uniform sampler2D pictureTexture; - varying highp vec2 qt_TexCoord0; - varying highp vec2 fTex2; - varying lowp float fFade; - void main() { - gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, qt_TexCoord0).w * fFade; - }" - } - - Emitter { - id: emitter - system: sys - enabled: false - lifeSpan: 8000 - maximumEmitted: 4000 - anchors.fill: parent - size: 16 - acceleration: PointDirection { xVariation: 12; yVariation: 12 } - } - MouseArea { - anchors.fill: parent - onClicked: emitter.burst(4000); - } - } -} diff --git a/examples/declarative/particles/emitters/burstandpulse.qml b/examples/declarative/particles/emitters/burstandpulse.qml deleted file mode 100644 index 1b1c2a60c9..0000000000 --- a/examples/declarative/particles/emitters/burstandpulse.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 540 - color: "black" - MouseArea { - id: ma - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - if (mouse.button == Qt.LeftButton) - emitter.burst(1000); - else - emitter.pulse(500); - } - } - - ParticleSystem { - id: particles - } - - ImageParticle { - anchors.fill: parent - system: particles - source: "../images/star.png" - alpha: 0 - colorVariation: 0.6 - } - - Emitter { - id: emitter - x: ma.mouseX - y: ma.mouseY - system: particles - emitRate: 2000 - lifeSpan: 2000 - enabled: false - speed: AngleDirection{magnitude: 64; angleVariation: 360} - size: 24 - sizeVariation: 8 - } -} diff --git a/examples/declarative/particles/emitters/customemitter.qml b/examples/declarative/particles/emitters/customemitter.qml deleted file mode 100644 index 757c836106..0000000000 --- a/examples/declarative/particles/emitters/customemitter.qml +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -ParticleSystem { - id: sys - width: 360 - height: 600 - running: true - Rectangle { - z: -1 - anchors.fill: parent - color: "black" - } - - property real petalLength: 180 - property real petalRotation: 0 - NumberAnimation on petalRotation { - from: 0; - to: 360; - loops: -1; - running: true - duration: 24000 - } - - function convert(a) {return a*(Math.PI/180);} - Emitter { - lifeSpan: 4000 - emitRate: 120 - size: 12 - anchors.centerIn: parent - onEmitParticles: { - for (var i=0; i 400 ? 32 : 16 - } -} diff --git a/examples/declarative/particles/imageparticle/colored.qml b/examples/declarative/particles/imageparticle/colored.qml deleted file mode 100644 index ac760b6219..0000000000 --- a/examples/declarative/particles/imageparticle/colored.qml +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 540 - color: "black" - ParticleSystem { - anchors.fill: parent - ImageParticle { - groups: ["stars"] - anchors.fill: parent - source: "../images/star.png" - } - Emitter { - group: "stars" - emitRate: 800 - lifeSpan: 2400 - size: 24 - sizeVariation: 8 - anchors.fill: parent - } - - ImageParticle { - anchors.fill: parent - source: "../images/star.png" - alpha: 0 - alphaVariation: 0.2 - colorVariation: 1.0 - } - - Emitter { - anchors.centerIn: parent - emitRate: 400 - lifeSpan: 2400 - size: 48 - sizeVariation: 8 - speed: AngleDirection {angleVariation: 180; magnitude: 60} - } - - Turbulence { - anchors.fill: parent - strength: 2 - } - } -} diff --git a/examples/declarative/particles/imageparticle/colortable.qml b/examples/declarative/particles/imageparticle/colortable.qml deleted file mode 100644 index 623029dae0..0000000000 --- a/examples/declarative/particles/imageparticle/colortable.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick.Particles 2.0 -import QtQuick 2.0 - -Rectangle { - id: root - width: 360 - height: 540 - color: "black" - - ParticleSystem { id: particles } - - ImageParticle { - system: particles - colorVariation: 0.5 - alpha: 0 - - source: "../images/particle.png" - colorTable: "../images/colortable.png" - sizeTable: "../images/colortable.png" - } - - Emitter { - system: particles - emitRate: 500 - lifeSpan: 2000 - - y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3 - x: root.width / 2 + Math.cos(t) * root.width * 0.3 - property real t; - - NumberAnimation on t { - from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite - } - - speedFromMovement: 20 - - speed: PointDirection { xVariation: 5; yVariation: 5;} - acceleration: PointDirection { xVariation: 5; yVariation: 5;} - - size: 16 - //endSize: 8 - //sizeVariation: 8 - } -} diff --git a/examples/declarative/particles/imageparticle/deformation.qml b/examples/declarative/particles/imageparticle/deformation.qml deleted file mode 100644 index e282927e78..0000000000 --- a/examples/declarative/particles/imageparticle/deformation.qml +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - color: "goldenrod" - width: 400 - height: 400 - ParticleSystem {id:sys} - - ImageParticle { - system: sys - groups: ["goingLeft", "goingRight"] - source: "../images/starfish_4.png" - rotation: 90 - rotationSpeed: 90 - autoRotation: true - } - ImageParticle { - system: sys - groups: ["goingDown"] - source: "../images/starfish_0.png" - rotation: 180 - yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; } - } - - Timer { - running: true - repeat: false - interval: 100 - onTriggered: emitA.enabled = true; - } - Timer { - running: true - repeat: false - interval: 4200 - onTriggered: emitB.enabled = true; - } - Timer { - running: true - repeat: false - interval: 8400 - onTriggered: emitC.enabled = true; - } - - Emitter { - id: emitA - x: 0 - y: 120 - system: sys - enabled: false - group: "goingRight" - speed: PointDirection { x: 100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } - Emitter { - id: emitB - x: 400 - y: 240 - system: sys - enabled: false - group: "goingLeft" - speed: PointDirection { x: -100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } - Emitter { - id: emitC - x: 0 - y: 360 - system: sys - enabled: false - group: "goingDown" - speed: PointDirection { x: 100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } -} diff --git a/examples/declarative/particles/imageparticle/rotation.qml b/examples/declarative/particles/imageparticle/rotation.qml deleted file mode 100644 index 3a75c379ed..0000000000 --- a/examples/declarative/particles/imageparticle/rotation.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - color: "goldenrod" - width: 2000 - height: 2000 - ParticleSystem {id: sys} - ImageParticle { - id: up - system: sys - source: "../images/starfish_2.png" - } - - Emitter { - anchors.centerIn: parent - system: sys - emitRate: 10 - size: 200 - lifeSpan: 10000 - speed: AngleDirection {angleVariation: 360; magnitudeVariation: 100;} - } - - MouseArea { - anchors.fill: parent - onClicked: { - up.autoRotation = !up.autoRotation - up.rotation = up.autoRotation ? -90 : 0 - } - } -} diff --git a/examples/declarative/particles/imageparticle/sharing.qml b/examples/declarative/particles/imageparticle/sharing.qml deleted file mode 100644 index 27e08322d9..0000000000 --- a/examples/declarative/particles/imageparticle/sharing.qml +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example shows how to create your own highlight delegate for a ListView -// that uses a SpringAnimation to provide custom movement when the -// highlight bar is moved between items. - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - property real delegateHeight: 65 - width: 200; height: 300 - gradient: Gradient { - GradientStop { position: 0.0; color: "#EEEEFF" } - GradientStop { position: 1.0; color: "lightblue" } - } - - // Define a delegate component. A component will be - // instantiated for each visible item in the list. - Component { - id: petDelegate - Item { - id: wrapper - width: 200; height: delegateHeight - z: 10 - Column { - Text {color: "white"; text: name; font.pixelSize: 18 } - Text {color: "white"; text: 'Type: ' + type; font.pixelSize: 14 } - Text {color: "white"; text: 'Age: ' + age; font.pixelSize: 14 } - } - // indent the item if it is the current item - states: State { - name: "Current" - when: wrapper.ListView.isCurrentItem - PropertyChanges { target: wrapper; x: 20 } - } - transitions: Transition { - NumberAnimation { properties: "x"; duration: 200 } - } - } - } - - // Define a highlight with customised movement between items. - Component { - id: highlightBar - Rectangle { - z: 0 - width: 200; height: delegateHeight - gradient: Gradient { - GradientStop { position: 0.0; color: "#99FF99" } - GradientStop { position: 1.0; color: "#88FF88" } - } - y: listView.currentItem.y; - Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } - ImageParticle { - anchors.fill: parent - system: particles - source: "../images/flower.png" - color: "red" - clip: true - alpha: 1.0 - } - } - } - - ListView { - id: listView - width: 200; height: parent.height - - model: petsModel - delegate: petDelegate - focus: true - - // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem - // to false so the highlight delegate can control how the highlight is moved. - highlight: highlightBar - highlightFollowsCurrentItem: false - - ParticleSystem { id: particles } - Emitter { - system: particles - anchors.fill: parent - emitRate: 1 - lifeSpan: 10000 - size: 24 - sizeVariation: 8 - speed: AngleDirection { angleVariation: 360; magnitude: 3 } - maximumEmitted: 10 - startTime: 5000 - } - - ImageParticle { - anchors.fill: parent - system: particles - source: "../images/flower.png" - alpha: 0.1 - color: "white" - rotationVariation: 180 - z: -1 - } - } - - ListModel { - id: petsModel - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } - } - -} diff --git a/examples/declarative/particles/imageparticle/sprites.qml b/examples/declarative/particles/imageparticle/sprites.qml deleted file mode 100644 index 0fe4f31ea3..0000000000 --- a/examples/declarative/particles/imageparticle/sprites.qml +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - color: "lightsteelblue" - width: 800 - height: 800 - id: root - - SpriteImage { - sprites: Sprite { - name: "bear" - source: "../images/bear_tiles.png" - frames: 13 - frameDuration: 120 - } - width: 250 - height: 250 - x: 20 - anchors.bottom: parent.bottom - anchors.bottomMargin: 20 - z:4 - } - - ParticleSystem { id: sys } - - ImageParticle { - anchors.fill: parent - id: particles - system: sys - sprites: [Sprite { - name: "happy" - source: "../images/starfish_1.png" - frames: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "angry": 1} - }, Sprite { - name: "angry" - source: "../images/starfish_0.png" - frames: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "angry": 1} - }, Sprite { - name: "silly" - source: "../images/starfish_2.png" - frames: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "noticedbear": 0} - }, Sprite { - name: "noticedbear" - source: "../images/starfish_3.png" - frames: 1 - frameDuration: 2600 - }] - } - - Emitter { - system: sys - emitRate: 2 - lifeSpan: 10000 - speed: AngleDirection {angle: 90; magnitude: 60; angleVariation: 5} - acceleration: PointDirection { y: 10 } - size: 160 - sizeVariation: 40 - width: parent.width - height: 100 - } - - SpriteGoal { - system: sys - width: root.width; - height: root.height/2; - y: root.height/2; - goalState:"noticedbear" - } -} diff --git a/examples/declarative/particles/images/_explo.png b/examples/declarative/particles/images/_explo.png deleted file mode 100644 index 4297245d49..0000000000 Binary files a/examples/declarative/particles/images/_explo.png and /dev/null differ diff --git a/examples/declarative/particles/images/backgroundLeaves.jpg b/examples/declarative/particles/images/backgroundLeaves.jpg deleted file mode 100755 index 08be16751d..0000000000 Binary files a/examples/declarative/particles/images/backgroundLeaves.jpg and /dev/null differ diff --git a/examples/declarative/particles/images/bear_tiles.png b/examples/declarative/particles/images/bear_tiles.png deleted file mode 100644 index 6bbb2a9b6d..0000000000 Binary files a/examples/declarative/particles/images/bear_tiles.png and /dev/null differ diff --git a/examples/declarative/particles/images/candle.png b/examples/declarative/particles/images/candle.png deleted file mode 100644 index 8fa3193719..0000000000 Binary files a/examples/declarative/particles/images/candle.png and /dev/null differ diff --git a/examples/declarative/particles/images/colortable.png b/examples/declarative/particles/images/colortable.png deleted file mode 100644 index a62ceeb4a0..0000000000 Binary files a/examples/declarative/particles/images/colortable.png and /dev/null differ diff --git a/examples/declarative/particles/images/finalfrontier.png b/examples/declarative/particles/images/finalfrontier.png deleted file mode 100644 index 2ba1815230..0000000000 Binary files a/examples/declarative/particles/images/finalfrontier.png and /dev/null differ diff --git a/examples/declarative/particles/images/flower.png b/examples/declarative/particles/images/flower.png deleted file mode 100644 index b5c606210e..0000000000 Binary files a/examples/declarative/particles/images/flower.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/allatonce.png b/examples/declarative/particles/images/launcherIcons/allatonce.png deleted file mode 100644 index b61d2d50d8..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/allatonce.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/attractor.png b/examples/declarative/particles/images/launcherIcons/attractor.png deleted file mode 100644 index 4bd8040c3b..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/attractor.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/blurparticles.png b/examples/declarative/particles/images/launcherIcons/blurparticles.png deleted file mode 100644 index 4337f979cb..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/blurparticles.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/close.png b/examples/declarative/particles/images/launcherIcons/close.png deleted file mode 100644 index c37714ee8f..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/close.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/colortable.png b/examples/declarative/particles/images/launcherIcons/colortable.png deleted file mode 100644 index 8841ea30f9..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/colortable.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/customaffector.png b/examples/declarative/particles/images/launcherIcons/customaffector.png deleted file mode 100644 index d02e7918fa..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/customaffector.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/customemitter.png b/examples/declarative/particles/images/launcherIcons/customemitter.png deleted file mode 100644 index 6d492573d1..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/customemitter.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/deformation.png b/examples/declarative/particles/images/launcherIcons/deformation.png deleted file mode 100644 index d1b722df01..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/deformation.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/delegates.png b/examples/declarative/particles/images/launcherIcons/delegates.png deleted file mode 100644 index 929414cd0e..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/delegates.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/dynamicemitters.png b/examples/declarative/particles/images/launcherIcons/dynamicemitters.png deleted file mode 100644 index 0cdef9d21e..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/dynamicemitters.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/emitmask.png b/examples/declarative/particles/images/launcherIcons/emitmask.png deleted file mode 100644 index e943a4adb9..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/emitmask.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/flickr.png b/examples/declarative/particles/images/launcherIcons/flickr.png deleted file mode 100644 index 4de2650280..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/flickr.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/fragmentshader.png b/examples/declarative/particles/images/launcherIcons/fragmentshader.png deleted file mode 100644 index 7c6de498d5..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/fragmentshader.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/gridsplosion.png b/examples/declarative/particles/images/launcherIcons/gridsplosion.png deleted file mode 100644 index ec75453df6..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/gridsplosion.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/groupgoal.png b/examples/declarative/particles/images/launcherIcons/groupgoal.png deleted file mode 100644 index 69c6f64e54..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/groupgoal.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/imagecolors.png b/examples/declarative/particles/images/launcherIcons/imagecolors.png deleted file mode 100644 index 0ff13a346e..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/imagecolors.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/list.png b/examples/declarative/particles/images/launcherIcons/list.png deleted file mode 100644 index bc13263cff..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/list.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/maximumemitted.png b/examples/declarative/particles/images/launcherIcons/maximumemitted.png deleted file mode 100644 index 4ef0435991..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/maximumemitted.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/multiplepainters.png b/examples/declarative/particles/images/launcherIcons/multiplepainters.png deleted file mode 100644 index a28e3c4f02..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/multiplepainters.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/package.png b/examples/declarative/particles/images/launcherIcons/package.png deleted file mode 100644 index eba8951c26..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/package.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/particleview.png b/examples/declarative/particles/images/launcherIcons/particleview.png deleted file mode 100644 index a74f9a0340..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/particleview.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/plasmapatrol.png b/examples/declarative/particles/images/launcherIcons/plasmapatrol.png deleted file mode 100644 index fda852b420..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/plasmapatrol.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/remove.png b/examples/declarative/particles/images/launcherIcons/remove.png deleted file mode 100644 index c37714ee8f..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/remove.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/rotation.png b/examples/declarative/particles/images/launcherIcons/rotation.png deleted file mode 100644 index 6a8dbea236..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/rotation.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/samegame.png b/examples/declarative/particles/images/launcherIcons/samegame.png deleted file mode 100644 index d00698264b..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/samegame.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/shapeanddirection.png b/examples/declarative/particles/images/launcherIcons/shapeanddirection.png deleted file mode 100644 index 9c1f910d0c..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/shapeanddirection.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/spaceexplorer.png b/examples/declarative/particles/images/launcherIcons/spaceexplorer.png deleted file mode 100644 index 770584a0fa..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/spaceexplorer.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/spritegoal.png b/examples/declarative/particles/images/launcherIcons/spritegoal.png deleted file mode 100644 index 77480c6f09..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/spritegoal.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/sprites.png b/examples/declarative/particles/images/launcherIcons/sprites.png deleted file mode 100644 index 144216ac7c..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/sprites.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/spritevariedparticles.png b/examples/declarative/particles/images/launcherIcons/spritevariedparticles.png deleted file mode 100644 index 495bb6beee..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/spritevariedparticles.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/startstop.png b/examples/declarative/particles/images/launcherIcons/startstop.png deleted file mode 100644 index 0ff53196a6..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/startstop.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/timedgroupchanges.png b/examples/declarative/particles/images/launcherIcons/timedgroupchanges.png deleted file mode 100644 index ec9f826495..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/timedgroupchanges.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/trailemitter.png b/examples/declarative/particles/images/launcherIcons/trailemitter.png deleted file mode 100644 index 39acf8b40d..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/trailemitter.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/trails.png b/examples/declarative/particles/images/launcherIcons/trails.png deleted file mode 100644 index 0337ebcfd8..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/trails.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/turbulence.png b/examples/declarative/particles/images/launcherIcons/turbulence.png deleted file mode 100644 index 2b9446ea90..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/turbulence.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/velocityfrommotion.png b/examples/declarative/particles/images/launcherIcons/velocityfrommotion.png deleted file mode 100644 index 79baa08293..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/velocityfrommotion.png and /dev/null differ diff --git a/examples/declarative/particles/images/launcherIcons/wander.png b/examples/declarative/particles/images/launcherIcons/wander.png deleted file mode 100644 index d98e14b8ae..0000000000 Binary files a/examples/declarative/particles/images/launcherIcons/wander.png and /dev/null differ diff --git a/examples/declarative/particles/images/matchmask.png b/examples/declarative/particles/images/matchmask.png deleted file mode 100644 index e575875c55..0000000000 Binary files a/examples/declarative/particles/images/matchmask.png and /dev/null differ diff --git a/examples/declarative/particles/images/meteor.png b/examples/declarative/particles/images/meteor.png deleted file mode 100644 index e8c368aea7..0000000000 Binary files a/examples/declarative/particles/images/meteor.png and /dev/null differ diff --git a/examples/declarative/particles/images/meteor_explo.png b/examples/declarative/particles/images/meteor_explo.png deleted file mode 100644 index e659bfe2cf..0000000000 Binary files a/examples/declarative/particles/images/meteor_explo.png and /dev/null differ diff --git a/examples/declarative/particles/images/meteors.png b/examples/declarative/particles/images/meteors.png deleted file mode 100644 index bada8a1407..0000000000 Binary files a/examples/declarative/particles/images/meteors.png and /dev/null differ diff --git a/examples/declarative/particles/images/nullRock.png b/examples/declarative/particles/images/nullRock.png deleted file mode 100644 index 4076327a1a..0000000000 Binary files a/examples/declarative/particles/images/nullRock.png and /dev/null differ diff --git a/examples/declarative/particles/images/particle.png b/examples/declarative/particles/images/particle.png deleted file mode 100644 index 5c83896d22..0000000000 Binary files a/examples/declarative/particles/images/particle.png and /dev/null differ diff --git a/examples/declarative/particles/images/particle2.png b/examples/declarative/particles/images/particle2.png deleted file mode 100644 index 36349c6c6e..0000000000 Binary files a/examples/declarative/particles/images/particle2.png and /dev/null differ diff --git a/examples/declarative/particles/images/particle3.png b/examples/declarative/particles/images/particle3.png deleted file mode 100644 index 905d8f37b8..0000000000 Binary files a/examples/declarative/particles/images/particle3.png and /dev/null differ diff --git a/examples/declarative/particles/images/particle4.png b/examples/declarative/particles/images/particle4.png deleted file mode 100644 index bc95b703c1..0000000000 Binary files a/examples/declarative/particles/images/particle4.png and /dev/null differ diff --git a/examples/declarative/particles/images/particleA.png b/examples/declarative/particles/images/particleA.png deleted file mode 100644 index c63acdee1f..0000000000 Binary files a/examples/declarative/particles/images/particleA.png and /dev/null differ diff --git a/examples/declarative/particles/images/portal_bg.png b/examples/declarative/particles/images/portal_bg.png deleted file mode 100644 index 3c59eeabb9..0000000000 Binary files a/examples/declarative/particles/images/portal_bg.png and /dev/null differ diff --git a/examples/declarative/particles/images/realLeaf1.png b/examples/declarative/particles/images/realLeaf1.png deleted file mode 100644 index 6cabf29efd..0000000000 Binary files a/examples/declarative/particles/images/realLeaf1.png and /dev/null differ diff --git a/examples/declarative/particles/images/realLeaf2.png b/examples/declarative/particles/images/realLeaf2.png deleted file mode 100644 index bfeca861d5..0000000000 Binary files a/examples/declarative/particles/images/realLeaf2.png and /dev/null differ diff --git a/examples/declarative/particles/images/realLeaf3.png b/examples/declarative/particles/images/realLeaf3.png deleted file mode 100644 index b1071e862b..0000000000 Binary files a/examples/declarative/particles/images/realLeaf3.png and /dev/null differ diff --git a/examples/declarative/particles/images/realLeaf4.png b/examples/declarative/particles/images/realLeaf4.png deleted file mode 100644 index d61d53d10e..0000000000 Binary files a/examples/declarative/particles/images/realLeaf4.png and /dev/null differ diff --git a/examples/declarative/particles/images/rocket.png b/examples/declarative/particles/images/rocket.png deleted file mode 100644 index a171610b03..0000000000 Binary files a/examples/declarative/particles/images/rocket.png and /dev/null differ diff --git a/examples/declarative/particles/images/rocket2.png b/examples/declarative/particles/images/rocket2.png deleted file mode 100644 index 7110f8fdc6..0000000000 Binary files a/examples/declarative/particles/images/rocket2.png and /dev/null differ diff --git a/examples/declarative/particles/images/sizeInOut.png b/examples/declarative/particles/images/sizeInOut.png deleted file mode 100644 index 0a306ea21a..0000000000 Binary files a/examples/declarative/particles/images/sizeInOut.png and /dev/null differ diff --git a/examples/declarative/particles/images/snowflake.png b/examples/declarative/particles/images/snowflake.png deleted file mode 100644 index 490887a82f..0000000000 Binary files a/examples/declarative/particles/images/snowflake.png and /dev/null differ diff --git a/examples/declarative/particles/images/sparkleSize.png b/examples/declarative/particles/images/sparkleSize.png deleted file mode 100644 index 752056541b..0000000000 Binary files a/examples/declarative/particles/images/sparkleSize.png and /dev/null differ diff --git a/examples/declarative/particles/images/star.png b/examples/declarative/particles/images/star.png deleted file mode 100644 index 0d592cfa87..0000000000 Binary files a/examples/declarative/particles/images/star.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_0.png b/examples/declarative/particles/images/starfish_0.png deleted file mode 100644 index 8747f0236e..0000000000 Binary files a/examples/declarative/particles/images/starfish_0.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_1.png b/examples/declarative/particles/images/starfish_1.png deleted file mode 100644 index 1f3f159d5e..0000000000 Binary files a/examples/declarative/particles/images/starfish_1.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_2.png b/examples/declarative/particles/images/starfish_2.png deleted file mode 100644 index c6c7e5a676..0000000000 Binary files a/examples/declarative/particles/images/starfish_2.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_3.png b/examples/declarative/particles/images/starfish_3.png deleted file mode 100644 index 307a89f815..0000000000 Binary files a/examples/declarative/particles/images/starfish_3.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_4.png b/examples/declarative/particles/images/starfish_4.png deleted file mode 100644 index d61c26545a..0000000000 Binary files a/examples/declarative/particles/images/starfish_4.png and /dev/null differ diff --git a/examples/declarative/particles/images/starfish_mask.png b/examples/declarative/particles/images/starfish_mask.png deleted file mode 100644 index 2ef74f902b..0000000000 Binary files a/examples/declarative/particles/images/starfish_mask.png and /dev/null differ diff --git a/examples/declarative/particles/itemparticle/content/Delegate.qml b/examples/declarative/particles/itemparticle/content/Delegate.qml deleted file mode 100644 index 97c7840cb4..0000000000 --- a/examples/declarative/particles/itemparticle/content/Delegate.qml +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -Package { - Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } - Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } - - Rectangle { - id: wrapper - width: 200; height: 25 - color: 'lightsteelblue' - - Text { text: display; anchors.centerIn: parent } - MouseArea { - anchors.fill: parent - onClicked: { - if (wrapper.state == 'inList') - wrapper.state = 'inGrid'; - else - wrapper.state = 'inList'; - } - } - - state: 'inList' - states: [ - State { - name: 'inList' - ParentChange { target: wrapper; parent: listDelegate } - }, - State { - name: 'inGrid' - ParentChange { - target: wrapper; parent: gridDelegate - x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height - } - } - ] - - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } -} -//![0] diff --git a/examples/declarative/particles/itemparticle/content/Delegate2.qml b/examples/declarative/particles/itemparticle/content/Delegate2.qml deleted file mode 100644 index cf60d43dc2..0000000000 --- a/examples/declarative/particles/itemparticle/content/Delegate2.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -Package { - Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' } - Item { id: particleDelegate; width: w; height: h; Package.name: 'particles' - - Rectangle { - id: wrapper - width: w; height: h; - color: col - rotation: Math.random()*360 - Behavior on rotation {RotationAnimation {}} - - states: State { - name: "gridded" - when: root.inGrid - PropertyChanges { - target: wrapper - rotation: 0 - } - ParentChange { - target: wrapper - parent: gridDelegate - x:0 - y:0 - } - } - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } - } -} -//![0] diff --git a/examples/declarative/particles/itemparticle/content/ExpandingDelegate.qml b/examples/declarative/particles/itemparticle/content/ExpandingDelegate.qml deleted file mode 100644 index 87f723d3f7..0000000000 --- a/examples/declarative/particles/itemparticle/content/ExpandingDelegate.qml +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../../../modelviews/listview/content" - -// This example illustrates expanding a list item to show a more detailed view. - - // Delegate for the recipes. This delegate has two modes: - // 1. List mode (default), which just shows the picture and title of the recipe. - // 2. Details mode, which also shows the ingredients and method. - Component { - id: recipeDelegate - - Item { - id: recipe - - // Create a property to contain the visibility of the details. - // We can bind multiple element's opacity to this one property, - // rather than having a "PropertyChanges" line for each element we - // want to fade. - property real detailsOpacity : 0 - - //this bit changed for aesthetics - width: 70 - height: 70 - // A simple rounded rectangle for the background - Rectangle { - id: background - x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 - color: "ivory" - border.color: "orange" - radius: 5 - } - Image { - anchors.fill:parent - anchors.margins: -32 - source: "bubble.png" - } - - - // This mouse region covers the entire delegate. - // When clicked it changes mode to 'Details'. If we are already - // in Details mode, then no change will happen. - MouseArea { - anchors.fill: parent - onClicked: recipe.state = 'Details'; - } - - // Lay out the page: picture, title and ingredients at the top, and method at the - // bottom. Note that elements that should not be visible in the list - // mode have their opacity set to recipe.detailsOpacity. - Row { - id: topLayout - x: 10; y: 10; height: recipeImage.height; width: parent.width - spacing: 10 - - Image { - id: recipeImage - width: 50; height: 50 - source: "../../modelviews/listview/" + picture - } - - Column { - width: background.width - recipeImage.width - 20; height: recipeImage.height - spacing: 5 - - Text { - text: title - font.bold: true; font.pointSize: 16 - } - - Text { - text: "Ingredients" - font.pointSize: 12; font.bold: true - opacity: recipe.detailsOpacity - } - - Text { - text: ingredients - wrapMode: Text.WordWrap - width: parent.width - opacity: recipe.detailsOpacity - } - } - } - - Item { - id: details - x: 10; width: parent.width - 20 - anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } - opacity: recipe.detailsOpacity - - Text { - id: methodTitle - anchors.top: parent.top - text: "Method" - font.pointSize: 12; font.bold: true - } - - Flickable { - id: flick - width: parent.width - anchors { top: methodTitle.bottom; bottom: parent.bottom } - contentHeight: methodText.height - clip: true - - Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } - } - - Image { - anchors { right: flick.right; top: flick.top } - source: "../../modelviews/listview/" + "content/pics/moreUp.png" - opacity: flick.atYBeginning ? 0 : 1 - } - - Image { - anchors { right: flick.right; bottom: flick.bottom } - source: "../../modelviews/listview/" + "content/pics/moreDown.png" - opacity: flick.atYEnd ? 0 : 1 - } - } - - // A button to close the detailed view, i.e. set the state back to default (''). - TextButton { - y: 10 - anchors { right: background.right; rightMargin: 10 } - opacity: recipe.detailsOpacity - text: "Close" - - onClicked: recipe.state = ''; - } - - states: State { - name: "Details" - - PropertyChanges { target: background; color: "white" } - PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger - PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible - PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view - - // Move the list so that this item is at the top. - //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } - - // Disallow flicking while we're in detailed view - //PropertyChanges { target: recipe.ListView.view; interactive: false } - } - - transitions: Transition { - //The only strictly necessary particle specific lines - to: "Details" - reversible: true - ScriptAction {script: { - if(state == "Details") - mp.freeze(index); - else - mp.unfreeze(index); - } - } - // Make the state changes smooth - ParallelAnimation { - ColorAnimation { property: "color"; duration: 500 } - NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" } - } - } - } - } diff --git a/examples/declarative/particles/itemparticle/content/RssModel.qml b/examples/declarative/particles/itemparticle/content/RssModel.qml deleted file mode 100644 index 46027600b3..0000000000 --- a/examples/declarative/particles/itemparticle/content/RssModel.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - property string tags : "" - - function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } - - source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "") - query: "/feed/entry" - namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" - - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "content"; query: "content/string()" } - XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } -} diff --git a/examples/declarative/particles/itemparticle/content/bubble.png b/examples/declarative/particles/itemparticle/content/bubble.png deleted file mode 100644 index c7f479e9e3..0000000000 Binary files a/examples/declarative/particles/itemparticle/content/bubble.png and /dev/null differ diff --git a/examples/declarative/particles/itemparticle/content/script.js b/examples/declarative/particles/itemparticle/content/script.js deleted file mode 100644 index e8ef93a847..0000000000 --- a/examples/declarative/particles/itemparticle/content/script.js +++ /dev/null @@ -1,27 +0,0 @@ -.pragma library - -function getWidth(string) { - return (string.match(/width=\"([0-9]+)\"/))[1] -} - -function getHeight(string) { - return (string.match(/height=\"([0-9]+)\"/))[1] -} - -function getImagePath(string) { - var pattern = /src=\"http:\/\/(\S+)\"/ - return (string.match(pattern))[1] -} - -function calculateScale(width, height, cellSize) { - var widthScale = (cellSize * 1.0) / width - var heightScale = (cellSize * 1.0) / height - var scale = 0 - - if (widthScale <= heightScale) { - scale = widthScale; - } else if (heightScale < widthScale) { - scale = heightScale; - } - return scale; -} diff --git a/examples/declarative/particles/itemparticle/delegates.qml b/examples/declarative/particles/itemparticle/delegates.qml deleted file mode 100644 index 58734d320a..0000000000 --- a/examples/declarative/particles/itemparticle/delegates.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root; - width: 360 - height: 600 - color: "black" - - function newPithySaying() { - switch (Math.floor(Math.random()*16)) { - case 0: return "Hello World"; - case 1: return "G'day Mate"; - case 2: return "Code Less"; - case 3: return "Create More"; - case 4: return "Deploy Everywhere"; - case 5: return "Qt Meta-object Language"; - case 6: return "Qt Magic Language"; - case 7: return "Fluid UIs"; - case 8: return "Touchable"; - case 9: return "How's it going?"; - case 10: return "Do you like text?"; - case 11: return "Enjoy!"; - case 12: return "ERROR: Out of pith"; - case 13: return "Punctuation Failure"; - case 14: return "I can go faster"; - case 15: return "I can go slower"; - default: return "OMGWTFBBQ"; - } - } - - ParticleSystem { - anchors.fill: parent - id: syssy - Emitter { - anchors.centerIn: parent - emitRate: 1 - lifeSpan: 4800 - lifeSpanVariation: 1600 - speed: AngleDirection {angleVariation: 360; magnitude: 40; magnitudeVariation: 20} - } - ItemParticle { - delegate: Text { - text: root.newPithySaying(); - color: "white" - font.pixelSize: 18 - font.bold: true - } - } - } -} diff --git a/examples/declarative/particles/itemparticle/particleview.qml b/examples/declarative/particles/itemparticle/particleview.qml deleted file mode 100644 index 774539a958..0000000000 --- a/examples/declarative/particles/itemparticle/particleview.qml +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content/script.js" as Script -import "content" - -Item { - id: root - width: 640 - height: 480 - Rectangle { - anchors.fill: parent - color: "black" - z: -1 - } - Item { - id: loading - Behavior on opacity {NumberAnimation {}} - anchors.fill: parent - Text { - anchors.centerIn: parent - text: "Loading" - color: "white" - } - } - ParticleSystem { - id: sys; - running: true - } - Emitter { - id: emitter - system: sys - height: parent.height - 132/2 - x: -132/2 - y: 132/2 - speed: PointDirection { x: 32; xVariation: 8 } - emitRate: 0.5 - lifeSpan: Emitter.InfiniteLife - group: "photos" - } - Age { - system: sys - x: parent.width + 132/2 - height: parent.height - width: 1000 - } - ImageParticle { - system: sys - groups: ["fireworks"] - source: "../trails/../images/star.png" - color: "lightsteelblue" - alpha: 0 - colorVariation: 0 - z: 1000 - } - ItemParticle { - id: mp - z: 0 - system: sys - fade: false - groups: ["photos"] - } - Component { - id: alertDelegate - Rectangle { - width: 132 - height: 132 - NumberAnimation on scale { - running: true - loops: 1 - from: 0.2 - to: 1 - } - Image { - source: "../asteroid/../images/rocket.png" - anchors.centerIn: parent - } - Text { - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - text: "A new ship has arrived!" - } - } - } - property Item alertItem; - function alert() { - //resetter.active = false - force.active = true; - alertItem = alertDelegate.createObject(root); - alertItem.x = root.width/2 - alertItem.width/2 - alertItem.y = root.height/2 - alertItem.height/2 - spawnFireworks.pulse(200); - stopAlert.start(); - } - focus: true - Keys.onSpacePressed: alert(); - Timer { - id: stopAlert - running: false - repeat: false - interval: 800 - onTriggered: { - force.active = false - //resetter.active = true; - mp.take(alertItem, true); - centerEmitter.burst(1); - } - } - Attractor { - id: force - system: sys - pointX: root.width/2 - pointY: root.height/2 - strength: -10000 - enabled: false - anchors.centerIn: parent - width: parent.width/2 - height: parent.height/2 - groups:["photos"] - affectedParameter: Attractor.Position - } - Emitter { - id: centerEmitter - speed: PointDirection { x: 32; xVariation: 8;} - emitRate: 0.5 - lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first) - maximumEmitted: 20 - group: "photos" - system: sys - anchors.centerIn: parent - enabled: false - - //TODO: Zoom in effect - } - Emitter { - id: spawnFireworks - group: "fireworks" - system: sys - maximumEmitted: 400 - emitRate: 400 - lifeSpan: 2800 - x: parent.width/2 - y: parent.height/2 - 64 - width: 8 - height: 8 - enabled: false - size: 32 - endSize: 8 - speed: AngleDirection { magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 } - acceleration: PointDirection { y: 160 } - } - Item { x: -1000; y: -1000 //offscreen - Repeater {//Load them here, add to system on completed - model: theModel - delegate: theDelegate - } - } - RssModel {id: theModel; tags:"particle,particles"} - Component { - id: theDelegate - Rectangle { - id: container - border.width: 2 - property real myRand: Math.random();//'depth' - z: Math.floor(myRand * 100) - scale: (myRand + 1.0)/2; - //TODO: Darken based on 'depth' - width: 132 - height: 132 - //ItemParticle.onAttached: console.log("I'm in" + x + "," + y + ":" + opacity); - ItemParticle.onDetached: mp.take(container);//respawns - function manage() - { - if (state == "selected") { - console.log("Taking " + index); - mp.freeze(container); - } else { - console.log("Returning " +index); - mp.unfreeze(container); - } - } - Image { - id: img - anchors.centerIn: parent - smooth: true; source: "http://" + Script.getImagePath(content); cache: true - fillMode: Image.PreserveAspectFit; - width: parent.width-4; height: parent.height-4 - onStatusChanged: if (img.status == Image.Ready) { - loading.opacity = 0; - mp.take(container); - } - } - Text { - anchors.bottom: parent.bottom - width: parent.width - horizontalAlignment: Text.AlignHCenter - elide: Text.ElideRight - text: title - color: "black" - } - MouseArea { - anchors.fill: parent - onClicked: container.state == "selected" ? container.state = "" : container.state = "selected" - } - states: State { - name: "selected" - ParentChange { - target: container - parent: root - x: 0 - y: 0 - } - PropertyChanges { - target: container - width: root.width - height: root.height - z: 101 - opacity: 1 - rotation: 0 - } - } - transitions: Transition { - to: "selected" - reversible: true - SequentialAnimation { - ScriptAction {script: container.manage();} - ParallelAnimation { - ParentAnimation {NumberAnimation { properties: "x,y" }}//Doesn't work, particles takes control of x,y instantly - NumberAnimation { properties: "width, height, z, rotation" } - } - } - } - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/PlasmaPatrol.qmlproject b/examples/declarative/particles/plasmapatrol/PlasmaPatrol.qmlproject deleted file mode 100644 index 548295243d..0000000000 --- a/examples/declarative/particles/plasmapatrol/PlasmaPatrol.qmlproject +++ /dev/null @@ -1,19 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "plasmapatrol.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - Files { - paths: ["TODO"] - } -} diff --git a/examples/declarative/particles/plasmapatrol/TODO b/examples/declarative/particles/plasmapatrol/TODO deleted file mode 100644 index ef9d21a73d..0000000000 --- a/examples/declarative/particles/plasmapatrol/TODO +++ /dev/null @@ -1,10 +0,0 @@ -Realistic Tasks: -Particle explosions on ship death. -Better help text (both content and styled a little nicer). -Hardpoint help showing them firing across the screen. -Endless Demo Mode - -Nice-but-i-doubt-it-will-get-done Tasks: -Particle Text for the winner. -Particle-based buttons. -Single player mode that is challenges (known opponents) to master the game with and earn achievements (in addition to 'skirmish'). diff --git a/examples/declarative/particles/plasmapatrol/content/BlasterHardpoint.qml b/examples/declarative/particles/plasmapatrol/content/BlasterHardpoint.qml deleted file mode 100644 index 4ac30d0202..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/BlasterHardpoint.qml +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property variant target: {"y": -90, "x":12} - property Item targetObj: container - property Item hardpoint: container - property ParticleSystem system - property int blasts: 16 - property int bonusBlasts: 12 - property bool show: true - - width: 24 - height: 24 - Emitter { - id: visualization - group: "blaster" - system: container.system - enabled: show - anchors.fill: parent - shape: EllipseShape {} - speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true} - lifeSpan: 1000 - emitRate: 64 - - size: 24 - sizeVariation: 24 - endSize: 0 - } - - property int blastsLeft: 0 - function fireAt(targetArg, container) { - target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2); - targetObj = targetArg; - hardpoint = container; - blastsLeft = blasts; - rofTimer.repeat = true; - rofTimer.start(); - } - Timer { - id: rofTimer - interval: 30;//Has to be greater than 1 frame or they stack up - running: false - repeat: false - onTriggered: { - if (targetObj.hp <= 0) - return; - //TODO: calculate hit and damage at target, which must be a Ship - var hit; - if (blastsLeft >= bonusBlasts) - hit = Math.random() > targetObj.dodge; - else - hit = false; //purely aesthetic shots, because the damage isn't that fine grained - if (hit == true) { - switch (targetObj.shipType) { - case 1: hardpoint.damageDealt += 4; break; - case 2: hardpoint.damageDealt += 5; break; - case 3: hardpoint.damageDealt += 1; break; - default: hardpoint.damageDealt += 100; - } - } - blastVector.targetX = target.x; - blastVector.targetY = target.y; - if (!hit) {//TODO: Actual targetVariation - blastVector.targetX += (128 * Math.random() - 64); - blastVector.targetY += (128 * Math.random() - 64); - } - emitter.burst(1); - blastsLeft--; - if (!blastsLeft) - rofTimer.repeat = false; - } - } - Emitter { - id: emitter - group: "blaster" - enabled: false - system: container.system - anchors.centerIn: parent - - lifeSpan: 1000 - emitRate: 16 - maximumEmitted: blasts - size: 24 - endSize:16 - sizeVariation: 8 - speed: TargetDirection { - id: blastVector - targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Button.qml b/examples/declarative/particles/plasmapatrol/content/Button.qml deleted file mode 100644 index 405b99304f..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Button.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -//TODO: Add particles to this component too -Rectangle { - id: container - property alias text: txt.text - signal clicked - //color: "lightsteelblue" - gradient: Gradient { - GradientStop { position: 0.0; color: "lightsteelblue" } - GradientStop { position: 1.0; color: "steelblue" } - } - height: 64 - radius: 16 - width: 128 - Text { - id: txt - anchors.centerIn: parent - font.pixelSize: 24 - color: "white" - } - MouseArea { - anchors.fill: parent - onClicked: container.clicked() - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/CannonHardpoint.qml b/examples/declarative/particles/plasmapatrol/content/CannonHardpoint.qml deleted file mode 100644 index c4aa412760..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/CannonHardpoint.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property variant target: {"y": -90, "x":12} - property ParticleSystem system - property bool show: true - - width: 24 - height: 24 - Emitter { - id: visualization - group: "cannon" - enabled: container.show - system: container.system - anchors.centerIn: parent - lifeSpan: 2000 - emitRate: 1 - - size: 4 - endSize: 0 - } - - function fireAt(targetArg, hardpoint) { - target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2); - if (container.hp <= 0 || targetArg.hp <= 0) - return; - //TODO: calculate hit and damage at target, which must be a Ship - var hit = Math.random() > targetArg.dodge - if (hit) { - switch (targetArg.shipType) { - case 1: hardpoint.damageDealt += 8; break; - case 2: hardpoint.damageDealt += 10; break; - case 3: hardpoint.damageDealt += 16; break; - default: hardpoint.damageDealt += 1000; - } - } - emitter.burst(1); - } - Emitter { - id: emitter - group: "cannon" - enabled: false - system: container.system - anchors.centerIn: parent - - lifeSpan: 1000 - emitRate: 1 - size: 8 - endSize: 4 - speed: TargetDirection { - id: blastVector - targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/ChoiceBox.qml b/examples/declarative/particles/plasmapatrol/content/ChoiceBox.qml deleted file mode 100644 index a678bc9dd4..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/ChoiceBox.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - width: 360 - height: 160 - property ParticleSystem system - Ship { - id: nully - system: system - } - property Item target: nully - /* - Component.onCompleted: { - container.target.shipType = 1 - container.target.gunType = 1 - } - */ - Row { - anchors.horizontalCenter: parent.horizontalCenter - height: parent.height - spacing: 8 - Button { - width: 80 - height: 80 - anchors.verticalCenter: parent.verticalCenter - text: "Cycle\nShip" - onClicked: { - var nextVal = container.target.shipType; - if(nextVal == 3) - nextVal = 1; - else - nextVal++; - container.target.shipType = nextVal; - } - } - Item { - width: 128 - height: 128 - anchors.verticalCenter: parent.verticalCenter - Ship { - hp: 20 - anchors.centerIn: parent - shipType: container.target.shipType - gunType: container.target.gunType - system: container.system - } - } - Button { - width: 80 - height: 80 - anchors.verticalCenter: parent.verticalCenter - text: "Cycle\nGun" - onClicked: { - var nextVal = container.target.gunType; - if(nextVal == 3) - nextVal = 1; - else - nextVal++; - container.target.gunType = nextVal; - } - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Cruiser.qml b/examples/declarative/particles/plasmapatrol/content/Cruiser.qml deleted file mode 100644 index c689879dce..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Cruiser.qml +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property int maxHP: 100 - property int hp: maxHP - property real initialDodge: 0.01 - property real dodge: initialDodge - onHpChanged: if(hp <= 0) target = container; - property ParticleSystem system//TODO: Ship abstraction - property Item target: container - property string shipParticle: "default"//Per team colors? - property int gunType: 0 - width: 128 - height: 128 - Emitter { - //TODO: Cooler would be an 'orbiting' affector - //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles - system: container.system - group: container.shipParticle - anchors.centerIn: parent - width: 64 - height: 64 - shape: EllipseShape {} - - emitRate: hp > 0 ? hp * 1 + 20 : 0 - lifeSpan: 2400 - maximumEmitted: (maxHP * 1 + 20)*2.4 - - size: 48 - sizeVariation: 16 - endSize: 16 - - speed: AngleDirection {angleVariation:360; magnitudeVariation: 32} - } - Emitter { - system: container.system - group: "cruiserArmor" - anchors.fill: parent - shape: EllipseShape { fill: false } - enabled: hp>0 - - emitRate: 16 - lifeSpan: 2000 - - size: 48 - sizeVariation: 24 - - SpriteGoal { - id: destructor - system: container.system - enabled: container.hp <=0 - anchors.fill: parent - groups: ["cruiserArmor"] - goalState: "death" -// jump: true - once: true - } - } - - Timer { - id: fireControl - property int next: Math.floor(Math.random() * 3) + 1 - interval: 800 - running: root.readySetGo - repeat: true - onTriggered: { - if (next == 1) { - gun1.fireAt(container.target); - next = Math.floor(Math.random() * 3) + 1; - } else if (next == 2) { - gun2.fireAt(container.target); - next = Math.floor(Math.random() * 3) + 1; - } else if (next == 3) { - gun3.fireAt(container.target); - next = Math.floor(Math.random() * 3) + 1; - } - } - } - - Hardpoint {//TODO: Hardpoint abstraction - x: 112 - 12 - 8*2 - y: 128 - 12 - 12*2 - id: gun1 - system: container.system - show: hp > 0 - hardpointType: gunType - } - Hardpoint { - x: 64 - 12 - y: 0 - 12 + 12*2 - id: gun2 - system: container.system - show: hp > 0 - hardpointType: gunType - } - Hardpoint { - x: 16 - 12 + 8*2 - y: 128 - 12 - 12*2 - id: gun3 - system: container.system - show: hp > 0 - hardpointType: gunType - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Frigate.qml b/examples/declarative/particles/plasmapatrol/content/Frigate.qml deleted file mode 100644 index de099bed72..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Frigate.qml +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property int maxHP: 100 - property int hp: maxHP - property real initialDodge: 0.2 - property real dodge: initialDodge - onHpChanged: if(hp <= 0) target = container; - property ParticleSystem system//TODO: Ship abstraction - property Item target: container - property string shipParticle: "default"//Per team colors? - property int gunType: 0 - width: 128 - height: 128 - Emitter { - system: container.system - group: "frigateShield" - anchors.centerIn: parent - size: 92 - emitRate: 1 - lifeSpan: 4800 - enabled: hp > 0 - } - Emitter { - system: container.system - group: container.shipParticle - anchors.centerIn: parent - width: 64 - height: 16 - shape: EllipseShape {} - - size: 16 - sizeVariation: 8 - endSize: 8 - emitRate: hp > 0 ? hp * 1 + 20 : 0 - lifeSpan: 1200 - maximumEmitted: (maxHP * 1 + 20)*2 - } - Timer { - id: fireControl - property int next: Math.floor(Math.random() * 2) + 1 - interval: 800 - running: root.readySetGo - repeat: true - onTriggered: { - if (next == 1) { - gun1.fireAt(container.target); - next = Math.floor(Math.random() * 2) + 1; - } else if (next == 2) { - gun2.fireAt(container.target); - next = Math.floor(Math.random() * 2) + 1; - } - } - } - - Hardpoint { - x: 128 - 32 - 12 - y: 64 - 12 - id: gun1 - system: container.system - show: hp > 0 - hardpointType: gunType - } - Hardpoint { - x: 0 + 32 - 12 - y: 64 - 12 - id: gun2 - system: container.system - show: hp > 0 - hardpointType: gunType - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Hardpoint.qml b/examples/declarative/particles/plasmapatrol/content/Hardpoint.qml deleted file mode 100644 index 5c7fb5521b..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Hardpoint.qml +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - //ReflectiveProperties - //TransferredProperties - property variant target: {"y": -90, "x":12} - property ParticleSystem system - property bool show: true - property int hardpointType: 0 //default is pea shooter - always bad. - - property Item targetObj: null - property int damageDealt: 0 - onDamageDealtChanged: dealDamageTimer.start(); - Timer { - id: dealDamageTimer - interval: 16 - running: false - repeat: false - onTriggered: {targetObj.hp -= damageDealt; damageDealt = 0;} - } - width: 24 - height: 24 - function fireAt(targetArg) {//Each implement own - if (targetArg != null) { - hardpointLoader.item.fireAt(targetArg, container); - targetObj = targetArg; - } - } - Loader { - id: hardpointLoader - sourceComponent: { - switch (hardpointType) { - case 1: laserComponent; break; - case 2: blasterComponent; break; - case 3: cannonComponent; break; - default: emptyComponent; - } - } - } - Component { - id: laserComponent - LaserHardpoint { - target: container.target - system: container.system - show: container.show - } - } - Component { - id: blasterComponent - BlasterHardpoint { - target: container.target - system: container.system - show: container.show - } - } - Component { - id: cannonComponent - CannonHardpoint { - target: container.target - system: container.system - show: container.show - } - } - Component { - id: emptyComponent - Item { - function fireAt(obj) { - console.log("Firing null weapon. It hurts."); - } - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/HelpScreens.qml b/examples/declarative/particles/plasmapatrol/content/HelpScreens.qml deleted file mode 100644 index 9297f86f31..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/HelpScreens.qml +++ /dev/null @@ -1,268 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -SequentialLoader { - id: hLdr - signal exitDesired - Component.onCompleted: advance(); - ParticleSystem { id: helpSystem } - PlasmaPatrolParticles { sys: helpSystem } - pages: [ - Component {Item { - id: story - Text { - color: "white" - text: "Story" - font.pixelSize: 48 - } - /* - Flickable { - y: 60 - width: 360 - height: 500 - contentHeight: txt1.height - contentWidth: 360//TODO: Less magic numbers? - */ - Text { - id: txt1 - color: "white" - y: 60 - font.pixelSize: 18 - text: " -In a remote nebula, a race of energy beings formed and lived prosperous lives for millenia. Until the schism - when they became constantly at each other's energy-throats. War soon followed, crippling both sides, until a truce was formed. But while governments knew the desparate need for peace, the soldiers in the ion-field were still filled with rampant bloodlust. On the border, patrols are constantly engaging in minor skirmishes whenever they cross paths. - -You must select one such patrol unit for the border, heading into an inevitable skirmish, in Plasma Patrol: the game of energy being spaceship combat! - " - width: 360 - wrapMode: Text.WordWrap - } - // } - Button { - x: 20 - y: 560 - height: 40 - width: 120 - text: "Next" - onClicked: hLdr.advance(); - } - Button { - x: 220 - y: 560 - height: 40 - width: 120 - text: "Menu" - onClicked: hLdr.exitDesired(); - } - }}, - Component {Item { - id: ships - Text { - color: "white" - text: "Vessels" - font.pixelSize: 48 - } - Column { - spacing: 16 - y: 60 - Row { - height: 128 - Sloop { - system: helpSystem - } - Text { - text: "The nimble sloop" - color: "white" - font.pixelSize: 18 - } - } - Row { - height: 128 - Frigate { - system: helpSystem - } - Text { - text: "The versitile shield frigate" - color: "white" - font.pixelSize: 18 - } - } - Row { - height: 128 - Cruiser { - system: helpSystem - } - Text { - text: "The armored cruiser" - color: "white" - font.pixelSize: 18 - } - } - } - Button { - x: 20 - y: 560 - height: 40 - width: 120 - text: "Next" - onClicked: hLdr.advance(); - } - Button { - x: 220 - y: 560 - height: 40 - width: 120 - text: "Menu" - onClicked: hLdr.exitDesired(); - } - }}, - Component {Item { - id: guns - Text { - color: "white" - text: "Hardpoints" - font.pixelSize: 48 - } - Column { - spacing: 16 - y: 60 - Row { - height: 128 - LaserHardpoint { - system: helpSystem - } - Text { - text: "The laser hardpoint almost always hits the target, even the nimble sloop, but loses much of its potency against the frigate's shields" - width: 332 - wrapMode: Text.WordWrap - color: "white" - font.pixelSize: 18 - } - } - Row { - height: 128 - BlasterHardpoint { - system: helpSystem - } - Text { - text: "The blaster passes right through the frigate's shields but loses much of its impact against the armor of the cruiser" - width: 332 - wrapMode: Text.WordWrap - color: "white" - font.pixelSize: 18 - } - } - Row { - height: 128 - CannonHardpoint { - system: helpSystem - } - Text { - text: "The cannon has poor accuracy, often missing the nimble sloop, but can punch right through the armor of the cruiser" - width: 332 - wrapMode: Text.WordWrap - color: "white" - font.pixelSize: 18 - } - } - } - Button { - x: 20 - y: 560 - height: 40 - width: 120 - text: "Next" - onClicked: hLdr.advance(); - } - Button { - x: 220 - y: 560 - height: 40 - width: 120 - text: "Menu" - onClicked: hLdr.exitDesired(); - } - }}, - Component {Item { - id: strategy - Text { - color: "white" - text: "Strategy" - font.pixelSize: 48 - } - Flickable { - y: 60 - width: 360 - height: 500 - contentHeight: txt1.height - contentWidth: 360//TODO: Less magic numbers? - Text { - id: txt1 - color: "white" - font.pixelSize: 18 - text: " -Basic Strategy: Good luck, have fun - don't die. -More to come after thorough playtesting. - " - width: 360 - wrapMode: Text.WordWrap - } - } - Button { - x: 20 - y: 560 - height: 40 - width: 120 - text: "Story" - onClicked: {hLdr.at=0; hLdr.advance();} - } - Button { - x: 220 - y: 560 - height: 40 - width: 120 - text: "Menu" - onClicked: hLdr.exitDesired(); - } - }} - ] -} diff --git a/examples/declarative/particles/plasmapatrol/content/LaserHardpoint.qml b/examples/declarative/particles/plasmapatrol/content/LaserHardpoint.qml deleted file mode 100644 index 87ac3e9e62..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/LaserHardpoint.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property variant target: {"y": -90, "x":12} - property ParticleSystem system - property bool show: true - - width: 24 - height: 24 - Emitter { - id: visualization - group: "laser" - system: container.system - anchors.fill: parent - enabled: container.show - shape: EllipseShape {} - speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true } - lifeSpan: 1000 - emitRate: 64 - - size: 24 - sizeVariation: 8 - endSize: 8 - } - - function fireAt(targetArg, hardpoint) { - if (targetArg.hp <= 0) - return; - //TODO: calculate hit and damage at target, which must be a Ship - var offset = 0; - if (Math.random() < 0.99) { - switch (targetArg.shipType) { - case 1: hardpoint.damageDealt += 16; break; - case 2: hardpoint.damageDealt += 4; break; - case 3: hardpoint.damageDealt += 8; break; - default: hardpoint.damageDealt += 500; //Really effective against unregistered vessels - } - } else {//Misses with Lasers are really rare - offset = Math.random() * 100; - } - target = container.mapFromItem(targetArg, offset + targetArg.width/2, offset + targetArg.height/2); - emitter.pulse(100); - // console.log("Fire box: " + Math.min(container.width/2, target.x) + "," + Math.min(container.height/2, target.y) + " " + (Math.max(container.width/2, target.x) - Math.min(container.width/2, target.x)) + "," + (Math.max(container.height/2, target.y) - Math.min(container.height/2, target.y))); - } - Emitter { - id: emitter - group: "laser" - enabled: false - system: container.system - x: Math.min(container.width/2, target.x); - width: Math.max(container.width/2, target.x) - x; - y: Math.min(container.height/2, target.y); - height: Math.max(container.height/2, target.y) - y; - shape: LineShape { - mirrored: (emitter.y < 0 || emitter.x < 0) && !(emitter.y < 0 && emitter.x < 0 )//I just want XOR - } - - lifeSpan: 1000 - emitRate: 8000 - maximumEmitted: 800 - size: 16 - endSize: 0 - - speed: PointDirection {xVariation: 4; yVariation: 4} - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/declarative/particles/plasmapatrol/content/PlasmaPatrolParticles.qml deleted file mode 100644 index 95d4bcd2b9..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/PlasmaPatrolParticles.qml +++ /dev/null @@ -1,173 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - property ParticleSystem sys - ImageParticle { - system: sys - groups: ["default"] - source: "pics/blur-circle3.png" - color: "#003A3A3A" - colorVariation: 0.1 - z: 0 - } - ImageParticle { - system: sys - groups: ["redTeam"] - source: "pics/blur-circle3.png" - color: "#0028060A" - colorVariation: 0.1 - z: 0 - } - ImageParticle { - system: sys - groups: ["greenTeam"] - source: "pics/blur-circle3.png" - color: "#0006280A" - colorVariation: 0.1 - z: 0 - } - ImageParticle { - system: sys - groups: ["blaster"] - source: "pics/star2.png" - //color: "#0F282406" - color: "#0F484416" - colorVariation: 0.2 - z: 2 - } - ImageParticle { - system: sys - groups: ["laser"] - source: "pics/star3.png" - //color: "#00123F68" - color: "#00428FF8" - colorVariation: 0.2 - z: 2 - } - ImageParticle { - system: sys - groups: ["cannon"] - source: "pics/particle.png" - color: "#80FFAAFF" - colorVariation: 0.1 - z: 2 - } - ImageParticle { - system: sys - groups: ["cannonCore"] - source: "pics/particle.png" - color: "#00666666" - colorVariation: 0.8 - z: 1 - } - ImageParticle { - system: sys - groups: ["cannonWake"] - source: "pics/star.png" - color: "#00CCCCCC" - colorVariation: 0.2 - z: 1 - } - ImageParticle { - system: sys - groups: ["frigateShield"] - source: "pics/blur-circle2.png" - color: "#00000000" - colorVariation: 0.05 - blueVariation: 0.5 - greenVariation: 0.1 - z: 3 - } - ImageParticle { - system: sys - groups: ["cruiserArmor"] - z: 1 - sprites:[Sprite { - id: spinState - name: "spinning" - source: "pics/meteor.png" - frames: 35 - frameDuration: 40 - to: {"death":0, "spinning":1} - },Sprite { - name: "death" - source: "pics/meteor_explo.png" - frames: 22 - frameDuration: 40 - to: {"null":1} - }, Sprite { - name: "null" - source: "pics/nullRock.png" - frames: 1 - frameDuration: 1000 - } - ] - } - TrailEmitter { - system: sys - group: "cannonWake" - follow: "cannon" - emitRatePerParticle: 64 - lifeSpan: 600 - speed: AngleDirection { angleVariation: 360; magnitude: 48} - size: 16 - endSize: 8 - sizeVariation: 2 - enabled: true - width: 1000//XXX: Terrible hack - height: 1000 - } - TrailEmitter { - system: sys - group: "cannonCore" - follow: "cannon" - emitRatePerParticle: 256 - lifeSpan: 128 - size: 24 - endSize: 8 - enabled: true - width: 1000//XXX: Terrible hack - height: 1000 - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/SequentialLoader.qml b/examples/declarative/particles/plasmapatrol/content/SequentialLoader.qml deleted file mode 100644 index eaef87fe57..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/SequentialLoader.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - id: container - //TODO: Somehow get particles into this? - property list pages - property Item cur: null - property int at: 0 - function advance() { - if(cur != null) - cur.destroy(); - cur = pages[at++].createObject(container); - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Ship.qml b/examples/declarative/particles/plasmapatrol/content/Ship.qml deleted file mode 100644 index a928cd2a2e..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Ship.qml +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: me - //Reflective Properties - width: shipLoader.width - height: shipLoader.height - //Transfered Properties - property int hp: 100//shipLoader.item.maxHP - property real dodge: shipLoader.item.initialDodge - property ParticleSystem system - property int targetIdx: 0 - property Item target: targets[targetIdx] == undefined?null:targets[targetIdx] - Connections { - target: me.target - onHpChanged: if (me.target.hp<=0) me.targetIdx++; - } - property list targets - property string shipParticle: "default"//Per team colors? - property int gunType: 0 - property int shipType: 0 - Component { - id: sloopComp - Sloop { - system: me.system - target: me.target - shipParticle: me.shipParticle - gunType: me.gunType - hp: me.hp - dodge: me.dodge - } - } - Component { - id: frigateComp - Frigate { - system: me.system - target: me.target - shipParticle: me.shipParticle - gunType: me.gunType - hp: me.hp - dodge: me.dodge - } - } - Component { - id: cruiserComp - Cruiser { - system: me.system - target: me.target - shipParticle: me.shipParticle - gunType: me.gunType - hp: me.hp - dodge: me.dodge - } - } - Component { - id: dumbComp - Item { - property int maxHP: 0 - property int initialDodge: 0 - } - } - Loader { - id: shipLoader - sourceComponent: { - switch (shipType) { - case 1: sloopComp; break; - case 2: frigateComp; break; - case 3: cruiserComp; break; - default: dumbComp; - } - } - } -} diff --git a/examples/declarative/particles/plasmapatrol/content/Sloop.qml b/examples/declarative/particles/plasmapatrol/content/Sloop.qml deleted file mode 100644 index c6b1183162..0000000000 --- a/examples/declarative/particles/plasmapatrol/content/Sloop.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: container - property int maxHP: 100 - property int hp: maxHP - property real initialDodge: 0.5 - property real dodge: initialDodge - property int blinkInterval: 800 - onHpChanged: if(hp <= 0) target = container; - property ParticleSystem system//TODO: Ship abstraction - property Item target: container - property string shipParticle: "default"//Per team colors? - property int gunType: 0 - width: 128 - height: 128 - Emitter { - id: emitter - //TODO: Cooler would be an 'orbiting' affector - //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles - system: container.system - group: container.shipParticle - shape: EllipseShape {} - - emitRate: hp > 0 ? hp + 20 : 0 - lifeSpan: blinkInterval - maximumEmitted: (maxHP + 20) - - acceleration: AngleDirection {angleVariation: 360; magnitude: 8} - - size: 24 - endSize: 4 - sizeVariation: 8 - width: 16 - height: 16 - x: 64 - y: 64 - Behavior on x {NumberAnimation {duration:blinkInterval}} - Behavior on y {NumberAnimation {duration:blinkInterval}} - Timer { - interval: blinkInterval - running: true - repeat: true - onTriggered: { - emitter.x = Math.random() * 48 + 32 - emitter.y = Math.random() * 48 + 32 - } - } - } - Hardpoint { - anchors.centerIn: parent - id: gun2 - system: container.system - show: container.hp > 0 - hardpointType: gunType - } - Timer { - id: fireControl - interval: 800 - running: root.readySetGo - repeat: true - onTriggered: { - gun2.fireAt(container.target); - } - } - -} diff --git a/examples/declarative/particles/plasmapatrol/content/pics/TitleText.png b/examples/declarative/particles/plasmapatrol/content/pics/TitleText.png deleted file mode 100644 index dc3acebe39..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/TitleText.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/blur-circle2.png b/examples/declarative/particles/plasmapatrol/content/pics/blur-circle2.png deleted file mode 100644 index f7c9f3e98e..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/blur-circle2.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/blur-circle3.png b/examples/declarative/particles/plasmapatrol/content/pics/blur-circle3.png deleted file mode 100644 index dbc39cb16e..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/blur-circle3.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/finalfrontier.png b/examples/declarative/particles/plasmapatrol/content/pics/finalfrontier.png deleted file mode 100644 index 2ba1815230..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/finalfrontier.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/meteor.png b/examples/declarative/particles/plasmapatrol/content/pics/meteor.png deleted file mode 100644 index e8c368aea7..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/meteor.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/meteor_explo.png b/examples/declarative/particles/plasmapatrol/content/pics/meteor_explo.png deleted file mode 100644 index 4297245d49..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/meteor_explo.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/nullRock.png b/examples/declarative/particles/plasmapatrol/content/pics/nullRock.png deleted file mode 100644 index 4076327a1a..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/nullRock.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/particle.png b/examples/declarative/particles/plasmapatrol/content/pics/particle.png deleted file mode 100644 index 5c83896d22..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/particle.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/star.png b/examples/declarative/particles/plasmapatrol/content/pics/star.png deleted file mode 100644 index 0d592cfa87..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/star.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/star2.png b/examples/declarative/particles/plasmapatrol/content/pics/star2.png deleted file mode 100644 index bb55c44788..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/star2.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/content/pics/star3.png b/examples/declarative/particles/plasmapatrol/content/pics/star3.png deleted file mode 100644 index 636a25f480..0000000000 Binary files a/examples/declarative/particles/plasmapatrol/content/pics/star3.png and /dev/null differ diff --git a/examples/declarative/particles/plasmapatrol/plasmapatrol.qml b/examples/declarative/particles/plasmapatrol/plasmapatrol.qml deleted file mode 100644 index 45f81c7222..0000000000 --- a/examples/declarative/particles/plasmapatrol/plasmapatrol.qml +++ /dev/null @@ -1,386 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content" - -Rectangle { - id: root - property bool readySetGo: false - //Debugging - property int hits: 0 - property int misses: 0 - property real ratio: hits/(misses?misses:1) - //Move to JS file? - property Ship redVar1: Ship {shipType: 1; gunType: 1} - property Ship redVar2: Ship {shipType: 1; gunType: 2} - property Ship redVar3: Ship {shipType: 1; gunType: 3} - property Ship greenVar1: Ship {shipType: 3; gunType: 1} - property Ship greenVar2: Ship {shipType: 2; gunType: 2} - property Ship greenVar3: Ship {shipType: 1; gunType: 3} - property string winner: "0" - property int players: 0 - function aiSet(ship) { - ship.gunType = Math.floor(Math.random() * 3) + 1 - ship.shipType = Math.floor(Math.random() * 3) + 1 - } - - width: 360 - height: 600 - color: "black" - SequentialLoader { - anchors.fill: parent - //General Children - Image { - anchors.centerIn: parent - source: "../images/finalfrontier.png" - } - ParticleSystem { - id: particles - } - PlasmaPatrolParticles { sys: particles; z: 100 }//Renders all particles on the one plane - //Component parts - id: pageControl - Component.onCompleted: advance(); - pages:[ - Component {Item { - id: menu - width: root.width - height: root.height - Column { - anchors.verticalCenter: parent.verticalCenter - width: parent.width - spacing: 8 - Item { - id: title - width: root.width - height: 240 - Emitter { - anchors.fill: parent - system: particles - enabled: true - group: "default" - emitRate: 1200 - lifeSpan: 1200 - shape: MaskShape {source:"content/pics/TitleText.png"} - size: 16 - endSize: 0 - sizeVariation: 8 - speed: AngleDirection {angleVariation:360; magnitudeVariation: 6} - } - } - Button { - text: "1P" - onClicked: {root.players = 1; pageControl.advance();} - anchors.horizontalCenter: parent.horizontalCenter - } - Button { - text: "2P" - onClicked: {root.players = 2; pageControl.advance();} - anchors.horizontalCenter: parent.horizontalCenter - } - Button { - text: "Demo" - anchors.horizontalCenter: parent.horizontalCenter - onClicked: {root.players = 0; - aiSet(redVar1); - aiSet(redVar2); - aiSet(redVar3); - aiSet(greenVar1); - aiSet(greenVar2); - aiSet(greenVar3); - pageControl.at = 5;//TODO: Not a magic number - pageControl.advance();} - } - Button { - text: "Help" - anchors.horizontalCenter: parent.horizontalCenter - onClicked: { - pageControl.at = 7;//TODO: Not a magic number - pageControl.advance(); - } - } - Button { - text: "Quit" - anchors.horizontalCenter: parent.horizontalCenter - onClicked: Qt.quit(); - } - } - }}, - Component {Item { - id: p1Screen - z: 101 - width: root.width - height: root.height - Rectangle { - anchors.fill: parent - color: "red" - } - Text { - anchors.centerIn: parent - color: "white" - font.pixelSize: 64 - font.bold: true - text: "Player\n 1" - horizontalAlignment: Text.AlignHCenter - } - MouseArea { - anchors.fill: parent - onClicked: pageControl.advance() - } - }}, - Component {Item { - id: p1Choices - z: 3 - width: root.width - height: root.height - Rectangle { - color: "black" - anchors.fill: parent - } - Column { - spacing: 16 - width: root.width - anchors.horizontalCenter: parent.horizontalCenter - ChoiceBox { - target: redVar1 - system: particles - } - ChoiceBox { - target: redVar2 - system: particles - } - ChoiceBox { - target: redVar3 - system: particles - } - Button { - anchors.horizontalCenter: parent.horizontalCenter - text: "Next" - onClicked: { - if (root.players < 2) { - aiSet(greenVar1); - aiSet(greenVar2); - aiSet(greenVar3); - pageControl.at = 5;//TODO: Not a magic number - } - pageControl.advance(); - } - } - } - }}, - Component {Item { - id: p2Screen - z: 101 - width: root.width - height: root.height - Rectangle { - anchors.fill: parent - color: "green" - } - Text { - anchors.centerIn: parent - color: "white" - font.pixelSize: 64 - font.bold: true - text: "Player\n 2" - horizontalAlignment: Text.AlignHCenter - } - MouseArea { - anchors.fill: parent - onClicked: pageControl.advance() - } - }}, - Component {Item { - id: p2Choices - z: 1 - width: root.width - height: root.height - Rectangle { - color: "black" - anchors.fill: parent - } - Column { - spacing: 16 - width: root.width - anchors.horizontalCenter: parent.horizontalCenter - ChoiceBox { - target: greenVar1 - system: particles - } - ChoiceBox { - target: greenVar2 - system: particles - } - ChoiceBox { - target: greenVar3 - system: particles - } - Button { - anchors.horizontalCenter: parent.horizontalCenter - text: "Next" - onClicked: pageControl.advance() - } - } - }}, - Component {Item { - id: arena - width: root.width - height: root.height - z: 0 - Component.onCompleted: root.readySetGo = true - Component.onDestruction: root.readySetGo = false - property bool victory: redShip3.hp <= 0 || greenShip3.hp <=0 - onVictoryChanged: { - if (redShip3.hp <= 0) { - if (greenShip3.hp <= 0) { - root.winner = "1&2" - }else { - root.winner = "2" - } - } else { - root.winner = "1" - } - winTimer.start() - } - Timer { - id: winTimer - interval: 1200 - repeat: false - running: false - onTriggered: pageControl.advance(); - } - Ship { - id: redShip1 - shipParticle: "redTeam" - system: particles - x: 180-64 - y: 128 - shipType: redVar1.shipType - gunType: redVar1.gunType - targets: [greenShip1, greenShip2, greenShip3] - } - Ship { - id: redShip2 - shipParticle: "redTeam" - system: particles - x: 0 - y: 0 - shipType: redVar2.shipType - gunType: redVar2.gunType - targets: [greenShip1, greenShip2, greenShip3] - } - Ship { - id: redShip3 - shipParticle: "redTeam" - system: particles - x: 360-128 - y: 0 - shipType: redVar3.shipType - gunType: redVar3.gunType - targets: [greenShip1, greenShip2, greenShip3] - } - - Ship { - id: greenShip1 - shipParticle: "greenTeam" - system: particles - x: 180-64 - y: 600 - 128 - 128 - shipType: greenVar1.shipType - gunType: greenVar1.gunType - targets: [redShip1, redShip2, redShip3] - } - Ship { - id: greenShip2 - shipParticle: "greenTeam" - system: particles - x: 0 - y: 600-128 - shipType: greenVar2.shipType - gunType: greenVar2.gunType - targets: [redShip1, redShip2, redShip3] - } - Ship { - id: greenShip3 - shipParticle: "greenTeam" - system: particles - x: 360 - 128 - y: 600 - 128 - shipType: greenVar3.shipType - gunType: greenVar3.gunType - targets: [redShip1, redShip2, redShip3] - } - }}, - Component {Item { - id: winScreen - z: 101 - width: root.width - height: root.height - /* - Rectangle { - anchors.fill: parent - color: "black" - } - */ - Text {//TODO: Particle Text? - anchors.fill: parent - color: "white" - font.pixelSize: 64 - font.bold: true - text: "Player " + root.winner + " wins!" - wrapMode: Text.WordWrap - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - MouseArea { - anchors.fill: parent - onClicked: {pageControl.at = 0; pageControl.advance();} - } - }}, - Component { - HelpScreens { - onExitDesired: {pageControl.at = 0; pageControl.advance();} - } - } - ] - } -} diff --git a/examples/declarative/particles/simple/dynamiccomparison.qml b/examples/declarative/particles/simple/dynamiccomparison.qml deleted file mode 100644 index a7cdb9b32a..0000000000 --- a/examples/declarative/particles/simple/dynamiccomparison.qml +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root - color: "black" - width: 640 - height: 480 - ParticleSystem { - id: sys - } - - ImageParticle { - system: sys - source: "../images/particle.png" - color: "white" - colorVariation: 1.0 - alpha: 0.1 - entryEffect: ImageParticle.None - } - - Emitter { - id: emitter - system: sys - width: parent.width/2 - speed: PointDirection {y: 72; yVariation: 24} - lifeSpan: 10000 - emitRate: 1000 - enabled: false - size: 32 - } - - Item { - id: fakeEmitter - function burst(number) { - while (number > 0) { - var item = fakeParticle.createObject(root); - item.lifeSpan = Math.random() * 5000 + 5000; - item.x = Math.random() * 320 + 320; - item.y = 0; - number--; - } - } - - Component { - id: fakeParticle - Image { - id: container - property int lifeSpan: 10000 - width: 32 - height: 32 - source: "../images/particle.png" - y: 0 - PropertyAnimation on y {from: -16; to: 480-16; duration: container.lifeSpan; running: true} - SequentialAnimation on opacity { - running: true - NumberAnimation { from:0; to: 1; duration: 500} - PauseAnimation { duration: container.lifeSpan - 1000} - NumberAnimation { from:1; to: 0; duration: 500} - ScriptAction { script: container.destroy(); } - } - } - } - } - - Text { - anchors.left: parent.left - anchors.bottom: parent.bottom - text: "1000 particles" - color: "white" - MouseArea { - anchors.fill: parent - onClicked: emitter.burst(1000); - } - } - Text { - anchors.right: parent.right - anchors.bottom: parent.bottom - text: "1000 items" - color: "white" - MouseArea { - anchors.fill: parent - onClicked: fakeEmitter.burst(1000); - } - } -} diff --git a/examples/declarative/particles/simple/dynamicemitters.qml b/examples/declarative/particles/simple/dynamicemitters.qml deleted file mode 100644 index 4431ebe82e..0000000000 --- a/examples/declarative/particles/simple/dynamicemitters.qml +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root - color: "black" - width: 640 - height: 480 - ParticleSystem { - id: sys - } - ImageParticle { - system: sys - source: "../images/particle.png" - color: "white" - colorVariation: 1.0 - alpha: 0.1 - } - - Component { - id: emitterComp - Emitter { - id: container - Emitter { - id: emitMore - system: sys - emitRate: 128 - lifeSpan: 600 - size: 16 - endSize: 8 - speed: AngleDirection {angleVariation:360; magnitude: 60} - } - - property int life: 2600 - property real targetX: 0 - property real targetY: 0 - function go() { - xAnim.start(); - yAnim.start(); - container.enabled = true - } - system: sys - emitRate: 32 - lifeSpan: 600 - size: 24 - endSize: 8 - NumberAnimation on x { - id: xAnim; - to: targetX - duration: life - running: false - } - NumberAnimation on y { - id: yAnim; - to: targetY - duration: life - running: false - } - Timer { - interval: life - running: true - onTriggered: container.destroy(); - } - } - } - - MouseArea { - anchors.fill: parent - onClicked: { - for (var i=0; i<8; i++) { - var obj = emitterComp.createObject(root); - obj.x = mouse.x - obj.y = mouse.y - obj.targetX = Math.random() * 240 - 120 + obj.x - obj.targetY = Math.random() * 240 - 120 + obj.y - obj.life = Math.round(Math.random() * 2400) + 200 - obj.emitRate = Math.round(Math.random() * 32) + 32 - obj.go(); - } - } - } -} diff --git a/examples/declarative/particles/simple/multiplepainters.qml b/examples/declarative/particles/simple/multiplepainters.qml deleted file mode 100644 index c1b85caa2d..0000000000 --- a/examples/declarative/particles/simple/multiplepainters.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - id: root - width: 360 - height: 600 - color: "darkblue" - property bool cloneMode: false - ParticleSystem { - id: sys - } - MouseArea { - anchors.fill: parent - onClicked: cloneMode = !cloneMode; - } - Emitter { - system: sys - y:root.height + 20 - width: root.width - emitRate: 200 - lifeSpan: 4000 - startTime: 4000 - speed: PointDirection { y: -120; } - } - - ImageParticle { - system: sys - visible: !cloneMode - source: "../images/particle2.png" - } - - ImageParticle { - system: sys - visible: cloneMode - z: 0 - source: "../images/particle3.png" - } - - ImageParticle { - system: sys - clip: true - visible: cloneMode - y: 120 - height: 240 - width: root.width - z: 1 - source: "../images/particle.png" - } -} diff --git a/examples/declarative/particles/simple/startstop.qml b/examples/declarative/particles/simple/startstop.qml deleted file mode 100644 index 62105b28a0..0000000000 --- a/examples/declarative/particles/simple/startstop.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 540 - color: "black" - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - if (mouse.button == Qt.LeftButton) - particles.running = !particles.running - else - particles.paused = !particles.paused; - } - } - - ParticleSystem { - id: particles - running: false - } - - ImageParticle { - anchors.fill: parent - system: particles - source: "../images/star.png" - sizeTable: "../images/sparkleSize.png" - alpha: 0 - colorVariation: 0.6 - } - - Emitter { - anchors.fill: parent - system: particles - emitRate: 2000 - lifeSpan: 2000 - size: 30 - sizeVariation: 10 - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml deleted file mode 100644 index f183c4b2a0..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -Component { - id: albumDelegate - Package { - - Item { - Package.name: 'browser' - GridView { - id: photosGridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height - 21 - x: 0; y: 21; cellWidth: 160; cellHeight: 153; interactive: false - onCurrentIndexChanged: photosListView.positionViewAtIndex(currentIndex, ListView.Contain) - } - } - - Item { - Package.name: 'fullscreen' - ListView { - id: photosListView; model: visualModel.parts.list; orientation: Qt.Horizontal - width: mainWindow.width; height: mainWindow.height; interactive: false - onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain) - highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem - } - } - - Item { - Package.name: 'album' - id: albumWrapper; width: 210; height: 220 - - VisualDataModel { - id: visualModel; delegate: PhotoDelegate { } - model: RssModel { id: rssModel; tags: tag } - } - - BusyIndicator { - id: busyIndicator - anchors { centerIn: parent; verticalCenterOffset: -20 } - on: rssModel.status != XmlListModel.Ready - } - - PathView { - id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5 - visible: !busyIndicator.visible - anchors.centerIn: parent; anchors.verticalCenterOffset: -30 - path: Path { - PathAttribute { name: 'z'; value: 9999.0 } - PathLine { x: 1; y: 1 } - PathAttribute { name: 'z'; value: 0.0 } - } - } - - MouseArea { - anchors.fill: parent - onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid' - } - - Tag { - anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 } - frontLabel: tag; backLabel: qsTr("Remove"); flipped: mainWindow.editMode - onTagChanged: rssModel.tags = tag - onBackClicked: if (mainWindow.editMode) photosModel.remove(index); - } - - states: [ - State { - name: 'inGrid' - PropertyChanges { target: photosGridView; interactive: true } - PropertyChanges { target: albumsShade; opacity: 1 } - PropertyChanges { target: backButton; onClicked: albumWrapper.state = ''; y: 6 } - }, - State { - name: 'fullscreen'; extend: 'inGrid' - PropertyChanges { target: photosGridView; interactive: false } - PropertyChanges { target: photosListView; interactive: true } - PropertyChanges { target: photosShade; opacity: 1 } - PropertyChanges { target: backButton; y: -backButton.height - 8 } - } - ] - - GridView.onAdd: NumberAnimation { - target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: Easing.OutQuad - } - GridView.onRemove: SequentialAnimation { - PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true } - NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuad } - PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false } - } - - transitions: [ - Transition { - from: '*'; to: 'inGrid' - SequentialAnimation { - NumberAnimation { properties: 'opacity'; duration: 250 } - PauseAnimation { duration: 350 } - NumberAnimation { target: backButton; properties: "y"; duration: 200; easing.type: Easing.OutQuad } - } - }, - Transition { - from: 'inGrid'; to: '*' - NumberAnimation { properties: "y,opacity"; easing.type: Easing.OutQuad; duration: 300 } - } - ] - } - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml deleted file mode 100644 index 2b1a75f369..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/BusyIndicator.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: container - property bool on: false - - source: "images/busy.png"; visible: container.on - NumberAnimation on rotation { running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/Button.qml b/examples/declarative/photoviewer/PhotoViewerCore/Button.qml deleted file mode 100644 index fcce969fbd..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/Button.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property alias label: labelText.text - property color tint: "transparent" - signal clicked - - width: labelText.width + 70 ; height: labelText.height + 18 - - BorderImage { - anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } - source: 'images/box-shadow.png'; smooth: true - border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 - } - - Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true } - - Rectangle { - anchors.fill: container; color: container.tint; visible: container.tint != "" - opacity: 0.25; smooth: true - } - - Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent; smooth: true } - - MouseArea { - anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } - onClicked: container.clicked() - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml deleted file mode 100644 index 5d845938c7..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/EditableButton.qml +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property string label - signal clicked - signal labelChanged(string label) - - width: textInput.width + 70 ; height: textInput.height + 18 - - BorderImage { - anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } - source: 'images/box-shadow.png'; smooth: true - border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 - } - - Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true } - - TextInput { - id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true - Keys.onReturnPressed: { - container.labelChanged(textInput.text) - container.focus = true - } - Keys.onEnterPressed: { - container.labelChanged(textInput.text) - container.focus = true - } - Keys.onEscapePressed: { - textInput.text = container.label - container.focus = true - } - } - - Rectangle { - anchors.fill: container; border.color: "steelblue"; border.width: 4 - color: "transparent"; visible: textInput.focus; smooth: true - } - - MouseArea { - anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } - onClicked: { textInput.forceActiveFocus(); textInput.openSoftwareInputPanel(); } - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml deleted file mode 100644 index b972c938eb..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/PhotoDelegate.qml +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "script/script.js" as Script - -Package { - Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z } - Item { id: listItem; Package.name: 'list'; width: mainWindow.width + 40; height: 153 } - Item { id: gridItem; Package.name: 'grid'; width: 160; height: 153 } - - Item { - width: 160; height: 153 - - Item { - id: photoWrapper - - property double randomAngle: Math.random() * (2 * 6 + 1) - 6 - property double randomAngle2: Math.random() * (2 * 6 + 1) - 6 - - x: 0; y: 0; width: 140; height: 133 - z: stackItem.PathView.z; rotation: photoWrapper.randomAngle - - BorderImage { - anchors { - fill: originalImage.status == Image.Ready ? border : placeHolder - leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 - } - source: 'images/box-shadow.png'; smooth: true - border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 - } - Rectangle { - id: placeHolder - - property int w: Script.getWidth(content) - property int h: Script.getHeight(content) - property double s: Script.calculateScale(w, h, photoWrapper.width) - - color: 'white'; anchors.centerIn: parent; smooth: true - width: w * s; height: h * s; visible: originalImage.status != Image.Ready - Rectangle { - color: "#878787"; smooth: true - anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 3; rightMargin: 3 } - } - } - Rectangle { - id: border; color: 'white'; anchors.centerIn: parent; smooth: true - width: originalImage.paintedWidth + 6; height: originalImage.paintedHeight + 6 - visible: !placeHolder.visible - } - BusyIndicator { anchors.centerIn: parent; on: originalImage.status != Image.Ready } - Image { - id: originalImage; smooth: true; source: "http://" + Script.getImagePath(content); cache: false - fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height - } - Image { - id: hqImage; smooth: true; source: ""; visible: false; cache: false - fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height - } - Binding { - target: mainWindow; property: "downloadProgress"; value: hqImage.progress - when: listItem.ListView.isCurrentItem - } - Binding { - target: mainWindow; property: "imageLoading" - value: (hqImage.status == Image.Loading) ? 1 : 0; when: listItem.ListView.isCurrentItem - } - MouseArea { - width: originalImage.paintedWidth; height: originalImage.paintedHeight; anchors.centerIn: originalImage - onClicked: { - if (albumWrapper.state == 'inGrid') { - gridItem.GridView.view.currentIndex = index; - albumWrapper.state = 'fullscreen' - } else { - gridItem.GridView.view.currentIndex = index; - albumWrapper.state = 'inGrid' - } - } - } - - states: [ - State { - name: 'stacked'; when: albumWrapper.state == '' - ParentChange { target: photoWrapper; parent: stackItem; x: 10; y: 10 } - PropertyChanges { target: photoWrapper; opacity: stackItem.PathView.onPath ? 1.0 : 0.0 } - }, - State { - name: 'inGrid'; when: albumWrapper.state == 'inGrid' - ParentChange { target: photoWrapper; parent: gridItem; x: 10; y: 10; rotation: photoWrapper.randomAngle2 } - }, - State { - name: 'fullscreen'; when: albumWrapper.state == 'fullscreen' - ParentChange { - target: photoWrapper; parent: listItem; x: 0; y: 0; rotation: 0 - width: mainWindow.width; height: mainWindow.height - } - PropertyChanges { target: border; opacity: 0 } - PropertyChanges { target: hqImage; source: listItem.ListView.isCurrentItem ? hq : ""; visible: true } - } - ] - - transitions: [ - Transition { - from: 'stacked'; to: 'inGrid' - SequentialAnimation { - PauseAnimation { duration: 10 * index } - ParentAnimation { - target: photoWrapper; via: foreground - NumberAnimation { - target: photoWrapper; properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' - } - } - } - }, - Transition { - from: 'inGrid'; to: 'stacked' - ParentAnimation { - target: photoWrapper; via: foreground - NumberAnimation { properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' } - } - }, - Transition { - from: 'inGrid'; to: 'fullscreen' - SequentialAnimation { - PauseAnimation { duration: gridItem.GridView.isCurrentItem ? 0 : 600 } - ParentAnimation { - target: photoWrapper; via: foreground - NumberAnimation { - targets: [ photoWrapper, border ] - properties: 'x,y,width,height,opacity,rotation' - duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart' - } - } - } - }, - Transition { - from: 'fullscreen'; to: 'inGrid' - ParentAnimation { - target: photoWrapper; via: foreground - NumberAnimation { - targets: [ photoWrapper, border ] - properties: 'x,y,width,height,rotation,opacity' - duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart' - } - } - } - ] - } - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml b/examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml deleted file mode 100644 index 43c936e342..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/ProgressBar.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property real progress: 0 - - Behavior on opacity { NumberAnimation { duration: 600 } } - - Rectangle { anchors.fill: parent; color: "black"; opacity: 0.5 } - - Rectangle { - id: fill; color: "white"; height: container.height - width: container.width * container.progress - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml b/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml deleted file mode 100644 index ab818924ac..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -XmlListModel { - property string tags : "" - - function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } - - source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "") - query: "/feed/entry" - namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" - - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "content"; query: "content/string()" } - XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/Tag.qml b/examples/declarative/photoviewer/PhotoViewerCore/Tag.qml deleted file mode 100644 index 2b546a3ac6..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/Tag.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Flipable { - id: flipable - - property alias frontLabel: frontButton.label - property alias backLabel: backButton.label - - property int angle: 0 - property int randomAngle: Math.random() * (2 * 6 + 1) - 6 - property bool flipped: false - - signal frontClicked - signal backClicked - signal tagChanged(string tag) - - front: EditableButton { - id: frontButton; rotation: flipable.randomAngle - anchors { centerIn: parent; verticalCenterOffset: -20 } - onClicked: flipable.frontClicked() - onLabelChanged: flipable.tagChanged(label) - } - - back: Button { - id: backButton; tint: "red"; rotation: flipable.randomAngle - anchors { centerIn: parent; verticalCenterOffset: -20 } - onClicked: flipable.backClicked() - } - - transform: Rotation { - origin.x: flipable.width / 2; origin.y: flipable.height / 2 - axis.x: 0; axis.y: 1; axis.z: 0 - angle: flipable.angle - } - - states: State { - name: "back"; when: flipable.flipped - PropertyChanges { target: flipable; angle: 180 } - } - - transitions: Transition { - ParallelAnimation { - NumberAnimation { properties: "angle"; duration: 400 } - SequentialAnimation { - NumberAnimation { target: flipable; property: "scale"; to: 0.8; duration: 200 } - NumberAnimation { target: flipable; property: "scale"; to: 1.0; duration: 200 } - } - } - } -} diff --git a/examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png b/examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png deleted file mode 100644 index 431af8545d..0000000000 Binary files a/examples/declarative/photoviewer/PhotoViewerCore/images/box-shadow.png and /dev/null differ diff --git a/examples/declarative/photoviewer/PhotoViewerCore/images/busy.png b/examples/declarative/photoviewer/PhotoViewerCore/images/busy.png deleted file mode 100644 index 664c2b1491..0000000000 Binary files a/examples/declarative/photoviewer/PhotoViewerCore/images/busy.png and /dev/null differ diff --git a/examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.png b/examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.png deleted file mode 100644 index 1847ab528d..0000000000 Binary files a/examples/declarative/photoviewer/PhotoViewerCore/images/cardboard.png and /dev/null differ diff --git a/examples/declarative/photoviewer/PhotoViewerCore/qmldir b/examples/declarative/photoviewer/PhotoViewerCore/qmldir deleted file mode 100644 index d3c247f21a..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/qmldir +++ /dev/null @@ -1,8 +0,0 @@ -AlbumDelegate AlbumDelegate.qml -PhotoDelegate PhotoDelegate.qml -ProgressBar ProgressBar.qml -RssModel RssModel.qml -BusyIndicator BusyIndicator.qml -EditableButton EditableButton.qml -Button Button.qml -Tag Tag.qml diff --git a/examples/declarative/photoviewer/PhotoViewerCore/script/script.js b/examples/declarative/photoviewer/PhotoViewerCore/script/script.js deleted file mode 100644 index e8ef93a847..0000000000 --- a/examples/declarative/photoviewer/PhotoViewerCore/script/script.js +++ /dev/null @@ -1,27 +0,0 @@ -.pragma library - -function getWidth(string) { - return (string.match(/width=\"([0-9]+)\"/))[1] -} - -function getHeight(string) { - return (string.match(/height=\"([0-9]+)\"/))[1] -} - -function getImagePath(string) { - var pattern = /src=\"http:\/\/(\S+)\"/ - return (string.match(pattern))[1] -} - -function calculateScale(width, height, cellSize) { - var widthScale = (cellSize * 1.0) / width - var heightScale = (cellSize * 1.0) / height - var scale = 0 - - if (widthScale <= heightScale) { - scale = widthScale; - } else if (heightScale < widthScale) { - scale = heightScale; - } - return scale; -} diff --git a/examples/declarative/photoviewer/i18n/base.ts b/examples/declarative/photoviewer/i18n/base.ts deleted file mode 100644 index 1accfd2f90..0000000000 --- a/examples/declarative/photoviewer/i18n/base.ts +++ /dev/null @@ -1,30 +0,0 @@ - - - - - AlbumDelegate - - - Remove - - - - - photoviewer - - - Add - - - - - Edit - - - - - Back - - - - diff --git a/examples/declarative/photoviewer/i18n/qml_fr.qm b/examples/declarative/photoviewer/i18n/qml_fr.qm deleted file mode 100644 index c24fcbc46c..0000000000 Binary files a/examples/declarative/photoviewer/i18n/qml_fr.qm and /dev/null differ diff --git a/examples/declarative/photoviewer/i18n/qml_fr.ts b/examples/declarative/photoviewer/i18n/qml_fr.ts deleted file mode 100644 index 9f892db616..0000000000 --- a/examples/declarative/photoviewer/i18n/qml_fr.ts +++ /dev/null @@ -1,30 +0,0 @@ - - - - - AlbumDelegate - - - Remove - Supprimer - - - - photoviewer - - - Add - Ajouter - - - - Edit - Éditer - - - - Back - Retour - - - diff --git a/examples/declarative/photoviewer/photoviewer.qml b/examples/declarative/photoviewer/photoviewer.qml deleted file mode 100644 index 918438832b..0000000000 --- a/examples/declarative/photoviewer/photoviewer.qml +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "PhotoViewerCore" - -Rectangle { - id: mainWindow - - property real downloadProgress: 0 - property bool imageLoading: false - property bool editMode: false - - width: 800; height: 480; color: "#d5d6d8" - - ListModel { - id: photosModel - ListElement { tag: "Flowers" } - ListElement { tag: "Wildlife" } - ListElement { tag: "Prague" } - } - - VisualDataModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} } - - GridView { - id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220 - model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0 - } - - Column { - spacing: 20; anchors { bottom: parent.bottom; right: parent.right; rightMargin: 20; bottomMargin: 20 } - Button { - id: newButton; label: qsTr("Add"); rotation: 3 - anchors.horizontalCenter: parent.horizontalCenter - onClicked: { - mainWindow.editMode = false - photosModel.append( { tag: "" } ) - albumView.positionViewAtIndex(albumView.count - 1, GridView.Contain) - } - } - Button { - id: deleteButton; label: qsTr("Edit"); rotation: -2; - onClicked: mainWindow.editMode = !mainWindow.editMode - anchors.horizontalCenter: parent.horizontalCenter - } - Button { - id: quitButton; label: qsTr("Quit"); rotation: -2; - onClicked: Qt.quit() - anchors.horizontalCenter: parent.horizontalCenter - } - } - - Rectangle { - id: albumsShade; color: mainWindow.color - width: parent.width; height: parent.height; opacity: 0.0 - } - - ListView { anchors.fill: parent; model: albumVisualModel.parts.browser; interactive: false } - - Button { id: backButton; label: qsTr("Back"); rotation: 3; x: parent.width - backButton.width - 6; y: -backButton.height - 8 } - - Rectangle { id: photosShade; color: 'black'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 } - - ListView { anchors.fill: parent; model: albumVisualModel.parts.fullscreen; interactive: false } - - Item { id: foreground; anchors.fill: parent } - - ProgressBar { - progress: mainWindow.downloadProgress; width: parent.width; height: 4 - anchors.bottom: parent.bottom; opacity: mainWindow.imageLoading; visible: opacity != 0.0 - } -} diff --git a/examples/declarative/photoviewer/photoviewer.qmlproject b/examples/declarative/photoviewer/photoviewer.qmlproject deleted file mode 100644 index 600bdb10f4..0000000000 --- a/examples/declarative/photoviewer/photoviewer.qmlproject +++ /dev/null @@ -1,20 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "photoviewer.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - Files { - filter: "*.ts" - directory: "i18n" - } -} diff --git a/examples/declarative/positioners/content/Button.qml b/examples/declarative/positioners/content/Button.qml deleted file mode 100644 index ee3aa9057e..0000000000 --- a/examples/declarative/positioners/content/Button.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - - property string text - property string icon - signal clicked - - border.color: "black"; color: "steelblue"; radius: 5 - width: pix.width + textelement.width + 13 - height: pix.height + 10 - - Image { id: pix; x: 5; y:5; source: parent.icon } - - Text { - id: textelement - text: page.text; color: "white" - x: pix.width + pix.x + 3 - anchors.verticalCenter: pix.verticalCenter - } - - MouseArea { - id: mr - anchors.fill: parent - onClicked: { parent.focus = true; page.clicked() } - } - - states: State { - name: "pressed"; when: mr.pressed - PropertyChanges { target: textelement; x: 5 } - PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 } - } - - transitions: Transition { - NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 } - } -} diff --git a/examples/declarative/positioners/content/add.png b/examples/declarative/positioners/content/add.png deleted file mode 100644 index 1ee45423e3..0000000000 Binary files a/examples/declarative/positioners/content/add.png and /dev/null differ diff --git a/examples/declarative/positioners/content/del.png b/examples/declarative/positioners/content/del.png deleted file mode 100644 index 8d2eaed523..0000000000 Binary files a/examples/declarative/positioners/content/del.png and /dev/null differ diff --git a/examples/declarative/positioners/positioners-attachedproperties.qml b/examples/declarative/positioners/positioners-attachedproperties.qml deleted file mode 100644 index a05927f5ea..0000000000 --- a/examples/declarative/positioners/positioners-attachedproperties.qml +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 400 - height: 100 - - // Create row with four rectangles, the fourth one is hidden - Row { - id: row - - Rectangle { - id: red - color: "red" - width: 100 - height: 100 - - // When mouse is clicked, display the values of the positioner - MouseArea { - anchors.fill: parent - onClicked: row.showInfo(red.Positioner) - } - } - - Rectangle { - id: green - color: "green" - width: 100 - height: 100 - - // When mouse is clicked, display the values of the positioner - MouseArea { - anchors.fill: parent - onClicked: row.showInfo(green.Positioner) - } - } - - Rectangle { - id: blue - color: "blue" - width: 100 - height: 100 - - // When mouse is clicked, display the values of the positioner - MouseArea { - anchors.fill: parent - onClicked: row.showInfo(blue.Positioner) - } - } - - // This rectangle is not visible, so it doesn't have a positioner value - Rectangle { - color: "black" - width: 100 - height: 100 - visible: false - } - - // Print the index of the child item in the positioner and convenience - // properties showing if it's the first or last item. - function showInfo(positioner) { - console.log("Item Index = " + positioner.index) - console.log(" isFirstItem = " + positioner.isFirstItem) - console.log(" isLastItem = " + positioner.isLastItem) - } - } -} diff --git a/examples/declarative/positioners/positioners.qml b/examples/declarative/positioners/positioners.qml deleted file mode 100644 index d9d16649ff..0000000000 --- a/examples/declarative/positioners/positioners.qml +++ /dev/null @@ -1,264 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: page - width: 420; height: 420 - - Column { - id: layout1 - y: 0 - move: Transition { - NumberAnimation { properties: "y"; easing.type: Easing.OutBounce } - } - add: Transition { - NumberAnimation { properties: "y"; easing.type: Easing.OutQuad } - } - - Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueV1 - visible: opacity != 0 - width: 100; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueV2 - visible: opacity != 0 - width: 100; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } - } - - Row { - id: layout2 - y: 300 - move: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.OutBounce } - } - add: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.OutQuad } - } - - Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } - - Rectangle { - id: blueH1 - visible: opacity != 0 - width: 50; height: 100 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } - - Rectangle { - id: blueH2 - visible: opacity != 0 - width: 50; height: 100 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } - } - - Button { - x: 135; y: 90 - text: "Remove" - icon: "del.png" - - onClicked: { - blueH2.opacity = 0 - blueH1.opacity = 0 - blueV1.opacity = 0 - blueV2.opacity = 0 - blueG1.opacity = 0 - blueG2.opacity = 0 - blueG3.opacity = 0 - blueF1.opacity = 0 - blueF2.opacity = 0 - blueF3.opacity = 0 - } - } - - Button { - x: 145; y: 140 - text: "Add" - icon: "add.png" - - onClicked: { - blueH2.opacity = 1 - blueH1.opacity = 1 - blueV1.opacity = 1 - blueV2.opacity = 1 - blueG1.opacity = 1 - blueG2.opacity = 1 - blueG3.opacity = 1 - blueF1.opacity = 1 - blueF2.opacity = 1 - blueF3.opacity = 1 - } - } - - Grid { - x: 260; y: 0 - columns: 3 - - move: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - add: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG1 - visible: opacity != 0 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG2 - visible: opacity != 0 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG3 - visible: opacity != 0 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - } - - Flow { - id: layout4 - x: 260; y: 250; width: 150 - - move: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - add: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF1 - visible: opacity != 0 - width: 60; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF2 - visible: opacity != 0 - width: 60; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF3 - visible: opacity != 0 - width: 40; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 } - } - -} diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml b/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml deleted file mode 100644 index 0c65647d5b..0000000000 --- a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qml +++ /dev/null @@ -1,246 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - property bool mirror - property int direction: Qt.application.layoutDirection - LayoutMirroring.enabled: mirror - LayoutMirroring.childrenInherit: true - width: column.width + 80 - height: column.height + 40 - Column { - id: column - width: 190 - spacing: 10 - anchors.centerIn: parent - - Text { - text: "Row" - anchors.horizontalCenter: parent.horizontalCenter - } - - Row { - layoutDirection: root.direction - spacing: 10 - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 4 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "Grid" - anchors.horizontalCenter: parent.horizontalCenter - } - - Grid { - layoutDirection: root.direction - spacing: 10; columns: 4 - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 11 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "Flow" - anchors.horizontalCenter: parent.horizontalCenter - } - - Flow { - layoutDirection: root.direction - spacing: 10; width: parent.width - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 10 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "ListView" - anchors.horizontalCenter: parent.horizontalCenter - } - - ListView { - id: listView - clip: true - width: parent.width; height: 40 - layoutDirection: root.direction - orientation: Qt.Horizontal - model: 48 - delegate: viewDelegate - } - - Text { - text: "GridView" - anchors.horizontalCenter: parent.horizontalCenter - } - - GridView { - clip: true - width: 200; height: 160 - cellWidth: 50; cellHeight: 50 - layoutDirection: root.direction - model: 48 - delegate: viewDelegate - } - - Rectangle { - height: 50; width: parent.width - color: mouseArea.pressed ? "black" : "gray" - Column { - anchors.centerIn: parent - Text { - text: root.direction ? "Right to left" : "Left to right" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - if (root.direction == Qt.LeftToRight) { - root.direction = Qt.RightToLeft; - } else { - root.direction = Qt.LeftToRight; - } - } - } - } - - Rectangle { - height: 50; width: parent.width - color: mouseArea2.pressed ? "black" : "gray" - Column { - anchors.centerIn: parent - Text { - text: root.mirror ? "Mirrored" : "Not mirrored" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea2 - anchors.fill: parent - onClicked: { - root.mirror = !root.mirror; - } - } - } - } - - Component { - id: positionerDelegate - Rectangle { - width: 40; height: 40 - color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0) - Text { - text: parent.parent.value+1 - color: "white" - font.pixelSize: 18 - anchors.centerIn: parent - } - } - } - Component { - id: viewDelegate - Item { - width: (listView.effectiveLayoutDirection == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50 - Rectangle { - width: 40; height: 40 - color: Qt.rgba(0.5+(48 - index)*Math.random()/48, - 0.3+index*Math.random()/48, - 0.3*Math.random(), - 1.0) - Text { - text: index+1 - color: "white" - font.pixelSize: 18 - anchors.centerIn: parent - } - } - } - } -} - diff --git a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject b/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject deleted file mode 100644 index 33cbb3c9e2..0000000000 --- a/examples/declarative/righttoleft/layoutdirection/layoutdirection.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "layoutdirection.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml deleted file mode 100644 index 5c4739bd57..0000000000 --- a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qml +++ /dev/null @@ -1,313 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft - LayoutMirroring.enabled: mirror - LayoutMirroring.childrenInherit: true - width: 400 - height: 875 - color: "lightsteelblue" - - Column { - spacing: 10 - anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 } - - Text { - text: "Positioners" - anchors.left: parent.left - } - - Column { - id: positioners - spacing: 5 - anchors.left: parent.left - Row { - id: row - spacing: 4 - property string text: "THISISROW" - anchors.left: parent.left - Repeater { - model: parent.text.length - delegate: positionerDelegate - } - } - Flow { - id: flow - spacing: 4 - width: 90 - property string text: "THISISFLOW" - anchors.left: parent.left - Repeater { - model: parent.text.length - delegate: positionerDelegate - } - } - Grid { - id: grid - spacing: 4 - columns: 6 - property string text: "THISISGRID" - anchors.left: parent.left - Repeater { - model: parent.text.length - delegate: positionerDelegate - } - } - Component { - id: positionerDelegate - Text { - color: "white" - font.pixelSize: 20 - text: parent.text[index] - Rectangle { - z: -1 - opacity: 0.7 - color: "black" - anchors.fill: parent - } - } - } - } - - Text { - text: "Text alignment" - anchors.left: parent.left - } - - Rectangle { - id: textStrings - width: 148 - height: 85 - color: "white" - anchors.left: parent.left - Column { - spacing: 5 - width: parent.width - anchors { fill: parent; margins: 5 } - Text { - id: englishText - width: parent.width - text: "English text" - } - Text { - id: arabicText - width: parent.width - text: "النص العربي" - } - Text { - id: leftAlignedText - width: parent.width - text: "Text aligned to left" - horizontalAlignment: Text.AlignLeft - } - Text { - id: rightAlignedText - width: parent.width - text: "Text aligned to right" - horizontalAlignment: Text.AlignRight - } - } - } - - Text { - text: "Model views" - anchors.left: parent.left - } - - Column { - id: views - spacing: 10 - anchors.left: parent.left - ListView { - id: listView - z: -1 - clip: true - model: text.length - width: 360; height: 45 - orientation: Qt.Horizontal - property string text: "LISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEW" - delegate: Rectangle { - color: "black" - width: 45; height: 45 - Rectangle { - anchors { fill: parent; margins: 1 } - color: "red" - } - Text { - text: listView.text[index] - font.pixelSize: 30 - anchors.centerIn: parent - } - } - } - GridView { - id: gridView - z: -1 - clip: true - model: text.length - width: 180; height: 90 - cellWidth: 45; cellHeight: 45 - property string text: "GRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEW" - anchors.left: parent.left - delegate: Rectangle { - color: "black" - width: 45; height: 45 - Rectangle { - anchors { fill: parent; margins: 1 } - color: "red" - } - Text { - anchors.centerIn: parent - font.pixelSize: 30 - text: gridView.text[index] - } - } - } - } - - Text { - text: "Item x" - anchors.left: parent.left - } - Rectangle { - id: items - color: Qt.rgba(0.2, 0.2, 0.2, 0.6) - width: 275; height: 95 - anchors.left: parent.left - Rectangle { - y: 5; x: 5 - width: 130; height: 40 - Text { - text: "Item with x: 5\n(not mirrored)" - anchors.centerIn: parent - } - } - Rectangle { - color: Qt.rgba(0.7, 0.7, 0.7) - y: 50; x: mirror(5) - width: 130; height: 40 - function mirror(value) { - return LayoutMirroring.enabled ? (parent.width - width - value) : value; - } - Text { - text: "Item with x: " + parent.x + "\n(manually mirrored)" - anchors.centerIn: parent - } - } - } - Text { - text: "Item anchors" - anchors.left: parent.left - } - - Rectangle { - id: anchoredItems - color: Qt.rgba(0.2, 0.2, 0.2, 0.6) - width: 270; height: 170 - anchors.left: parent.left - Rectangle { - id: blackRectangle - color: "black" - width: 180; height: 90 - anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 } - Text { - text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent." - color: "white" - anchors.centerIn: parent - } - } - Rectangle { - id: whiteRectangle - color: "white" - width: 120; height: 70 - anchors { left: parent.left; bottom: parent.bottom } - Text { - text: "Left side anchored\nto the left side\nof the parent." - color: "black" - anchors.centerIn: parent - } - } - Rectangle { - id: grayRectangle - color: Qt.rgba(0.7, 0.7, 0.7) - width: 140; height: 90 - anchors { right: parent.right; bottom: parent.bottom } - Text { - text: "Right side anchored\nto the right side\nof the parent." - anchors.centerIn: parent - } - } - } - Rectangle { - id: mirrorButton - color: mouseArea2.pressed ? "black" : "gray" - height: 50; width: parent.width - anchors.left: parent.left - Column { - anchors.centerIn: parent - Text { - text: root.mirror ? "Mirrored" : "Not mirrored" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea2 - anchors.fill: parent - onClicked: { - root.mirror = !root.mirror; - } - } - } - } -} - diff --git a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject deleted file mode 100644 index 72bc04a8a9..0000000000 --- a/examples/declarative/righttoleft/layoutmirroring/layoutmirroring.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "layoutmirroring.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/righttoleft/textalignment/textalignment.qml b/examples/declarative/righttoleft/textalignment/textalignment.qml deleted file mode 100644 index ef5b97bb1a..0000000000 --- a/examples/declarative/righttoleft/textalignment/textalignment.qml +++ /dev/null @@ -1,427 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - color: "white" - width: containerColumn.width - height: containerColumn.height + containerColumn.anchors.topMargin - - property bool mirror: false - property variant horizontalAlignment: undefined - - property variant editorType: ["Plain Text", "Styled Text", "Plain Rich Text", "Italic Rich Text", "Plain TextEdit", "Italic TextEdit", "TextInput"] - property variant text: ["", " ", "Hello world!", "مرحبا العالم!", "Hello world! Hello!\nHello world! Hello!", "مرحبا العالم! مرحبا! مرحبا العالم! مرحبا!" ,"مرحبا العالم! مرحبا! مرحبا Hello world!\nالعالم! مرحبا!"] - property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text", "multi-line left-to-right text", "multi-line right-to-left text", "multi-line bidi text"] - property variant textComponents: [plainTextComponent, styledTextComponent, richTextComponent, italicRichTextComponent, plainTextEdit, italicTextEdit, textInput] - - function shortText(horizontalAlignment) { - - // all the different QML editors have - // the same alignment values - switch (horizontalAlignment) { - case Text.AlignLeft: - return "L"; - case Text.AlignRight: - return "R"; - case Text.AlignHCenter: - return "C"; - case Text.AlignJustify: - return "J"; - default: - return "Error"; - } - } - Column { - id: containerColumn - spacing: 10 - width: editorTypeRow.width - anchors { top: parent.top; topMargin: 5 } - Row { - id: editorTypeRow - Repeater { - model: editorType.length - Item { - width: editorColumn.width - height: editorColumn.height - Column { - id: editorColumn - spacing: 5 - width: textColumn.width+10 - Text { - text: root.editorType[index] - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Column { - id: textColumn - spacing: 5 - anchors.horizontalCenter: parent.horizontalCenter - Repeater { - model: textComponents.length - delegate: textComponents[index] - } - } - } - } - } - } - Column { - spacing: 2 - width: parent.width - Rectangle { - // button - height: 50; width: parent.width - color: mouseArea.pressed ? "black" : "lightgray" - Column { - anchors.centerIn: parent - Text { - text: root.mirror ? "Mirrored" : "Not mirrored" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea - property int index: 0 - anchors.fill: parent - onClicked: root.mirror = !root.mirror - } - } - Rectangle { - // button - height: 50; width: parent.width - color: mouseArea2.pressed ? "black" : "gray" - Column { - anchors.centerIn: parent - Text { - text: { - if (root.horizontalAlignment == undefined) - return "Implict alignment"; - switch (root.horizontalAlignment) { - case Text.AlignLeft: - return "Left alignment"; - case Text.AlignRight: - return "Right alignment"; - case Text.AlignHCenter: - return "Center alignment"; - case Text.AlignJustify: - return "Justify alignment"; - } - } - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea2 - property int index: 0 - anchors.fill: parent - onClicked: { - if (index < 0) { - root.horizontalAlignment = undefined; - } else { - root.horizontalAlignment = Math.pow(2, index); - } - index = (index + 2) % 5 - 1; - } - } - } - } - } - - Component { - id: plainTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: styledTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - style: Text.Sunken - styleColor: "white" - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: richTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: italicRichTextComponent - Text { - width: 180 - text: "" + root.text[index] + "" - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - property variant backgroundColor: Qt.rgba(0.8, 0.2, 0.2, 0.3) - Rectangle { - z: -1 - color: parent.backgroundColor - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: plainTextEdit - TextEdit { - width: 180 - text: root.text[index] - font.pixelSize: 24 - cursorVisible: true - wrapMode: TextEdit.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.5, 0.5, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: italicTextEdit - TextEdit { - width: 180 - text: "" + root.text[index] + "" - font.pixelSize: 24 - cursorVisible: true - wrapMode: TextEdit.WordWrap - textFormat: TextEdit.RichText - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.5, 0.5, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: textInput - Item { - width: 180 - height: textInput.text.length > 20 ? 3*textInput.height : textInput.height - TextInput { - id: textInput - width: 180 - text: root.text[index] - font.pixelSize: 24 - cursorVisible: true - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.6, 0.4, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - } -} - diff --git a/examples/declarative/righttoleft/textalignment/textalignment.qmlproject b/examples/declarative/righttoleft/textalignment/textalignment.qmlproject deleted file mode 100644 index e4b5061364..0000000000 --- a/examples/declarative/righttoleft/textalignment/textalignment.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "textalignment.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/rssnews/content/BusyIndicator.qml b/examples/declarative/rssnews/content/BusyIndicator.qml deleted file mode 100644 index b6264ead92..0000000000 --- a/examples/declarative/rssnews/content/BusyIndicator.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: container - property bool on: false - - source: "images/busy.png"; visible: container.on - - NumberAnimation on rotation { - running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 - } -} diff --git a/examples/declarative/rssnews/content/CategoryDelegate.qml b/examples/declarative/rssnews/content/CategoryDelegate.qml deleted file mode 100644 index 1a56184489..0000000000 --- a/examples/declarative/rssnews/content/CategoryDelegate.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: delegate - - width: delegate.ListView.view.width; height: 60 - - Text { - text: name - color: delegate.ListView.isCurrentItem ? "white" : "black" - font { family: "Helvetica"; pixelSize: 16; bold: true } - anchors { - left: parent.left; leftMargin: 15 - verticalCenter: parent.verticalCenter - } - } - - BusyIndicator { - scale: 0.6 - on: delegate.ListView.isCurrentItem && window.loading - anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter } - } - - Rectangle { - width: delegate.width; height: 1; color: "#cccccc" - anchors.bottom: delegate.bottom - visible: delegate.ListView.isCurrentItem ? false : true - } - Rectangle { - width: delegate.width; height: 1; color: "white" - visible: delegate.ListView.isCurrentItem ? false : true - } - - MouseArea { - anchors.fill: delegate - onClicked: { - delegate.ListView.view.currentIndex = index - window.currentFeed = feed - } - } -} diff --git a/examples/declarative/rssnews/content/NewsDelegate.qml b/examples/declarative/rssnews/content/NewsDelegate.qml deleted file mode 100644 index 84019a9179..0000000000 --- a/examples/declarative/rssnews/content/NewsDelegate.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: delegate - height: column.height + 40 - width: delegate.ListView.view.width - - Column { - id: column - x: 20; y: 20 - width: parent.width - 40 - - Text { - id: titleText - text: title; width: parent.width; wrapMode: Text.WordWrap - font { bold: true; family: "Helvetica"; pointSize: 16 } - } - - Text { - id: descriptionText - width: parent.width; text: description - wrapMode: Text.WordWrap; font.family: "Helvetica" - } - } - - Rectangle { - width: parent.width; height: 1; color: "#cccccc" - anchors.bottom: parent.bottom - } -} diff --git a/examples/declarative/rssnews/content/RssFeeds.qml b/examples/declarative/rssnews/content/RssFeeds.qml deleted file mode 100644 index 278f05752c..0000000000 --- a/examples/declarative/rssnews/content/RssFeeds.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - id: rssFeeds - - ListElement { name: "Top Stories"; feed: "rss.news.yahoo.com/rss/topstories" } - ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" } - ListElement { name: "Europe"; feed: "rss.news.yahoo.com/rss/europe" } - ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" } - ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" } - ListElement { name: "Politics"; feed: "rss.news.yahoo.com/rss/politics" } - ListElement { name: "Business"; feed: "rss.news.yahoo.com/rss/business" } - ListElement { name: "Technology"; feed: "rss.news.yahoo.com/rss/tech" } - ListElement { name: "Entertainment"; feed: "rss.news.yahoo.com/rss/entertainment" } - ListElement { name: "Health"; feed: "rss.news.yahoo.com/rss/health" } - ListElement { name: "Science"; feed: "rss.news.yahoo.com/rss/science" } - ListElement { name: "Sports"; feed: "rss.news.yahoo.com/rss/sports" } -} diff --git a/examples/declarative/rssnews/content/ScrollBar.qml b/examples/declarative/rssnews/content/ScrollBar.qml deleted file mode 100644 index 4ca4132c6b..0000000000 --- a/examples/declarative/rssnews/content/ScrollBar.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property variant scrollArea - property variant orientation: Qt.Vertical - - opacity: 0 - - function position() - { - var ny = 0; - if (container.orientation == Qt.Vertical) - ny = scrollArea.visibleArea.yPosition * container.height; - else - ny = scrollArea.visibleArea.xPosition * container.width; - if (ny > 2) return ny; else return 2; - } - - function size() - { - var nh, ny; - - if (container.orientation == Qt.Vertical) - nh = scrollArea.visibleArea.heightRatio * container.height; - else - nh = scrollArea.visibleArea.widthRatio * container.width; - - if (container.orientation == Qt.Vertical) - ny = scrollArea.visibleArea.yPosition * container.height; - else - ny = scrollArea.visibleArea.xPosition * container.width; - - if (ny > 3) { - var t; - if (container.orientation == Qt.Vertical) - t = Math.ceil(container.height - 3 - ny); - else - t = Math.ceil(container.width - 3 - ny); - if (nh > t) return t; else return nh; - } else return nh + ny; - } - - Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 } - - BorderImage { - source: "images/scrollbar.png" - border { left: 1; right: 1; top: 1; bottom: 1 } - x: container.orientation == Qt.Vertical ? 2 : position() - width: container.orientation == Qt.Vertical ? container.width - 4 : size() - y: container.orientation == Qt.Vertical ? position() : 2 - height: container.orientation == Qt.Vertical ? size() : container.height - 4 - } - - states: State { - name: "visible" - when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally - PropertyChanges { target: container; opacity: 1.0 } - } - - transitions: Transition { - from: "visible"; to: "" - NumberAnimation { properties: "opacity"; duration: 600 } - } -} diff --git a/examples/declarative/rssnews/content/images/busy.png b/examples/declarative/rssnews/content/images/busy.png deleted file mode 100644 index 664c2b1491..0000000000 Binary files a/examples/declarative/rssnews/content/images/busy.png and /dev/null differ diff --git a/examples/declarative/rssnews/content/images/scrollbar.png b/examples/declarative/rssnews/content/images/scrollbar.png deleted file mode 100644 index 0228dcf9eb..0000000000 Binary files a/examples/declarative/rssnews/content/images/scrollbar.png and /dev/null differ diff --git a/examples/declarative/rssnews/rssnews.qml b/examples/declarative/rssnews/rssnews.qml deleted file mode 100644 index 491cefda07..0000000000 --- a/examples/declarative/rssnews/rssnews.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 -import "content" - -Rectangle { - id: window - width: 800; height: 480 - - property string currentFeed: "rss.news.yahoo.com/rss/topstories" - property bool loading: feedModel.status == XmlListModel.Loading - - RssFeeds { id: rssFeeds } - - XmlListModel { - id: feedModel - source: "http://" + window.currentFeed - query: "/rss/channel/item" - - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "link"; query: "link/string()" } - XmlRole { name: "description"; query: "description/string()" } - } - - Row { - Rectangle { - width: 220; height: window.height - color: "#efefef" - - ListView { - focus: true - id: categories - anchors.fill: parent - model: rssFeeds - footer: quitButtonDelegate - delegate: CategoryDelegate {} - highlight: Rectangle { color: "steelblue" } - highlightMoveSpeed: 9999999 - } - ScrollBar { - scrollArea: categories; height: categories.height; width: 8 - anchors.right: categories.right - } - } - ListView { - id: list - width: window.width - 220; height: window.height - model: feedModel - delegate: NewsDelegate {} - } - } - Component { - id: quitButtonDelegate - Item { - width: categories.width; height: 60 - Text { - text: "Quit" - font { family: "Helvetica"; pixelSize: 16; bold: true } - anchors { - left: parent.left; leftMargin: 15 - verticalCenter: parent.verticalCenter - } - } - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - } - } - ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right } - Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" } -} diff --git a/examples/declarative/rssnews/rssnews.qmlproject b/examples/declarative/rssnews/rssnews.qmlproject deleted file mode 100644 index 5becbdaed0..0000000000 --- a/examples/declarative/rssnews/rssnews.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "rssnews.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/samegame/content/BoomBlock.qml b/examples/declarative/samegame/content/BoomBlock.qml deleted file mode 100644 index 47f86bd81b..0000000000 --- a/examples/declarative/samegame/content/BoomBlock.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: block - property bool dying: false - property bool spawned: false - property int type: 0 - property ParticleSystem particleSystem - - Behavior on x { - enabled: spawned; - SpringAnimation{ spring: 2; damping: 0.2 } - } - Behavior on y { - SpringAnimation{ spring: 2; damping: 0.2 } - } - - Image { - id: img - source: { - if(type == 0){ - "pics/redStone.png"; - } else if(type == 1) { - "pics/blueStone.png"; - } else { - "pics/greenStone.png"; - } - } - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 200 } } - anchors.fill: parent - } - Emitter { - id: particles - system: particleSystem - group: { - if(type == 0){ - "red"; - } else if (type == 1) { - "blue"; - } else { - "green"; - } - } - anchors.fill: parent - - speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60} - shape: EllipseShape{fill:true} - enabled: false; - lifeSpan: 700; lifeSpanVariation: 100 - emitRate: 1000 - maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number) - size: 28 - endSize: 14 - } - - states: [ - State { - name: "AliveState"; when: spawned == true && dying == false - PropertyChanges { target: img; opacity: 1 } - }, - - State { - name: "DeathState"; when: dying == true - StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100);} } - PropertyChanges { target: img; opacity: 0 } - StateChangeScript { script: block.destroy(1000); } - } - ] -} diff --git a/examples/declarative/samegame/content/Button.qml b/examples/declarative/samegame/content/Button.qml deleted file mode 100644 index b305455c92..0000000000 --- a/examples/declarative/samegame/content/Button.qml +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 20 - smooth: true - border { width: 1; color: Qt.darker(activePalette.button) } - radius: 8 - color: activePalette.button - - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } - - Text { - id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText; font.pixelSize: 24 - } -} diff --git a/examples/declarative/samegame/content/Dialog.qml b/examples/declarative/samegame/content/Dialog.qml deleted file mode 100644 index 80e5984bfe..0000000000 --- a/examples/declarative/samegame/content/Dialog.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - anchors.centerIn: parent - - property Item text: dialogText - property bool open: false - - signal closed - signal opened - function forceClose() { - if(!open) - return; //already closed - page.open = false; - page.closed(); - page.opacity = 0; - } - - function show(txt) { - page.open = true; - page.opened(); - dialogText.text = txt; - page.opacity = 1; - } - - width: dialogText.width + 20; height: dialogText.height + 20 - color: "white" - border.width: 1 - opacity: 0 - visible: opacity > 0 - Behavior on opacity { - NumberAnimation { duration: 1000 } - } - - Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" } - - MouseArea { anchors.fill: parent; onClicked: forceClose(); } -} - diff --git a/examples/declarative/samegame/content/GameArea.qml b/examples/declarative/samegame/content/GameArea.qml deleted file mode 100644 index a43d55117a..0000000000 --- a/examples/declarative/samegame/content/GameArea.qml +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "samegame.js" as Logic - -Item { - id: gameCanvas - property int score: 0 - property int blockSize: 40 - property ParticleSystem ps: particleSystem - Image { - id: background - anchors.fill: parent - z: -1 - source: "pics/background.png" - fillMode: Image.PreserveAspectCrop - } - - width: 480 - height: 800 - MouseArea { - anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y); - } - ParticleSystem{ - id: particleSystem; - onEmptyChanged: if (empty) paused = true; - z:2 - ImageParticle { - groups: ["red"] - color: Qt.darker("red");//Actually want desaturated... - source: "pics/particle.png" - colorVariation: 0.4 - alpha: 0.1 - } - ImageParticle { - groups: ["green"] - color: Qt.darker("green");//Actually want desaturated... - source: "pics/particle.png" - colorVariation: 0.4 - alpha: 0.1 - } - ImageParticle { - groups: ["blue"] - color: Qt.darker("blue");//Actually want desaturated... - source: "pics/particle.png" - colorVariation: 0.4 - alpha: 0.1 - } - anchors.fill: parent - } -} - diff --git a/examples/declarative/samegame/content/NameInputDialog.qml b/examples/declarative/samegame/content/NameInputDialog.qml deleted file mode 100644 index 602e69789a..0000000000 --- a/examples/declarative/samegame/content/NameInputDialog.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Dialog { - id: nameInputDialog - - property int initialWidth: 0 - property alias name: nameInputText.text - - anchors.centerIn: parent - z: 22; - - Behavior on width { - NumberAnimation {} - enabled: nameInputDialog.initialWidth != 0 - } - - signal accepted(string name) - onClosed: { - if (nameInputText.text != "") - accepted(name); - } - Text { - id: dialogText - anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter } - text: "You won! Please enter your name: " - } - MouseArea { - anchors.fill: parent - onClicked: { - if (nameInputText.text == "") - nameInputText.openSoftwareInputPanel(); - else - nameInputDialog.forceClose(); - } - } - - TextInput { - id: nameInputText - anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } - focus: visible - autoScroll: false - maximumLength: 24 - onTextChanged: { - var newWidth = nameInputText.width + dialogText.width + 40; - if ( (newWidth > nameInputDialog.width && newWidth < screen.width) - || (nameInputDialog.width > nameInputDialog.initialWidth) ) - nameInputDialog.width = newWidth; - } - onAccepted: { - nameInputDialog.forceClose(); - } - } -} diff --git a/examples/declarative/samegame/content/pics/background.png b/examples/declarative/samegame/content/pics/background.png deleted file mode 100644 index 3734a27744..0000000000 Binary files a/examples/declarative/samegame/content/pics/background.png and /dev/null differ diff --git a/examples/declarative/samegame/content/pics/blueStone.png b/examples/declarative/samegame/content/pics/blueStone.png deleted file mode 100644 index 20e43c75b6..0000000000 Binary files a/examples/declarative/samegame/content/pics/blueStone.png and /dev/null differ diff --git a/examples/declarative/samegame/content/pics/greenStone.png b/examples/declarative/samegame/content/pics/greenStone.png deleted file mode 100644 index b568a1900c..0000000000 Binary files a/examples/declarative/samegame/content/pics/greenStone.png and /dev/null differ diff --git a/examples/declarative/samegame/content/pics/particle.png b/examples/declarative/samegame/content/pics/particle.png deleted file mode 100644 index 5c83896d22..0000000000 Binary files a/examples/declarative/samegame/content/pics/particle.png and /dev/null differ diff --git a/examples/declarative/samegame/content/pics/redStone.png b/examples/declarative/samegame/content/pics/redStone.png deleted file mode 100644 index 36b09a2686..0000000000 Binary files a/examples/declarative/samegame/content/pics/redStone.png and /dev/null differ diff --git a/examples/declarative/samegame/content/pics/yellowStone.png b/examples/declarative/samegame/content/pics/yellowStone.png deleted file mode 100644 index b1ce76212c..0000000000 Binary files a/examples/declarative/samegame/content/pics/yellowStone.png and /dev/null differ diff --git a/examples/declarative/samegame/content/samegame.js b/examples/declarative/samegame/content/samegame.js deleted file mode 100755 index 611767584b..0000000000 --- a/examples/declarative/samegame/content/samegame.js +++ /dev/null @@ -1,290 +0,0 @@ -/* This script file handles the game logic */ -.pragma library -.import QtQuick.LocalStorage 2.0 as Sql - -var maxColumn = 10; -var maxRow = 15; -var maxIndex = maxColumn*maxRow; -var board = new Array(maxIndex); -var blockSrc = "BoomBlock.qml"; -var scoresURL = ""; -var gameDuration; -var component = Qt.createComponent(blockSrc); -var highScoreBar = -1; -var gameCanvas; -var nameInputDialog = null; -var dialog = null; - -// Index function used instead of a 2D array -function index(column, row) -{ - return column + row * maxColumn; -} - -function timeStr(msecs) -{ - var secs = Math.floor(msecs/1000); - var m = Math.floor(secs/60); - var ret = "" + m + "m " + (secs%60) + "s"; - return ret; -} - -function startNewGame(gc) -{ - gameCanvas = gc; - // Delete blocks from previous game - for (var i = 0; i < maxIndex; i++) { - if (board[i] != null) - board[i].destroy(); - } - - // Calculate board size - maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize); - maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize); - maxIndex = maxRow * maxColumn; - - // Close dialogs - if(nameInputDialog != null) - nameInputDialog.forceClose(); - if(dialog != null) - dialog.forceClose(); - - // Initialize Board - board = new Array(maxIndex); - gameCanvas.score = 0; - for (var column = 0; column < maxColumn; column++) { - for (var row = 0; row < maxRow; row++) { - board[index(column, row)] = null; - createBlock(column, row); - } - } - gameDuration = new Date(); -} - -var fillFound; // Set after a floodFill call to the number of blocks found -var floodBoard; // Set to 1 if the floodFill reaches off that node - -// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope -function handleClick(x,y) -{ - if(gameCanvas == undefined){ - console.log("But the game hasn't started yet!"); - return; - } - var column = Math.floor(x/gameCanvas.blockSize); - var row = Math.floor(y/gameCanvas.blockSize); - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (board[index(column, row)] == null) - return; - // If it's a valid block, remove it and all connected (does nothing if it's not connected) - floodFill(column,row, -1); - if (fillFound <= 0) - return; - gameCanvas.score += (fillFound - 1) * (fillFound - 1); - shuffleDown(); - victoryCheck(); -} - -function floodFill(column,row,type) -{ - if (board[index(column, row)] == null) - return; - var first = false; - if (type == -1) { - first = true; - type = board[index(column,row)].type; - - // Flood fill initialization - fillFound = 0; - floodBoard = new Array(maxIndex); - } - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) - return; - floodBoard[index(column, row)] = 1; - floodFill(column + 1, row, type); - floodFill(column - 1, row, type); - floodFill(column, row + 1, type); - floodFill(column, row - 1, type); - if (first == true && fillFound == 0) - return; // Can't remove single blocks - board[index(column, row)].dying = true; - board[index(column, row)] = null; - fillFound += 1; -} - -function shuffleDown() -{ - // Fall down - for (var column = 0; column < maxColumn; column++) { - var fallDist = 0; - for (var row = maxRow - 1; row >= 0; row--) { - if (board[index(column,row)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - var obj = board[index(column, row)]; - obj.y = (row + fallDist) * gameCanvas.blockSize; - board[index(column, row + fallDist)] = obj; - board[index(column, row)] = null; - } - } - } - } - // Fall to the left - fallDist = 0; - for (column = 0; column < maxColumn; column++) { - if (board[index(column, maxRow - 1)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - for (row = 0; row < maxRow; row++) { - obj = board[index(column, row)]; - if (obj == null) - continue; - obj.x = (column - fallDist) * gameCanvas.blockSize; - board[index(column - fallDist,row)] = obj; - board[index(column, row)] = null; - } - } - } - } -} - -function victoryCheck() -{ - // Awards bonuses for no blocks left - var deservesBonus = true; - for (var column = maxColumn - 1; column >= 0; column--) - if (board[index(column, maxRow - 1)] != null) - deservesBonus = false; - if (deservesBonus) - gameCanvas.score += 500; - // Checks for game over - if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { - gameDuration = new Date() - gameDuration; - if(nameInputDialog == null){ - nameInputDialog = Qt.createQmlObject('import "."; import "samegame.js" as Logic; NameInputDialog{onAccepted: Logic.saveHighScore(name)}', gameCanvas, "highscoredialog.qml"); - } - if(dialog == null){ - dialog = Qt.createComponent("Dialog.qml").createObject(gameCanvas); - } - initHighScoreBar(); - if(gameCanvas.score > highScoreBar){ - nameInputDialog.show("You won! Please enter your name: "); - nameInputDialog.initialWidth = nameInputDialog.text.width + 20; - if (nameInputDialog.name == "") - nameInputDialog.width = nameInputDialog.initialWidth; - nameInputDialog.text.opacity = 0; // Just a spacer - }else{ - dialog.show("You won!"); - } - } -} - -// Only floods up and right, to see if it can find adjacent same-typed blocks -function floodMoveCheck(column, row, type) -{ - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return false; - if (board[index(column, row)] == null) - return false; - var myType = board[index(column, row)].type; - if (type == myType) - return true; - return floodMoveCheck(column + 1, row, myType) || - floodMoveCheck(column, row - 1, board[index(column, row)].type); -} - -function createBlock(column,row) -{ - // Note that we don't wait for the component to become ready. This will - // only work if the block QML is a local file. Otherwise the component will - // not be ready immediately. There is a statusChanged signal on the - // component you could use if you want to wait to load remote files. - if(component.status == 1){ - var dynamicObject = component.createObject(gameCanvas, - {"type": Math.floor(Math.random() * 3), - "x": column*gameCanvas.blockSize, - "width": gameCanvas.blockSize, - "height": gameCanvas.blockSize, - "particleSystem": gameCanvas.ps}); - if(dynamicObject == null){ - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.y = row*gameCanvas.blockSize; - dynamicObject.spawned = true; - - board[index(column,row)] = dynamicObject; - }else{ - console.log("error loading block component"); - console.log(component.errorString()); - return false; - } - return true; -} - -function initHighScoreBar() -{ - var db = Sql.openDatabaseSync( - "SameGameScores", - "1.0", - "Local SameGame High Scores", - 100 - ); - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); - // Only show results for the current grid size - var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "' - + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10'); - if(rs.rows.length < 10) - highScoreBar = 0; - else - highScoreBar = rs.rows.item(rs.rows.length - 1).score; - } - ); -} - -function saveHighScore(name) -{ - if (scoresURL != "") - sendHighScore(name); - // Offline storage - var db = Sql.openDatabaseSync( - "SameGameScores", - "1.0", - "Local SameGame High Scores", - 100 - ); - var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; - var data = [ - name, - gameCanvas.score, - maxColumn + "x" + maxRow, - Math.floor(gameDuration / 1000) - ]; - db.transaction( - function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); - tx.executeSql(dataStr, data); - - // Only show results for the current grid size - var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "' - + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10'); - var r = "\nHIGH SCORES for this grid size\n\n" - for (var i = 0; i < rs.rows.length; i++) { - r += (i+1) + ". " + rs.rows.item(i).name + ' got ' - + rs.rows.item(i).score + ' points in ' - + rs.rows.item(i).time + ' seconds.\n'; - } - if(rs.rows.length == 10) - highScoreBar = rs.rows.item(9).score; - dialog.show(r); - } - ); -} diff --git a/examples/declarative/samegame/samegame.qml b/examples/declarative/samegame/samegame.qml deleted file mode 100644 index 201f826a29..0000000000 --- a/examples/declarative/samegame/samegame.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content" -import "content/samegame.js" as Logic - -Rectangle { - id: screen - width: 480; height: 640 - - SystemPalette { id: activePalette } - - GameArea { - id: gameCanvas - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - } - - Rectangle { - id: toolBar - width: parent.width; height: 80 - color: activePalette.window - anchors.bottom: screen.bottom - - Button { - id: newGameButton - anchors { left: parent.left; leftMargin: 12; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: Logic.startNewGame(gameCanvas) - } - - Button { - text: "Quit" - anchors { left: newGameButton.right; leftMargin: 12; verticalCenter: parent.verticalCenter } - onClicked: Qt.quit(); - } - - Text { - id: score - anchors { right: parent.right; rightMargin: 12; verticalCenter: parent.verticalCenter } - text: "Score: " + gameCanvas.score - font.bold: true - font.pixelSize: 24 - color: activePalette.windowText - } - } -} diff --git a/examples/declarative/samegame/samegame.qmlproject b/examples/declarative/samegame/samegame.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/samegame/samegame.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/script/script.pro b/examples/declarative/script/script.pro deleted file mode 100644 index 98c1bbc5ee..0000000000 --- a/examples/declarative/script/script.pro +++ /dev/null @@ -1,4 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS = \ - shell diff --git a/examples/declarative/script/shell/main.cpp b/examples/declarative/script/shell/main.cpp deleted file mode 100644 index 9f0edf4a25..0000000000 --- a/examples/declarative/script/shell/main.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include -#include -#include -#include - -#include - -#include - -#include - - -class CommandInterface : public QObject -{ - Q_OBJECT -public: - Q_INVOKABLE void quit() { m_wantsToQuit = true; } - static bool wantsToQuit() { return m_wantsToQuit; } -private: - static bool m_wantsToQuit; -}; - -bool CommandInterface::m_wantsToQuit = false; - - -static void interactive(QJSEngine *eng) -{ - QTextStream qin(stdin, QFile::ReadOnly); - const char *prompt = "qs> "; - - forever { - QString line; - - printf("%s", prompt); - fflush(stdout); - - line = qin.readLine(); - if (line.isNull()) - break; - - if (line.trimmed().isEmpty()) - continue; - - line += QLatin1Char('\n'); - - QJSValue result = eng->evaluate(line, QLatin1String("typein")); - - fprintf(stderr, "%s\n", qPrintable(result.toString())); - - if (CommandInterface::wantsToQuit()) - break; - } -} - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - QScopedPointer eng(new QJSEngine()); - { - QJSValue globalObject = eng->globalObject(); - QJSValue interface = eng->newQObject(new CommandInterface); - globalObject.setProperty("qt", interface); - } - - if (! *++argv) { - interactive(eng.data()); - return EXIT_SUCCESS; - } - - while (const char *arg = *argv++) { - QString fileName = QString::fromLocal8Bit(arg); - - if (fileName == QLatin1String("-i")) { - interactive(eng.data()); - break; - } - - QString contents; - int lineNumber = 1; - - if (fileName == QLatin1String("-")) { - QTextStream stream(stdin, QFile::ReadOnly); - contents = stream.readAll(); - } else { - QFile file(fileName); - if (file.open(QFile::ReadOnly)) { - QTextStream stream(&file); - contents = stream.readAll(); - file.close(); - - // strip off #!/usr/bin/env qjs line - if (contents.startsWith("#!")) { - contents.remove(0, contents.indexOf("\n")); - ++lineNumber; - } - } - } - - if (contents.isEmpty()) - continue; - - QJSValue result = eng->evaluate(contents, fileName, lineNumber); - if (eng->hasUncaughtException()) { - fprintf (stderr, " %s\n\n", qPrintable(result.toString())); - return EXIT_FAILURE; - } - } - - return EXIT_SUCCESS; -} - -#include diff --git a/examples/declarative/script/shell/shell.pro b/examples/declarative/script/shell/shell.pro deleted file mode 100644 index 00191ab3d0..0000000000 --- a/examples/declarative/script/shell/shell.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += declarative - -win32: CONFIG += console -mac:CONFIG -= app_bundle - -SOURCES += main.cpp - diff --git a/examples/declarative/shadereffects/content/Slider.qml b/examples/declarative/shadereffects/content/Slider.qml deleted file mode 100644 index 4ddc6d3432..0000000000 --- a/examples/declarative/shadereffects/content/Slider.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - property real value: bar.x / (foo.width - bar.width) - Item { - id: foo - width: parent.width - 4 - height: 6 - anchors.centerIn: parent - - Rectangle { - height: parent.height - anchors.left: parent.left - anchors.right: bar.horizontalCenter - color: "blue" - radius: 3 - } - Rectangle { - height: parent.height - anchors.left: bar.horizontalCenter - anchors.right: parent.right - color: "gray" - radius: 3 - } - Rectangle { - anchors.fill: parent - color: "transparent" - radius: 3 - border.width: 2 - border.color: "black" - } - - Rectangle { - id: bar - y: -7 - width: 20 - height: 20 - radius: 15 - color: "white" - border.width: 2 - border.color: "black" - MouseArea { - anchors.fill: parent - drag.target: parent - drag.axis: Drag.XAxis - drag.minimumX: 0 - drag.maximumX: foo.width - parent.width - } - } - } -} - diff --git a/examples/declarative/shadereffects/content/face-smile.png b/examples/declarative/shadereffects/content/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/shadereffects/content/face-smile.png and /dev/null differ diff --git a/examples/declarative/shadereffects/content/qt-logo.png b/examples/declarative/shadereffects/content/qt-logo.png deleted file mode 100644 index 7d3e97eb36..0000000000 Binary files a/examples/declarative/shadereffects/content/qt-logo.png and /dev/null differ diff --git a/examples/declarative/shadereffects/shadereffects.qml b/examples/declarative/shadereffects/shadereffects.qml deleted file mode 100644 index 842e42b89f..0000000000 --- a/examples/declarative/shadereffects/shadereffects.qml +++ /dev/null @@ -1,300 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Image { - width: 640 - height: 360 - source: "../snake/content/pics/background.png" - - ShaderEffectSource { - id: theSource - sourceItem: theItem - smooth: true - } - - function saturate(x) { - return Math.min(Math.max(x, 0), 1) - } - - function sliderToColor(x) { - return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)), - saturate(Math.min(6 * x, 4 - 6 * x)), - saturate(Math.min(6 * x - 2, 6 - 6 * x))) - } - - Grid { - anchors.centerIn: parent - columns: 3 - - Item { - id: theItem - width: 180 - height: 180 - ListView { - anchors.centerIn: parent - width: 160 - height: 140 - clip: true - snapMode: ListView.SnapOneItem - model: VisualItemModel { - Text { - width: 160 - height: 140 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.pixelSize: 120 - font.family: "Times" - color: "blue" - text: "Qt" - } - Image { - width: 160 - height: 140 - source: "content/qt-logo.png" - smooth: true - } - Image { - width: 160 - height: 140 - source: "content/face-smile.png" - smooth: true - } - } - } - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property real amplitude: 0.04 * wobbleSlider.value - property real frequency: 20 - property real time: 0 - NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } - fragmentShader: - "uniform lowp float qt_Opacity;" + - "uniform highp float amplitude;" + - "uniform highp float frequency;" + - "uniform highp float time;" + - "uniform sampler2D source;" + - "varying highp vec2 qt_TexCoord0;" + - "void main() {" + - " highp vec2 p = sin(time + frequency * qt_TexCoord0);" + - " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" + - "}" - Slider { - id: wobbleSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property variant shadow: ShaderEffectSource { - smooth: true - sourceItem: ShaderEffect { - width: theItem.width - height: theItem.height - property variant delta: Qt.size(0.0, 1.0 / height) - property variant source: ShaderEffectSource { - smooth: true - sourceItem: ShaderEffect { - width: theItem.width - height: theItem.height - property variant delta: Qt.size(1.0 / width, 0.0) - property variant source: theSource - fragmentShader: " - uniform lowp float qt_Opacity; - uniform sampler2D source; - uniform highp vec2 delta; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) - + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) - + 0.2466 * texture2D(source, qt_TexCoord0) - + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) - + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; - }" - } - } - fragmentShader: " - uniform lowp float qt_Opacity; - uniform sampler2D source; - uniform highp vec2 delta; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) - + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) - + 0.2466 * texture2D(source, qt_TexCoord0) - + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) - + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; - }" - } - } - property real angle: 0 - property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle)) - NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 } - property variant delta: Qt.size(offset.x / width, offset.y / height) - property real darkness: shadowSlider.value - fragmentShader: " - uniform lowp float qt_Opacity; - uniform highp vec2 offset; - uniform sampler2D source; - uniform sampler2D shadow; - uniform highp float darkness; - uniform highp vec2 delta; - varying highp vec2 qt_TexCoord0; - void main() { - lowp vec4 fg = texture2D(source, qt_TexCoord0); - lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta); - gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity; - }" - Slider { - id: shadowSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property variant delta: Qt.size(0.5 / width, 0.5 / height) - fragmentShader: " - uniform sampler2D source; - uniform highp vec2 delta; - uniform highp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { - lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta); - lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y)); - lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y)); - lowp vec4 br = texture2D(source, qt_TexCoord0 + delta); - lowp vec4 gx = (tl + bl) - (tr + br); - lowp vec4 gy = (tl + tr) - (bl + br); - gl_FragColor.xyz = vec3(0.); - gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity; - }" - } - ShaderEffect { - width: 180 - height: 180 - property variant source: theSource - property color tint: sliderToColor(colorizeSlider.value) - fragmentShader: " - uniform sampler2D source; - uniform lowp vec4 tint; - uniform lowp float qt_Opacity; - varying highp vec2 qt_TexCoord0; - void main() { - lowp vec4 c = texture2D(source, qt_TexCoord0); - lowp float lo = min(min(c.x, c.y), c.z); - lowp float hi = max(max(c.x, c.y), c.z); - gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w); - }" - Slider { - id: colorizeSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - ShaderEffect { - width: 180 - height: 180 - mesh: Qt.size(10, 10) - property variant source: theSource - property real bend: 0 - property real minimize: 0 - property real side: genieSlider.value - SequentialAnimation on bend { - loops: Animation.Infinite - NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1600 } - NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1000 } - } - SequentialAnimation on minimize { - loops: Animation.Infinite - PauseAnimation { duration: 300 } - NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1000 } - NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } - PauseAnimation { duration: 1300 } - } - vertexShader: " - uniform highp mat4 qt_Matrix; - uniform highp float bend; - uniform highp float minimize; - uniform highp float side; - uniform highp float width; - uniform highp float height; - attribute highp vec4 qt_Vertex; - attribute highp vec2 qt_MultiTexCoord0; - varying highp vec2 qt_TexCoord0; - void main() { - qt_TexCoord0 = qt_MultiTexCoord0; - highp vec4 pos = qt_Vertex; - pos.y = mix(qt_Vertex.y, height, minimize); - highp float t = pos.y / height; - t = (3. - 2. * t) * t * t; - pos.x = mix(qt_Vertex.x, side * width, t * bend); - gl_Position = qt_Matrix * pos; - }" - Slider { - id: genieSlider - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 40 - } - } - } -} diff --git a/examples/declarative/shared/Button.qml b/examples/declarative/shared/Button.qml deleted file mode 100644 index a899a1410b..0000000000 --- a/examples/declarative/shared/Button.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - property string text: "Button" - property string subText: "Just a button" - signal clicked - - width: buttonLabel.width + 20; height: col.height + 12 - - MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } - - Column { - spacing: 2 - id: col - Text { - id: buttonLabel; text: container.text; color: "black"; font.pixelSize: 24 - } - Text { - id: buttonLabel2; text: container.subText; color: "black"; font.pixelSize: 12 - } - } -} diff --git a/examples/declarative/shared/LauncherList.qml b/examples/declarative/shared/LauncherList.qml deleted file mode 100644 index 782fcc7ddd..0000000000 --- a/examples/declarative/shared/LauncherList.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -ListView { - //model is a list of {"name":"somename", "url":"file:///some/url/mainfile.qml"} - //function used to add to model A) to enforce scheme B) to allow Qt.resolveUrl in url assignments - function addExample(name, desc, url) - { - myModel.append({"name":name, "description":desc, "url":url}) - } - function hideExample() - { - ei.visible = false; - } - - clip: true - delegate: SimpleLauncherDelegate{exampleItem: ei} - model: ListModel {id:myModel} - Item { - id: ei - visible: false - clip: true - property url exampleUrl - onExampleUrlChanged: visible = (exampleUrl == '' ? false : true);//Setting exampleUrl automatically shows example - anchors.fill: parent - anchors.bottomMargin: 40 - Rectangle { - id: bg - anchors.fill: parent - color: "white" - } - MouseArea{ - anchors.fill: parent - enabled: ei.visible - //Eats mouse events - } - Loader{ - source: ei.exampleUrl - anchors.fill: parent - } - } - Rectangle { - id: bar - visible: ei.visible - anchors.bottom: parent.bottom - width: parent.width - height: 40 - MouseArea{ - anchors.fill: parent - enabled: ei.visible - //Eats mouse events - } - Image { - source: "back.png" - anchors.verticalCenter: parent.verticalCenter - x: 4 - MouseArea { - anchors.fill: parent - onClicked: ei.exampleUrl = ""; - } - } - } -} diff --git a/examples/declarative/shared/README b/examples/declarative/shared/README deleted file mode 100644 index bf16f238c7..0000000000 --- a/examples/declarative/shared/README +++ /dev/null @@ -1,11 +0,0 @@ -These files are shared between multiple examples as a set of common and -reusuable components. While they do demonstrate the building of reusable -components in QML, they are not official examples themselves. -Consequently they do not have entries in the Qt documentation, and are -documented only through the code comments within the files. Developers -new to QML are strongly encouraged to go through the official examples -before delving into this directory. - -For most application use, see the Qt Quick Components project to find -ready-made Components you can use in your own projects. Qt Declarative -examples do not use them only to avoid external dependencies. diff --git a/examples/declarative/shared/SimpleLauncherDelegate.qml b/examples/declarative/shared/SimpleLauncherDelegate.qml deleted file mode 100644 index c3708fe259..0000000000 --- a/examples/declarative/shared/SimpleLauncherDelegate.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - id: container - property Item exampleItem - width: ListView.view.width - height: 64 - Button { - anchors.fill: parent - text: name - subText: description - onClicked: exampleItem.exampleUrl = url; - } -} diff --git a/examples/declarative/shared/back.png b/examples/declarative/shared/back.png deleted file mode 100644 index 506ac42fcf..0000000000 Binary files a/examples/declarative/shared/back.png and /dev/null differ diff --git a/examples/declarative/snake/content/Button.qml b/examples/declarative/snake/content/Button.qml deleted file mode 100644 index dfac45049a..0000000000 --- a/examples/declarative/snake/content/Button.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - signal clicked - property string text: "Button" - - color: activePalette.button; smooth: true - width: txtItem.width + 20; height: txtItem.height + 6 - border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; - - gradient: Gradient { - GradientStop { - id: topGrad; position: 0.0 - color: if (mr.pressed) { activePalette.dark } else { activePalette.light } } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() } - - Text { - id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText - } -} diff --git a/examples/declarative/snake/content/Cookie.qml b/examples/declarative/snake/content/Cookie.qml deleted file mode 100644 index cae53af525..0000000000 --- a/examples/declarative/snake/content/Cookie.qml +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { - id: root - property bool dying: false - property int row; - property int column; - x: margin + column * gridSize - y: margin + row * gridSize - - width: gridSize - height: gridSize - property int value : 1; - - Image { - id: img - anchors.fill: parent - source: "pics/cookie.png" - opacity: 0 - Text { - font.bold: true - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - text: value - } - } - - - ParticleSystem { - width:1; height:1; anchors.centerIn: parent; - ImageParticle { - groups: ["star"] - source: "pics/yellowStar.png" - } - Emitter { - id: particles - anchors.fill: parent - group: "star" - emitRate: 50 - enabled: false - lifeSpan: 700 - acceleration: AngleDirection { angleVariation: 360; magnitude: 200 } - } - } - - states: [ - State{ name: "AliveState"; when: dying == false - PropertyChanges { target: img; opacity: 1 } - }, - State{ name: "DeathState"; when: dying == true - StateChangeScript { script: particles.burst(50); } - PropertyChanges { target: img; opacity: 0 } - } - ] - transitions: [ - Transition { - NumberAnimation { target: img; property: "opacity"; duration: 100 } - } - ] -} diff --git a/examples/declarative/snake/content/HighScoreModel.qml b/examples/declarative/snake/content/HighScoreModel.qml deleted file mode 100644 index af66b99ede..0000000000 --- a/examples/declarative/snake/content/HighScoreModel.qml +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.LocalStorage 2.0 as Sql - -// Models a high score table. -// -// Use this component like this: -// -// HighScoreModel { -// id: highScores -// game: "MyCoolGame" -// } -// -// Then use either use the top-score properties: -// -// Text { text: "HI: " + highScores.topScore } -// -// or, use the model in a view: -// -// ListView { -// model: highScore -// delegate: Component { -// ... player ... score ... -// } -// } -// -// Add new scores via: -// -// saveScore(newScore) -// -// or: -// -// savePlayerScore(playerName,newScore) -// -// The best maxScore scores added by this method will be retained in an SQL database, -// and presented in the model and in the topScore/topPlayer properties. -// - -ListModel { - id: model - property string game: "" - property int topScore: 0 - property string topPlayer: "" - property int maxScores: 10 - - function __db() - { - return Sql.openDatabaseSync("HighScoreModel", "1.0", "Generic High Score Functionality for QML", 1000000); - } - function __ensureTables(tx) - { - tx.executeSql('CREATE TABLE IF NOT EXISTS HighScores(game TEXT, score INT, player TEXT)', []); - } - - function fillModel() { - __db().transaction( - function(tx) { - __ensureTables(tx); - var rs = tx.executeSql("SELECT score,player FROM HighScores WHERE game=? ORDER BY score DESC", [game]); - model.clear(); - if (rs.rows.length > 0) { - topScore = rs.rows.item(0).score - topPlayer = rs.rows.item(0).player - for (var i=0; i maxScores) - tx.executeSql("DELETE FROM HighScores WHERE game=? AND score <= ?", - [game, rs.rows.item(maxScores).score]); - } - } - ) - } - - function savePlayerScore(player,score) { - __db().transaction( - function(tx) { - __ensureTables(tx); - tx.executeSql("INSERT INTO HighScores VALUES(?,?,?)", [game,score,player]); - fillModel(); - } - ) - } - - function saveScore(score) { - savePlayerScore("player",score); - } - - function clearScores() { - __db().transaction( - function(tx) { - tx.executeSql("DELETE FROM HighScores WHERE game=?", [game]); - fillModel(); - } - ) - } - - Component.onCompleted: { fillModel() } -} diff --git a/examples/declarative/snake/content/Link.qml b/examples/declarative/snake/content/Link.qml deleted file mode 100644 index 891adafe5e..0000000000 --- a/examples/declarative/snake/content/Link.qml +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Item { id:link - property bool dying: false - property bool spawned: false - property int type: 0 - property int row: 0 - property int column: 0 - property int rotation; - - width: 40; - height: 40 - - x: margin - 3 + gridSize * column - y: margin - 3 + gridSize * row - Behavior on x { NumberAnimation { duration: spawned ? heartbeatInterval : 0} } - Behavior on y { NumberAnimation { duration: spawned ? heartbeatInterval : 0 } } - - - Item { - id: img - anchors.fill: parent - Image { - source: { - if(type == 1) { - "pics/blueStone.png"; - } else if (type == 2) { - "pics/head.png"; - } else { - "pics/redStone.png"; - } - } - - transform: Rotation { - id: actualImageRotation - origin.x: width/2; origin.y: height/2; - angle: rotation * 90 - Behavior on angle { - RotationAnimation{ - direction: RotationAnimation.Shortest - duration: spawned ? 200 : 0 - } - } - } - } - - Image { - source: "pics/stoneShadow.png" - } - - opacity: 0 - } - - ParticleSystem { - width:1; height:1; anchors.centerIn: parent; - ImageParticle { - groups: ["star"] - source: type == 1 ? "pics/blueStar.png" : "pics/redStar.png" - } - Emitter { - id: particles - anchors.fill: parent - group: "star" - emitRate: 50 - enabled: false - lifeSpan: 700 - acceleration: AngleDirection { angleVariation: 360; magnitude: 200 } - } - } - - states: [ - State{ name: "AliveState"; when: spawned == true && dying == false - PropertyChanges { target: img; opacity: 1 } - }, - State{ name: "DeathState"; when: dying == true - StateChangeScript { script: particles.burst(50); } - PropertyChanges { target: img; opacity: 0 } - } - ] - - transitions: [ - Transition { - NumberAnimation { target: img; property: "opacity"; duration: 200 } - } - ] - -} diff --git a/examples/declarative/snake/content/Skull.qml b/examples/declarative/snake/content/Skull.qml deleted file mode 100644 index ce3d108e04..0000000000 --- a/examples/declarative/snake/content/Skull.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - property bool spawned: false - property int row; - property int column; - property int verticalMovement; - property int horizontalMovement; - - x: margin + column * gridSize + 2 - y: margin + row * gridSize - 3 - Behavior on x { NumberAnimation { duration: spawned ? halfbeatInterval : 0} } - Behavior on y { NumberAnimation { duration: spawned ? halfbeatInterval : 0 } } - - opacity: spawned ? 1 : 0 - Behavior on opacity { NumberAnimation { duration: 200 } } - - source: "pics/skull.png" - width: 24 - height: 40 -} diff --git a/examples/declarative/snake/content/pics/README b/examples/declarative/snake/content/pics/README deleted file mode 100644 index 0215132caa..0000000000 --- a/examples/declarative/snake/content/pics/README +++ /dev/null @@ -1 +0,0 @@ -snake.jpg: This image is based on the picture "Eastern Green Mamba.jpg" from the free media databse Wikimedia Commons and is published under the terms of the GNU Free Documentation License. The original picture was taken by Danleo. diff --git a/examples/declarative/snake/content/pics/background.png b/examples/declarative/snake/content/pics/background.png deleted file mode 100644 index 72dffaa843..0000000000 Binary files a/examples/declarative/snake/content/pics/background.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/blueStar.png b/examples/declarative/snake/content/pics/blueStar.png deleted file mode 100644 index ba7acabd26..0000000000 Binary files a/examples/declarative/snake/content/pics/blueStar.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/blueStone.png b/examples/declarative/snake/content/pics/blueStone.png deleted file mode 100644 index 356affdd95..0000000000 Binary files a/examples/declarative/snake/content/pics/blueStone.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/cookie.png b/examples/declarative/snake/content/pics/cookie.png deleted file mode 100644 index aec2957f34..0000000000 Binary files a/examples/declarative/snake/content/pics/cookie.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/eyes.svg b/examples/declarative/snake/content/pics/eyes.svg deleted file mode 100644 index 1078692725..0000000000 --- a/examples/declarative/snake/content/pics/eyes.svg +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - image/svg+xml - - - - - - - - - - - - - - diff --git a/examples/declarative/snake/content/pics/head.png b/examples/declarative/snake/content/pics/head.png deleted file mode 100644 index 550e002687..0000000000 Binary files a/examples/declarative/snake/content/pics/head.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/pause.png b/examples/declarative/snake/content/pics/pause.png deleted file mode 100644 index 056d97dd17..0000000000 Binary files a/examples/declarative/snake/content/pics/pause.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/redStar.png b/examples/declarative/snake/content/pics/redStar.png deleted file mode 100644 index cd06854719..0000000000 Binary files a/examples/declarative/snake/content/pics/redStar.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/redStone.png b/examples/declarative/snake/content/pics/redStone.png deleted file mode 100644 index 9bb7fe4277..0000000000 Binary files a/examples/declarative/snake/content/pics/redStone.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/skull.png b/examples/declarative/snake/content/pics/skull.png deleted file mode 100644 index 63186167bd..0000000000 Binary files a/examples/declarative/snake/content/pics/skull.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/snake.jpg b/examples/declarative/snake/content/pics/snake.jpg deleted file mode 100644 index e91a784f71..0000000000 Binary files a/examples/declarative/snake/content/pics/snake.jpg and /dev/null differ diff --git a/examples/declarative/snake/content/pics/star.png b/examples/declarative/snake/content/pics/star.png deleted file mode 100644 index defbde53ca..0000000000 Binary files a/examples/declarative/snake/content/pics/star.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/stoneShadow.png b/examples/declarative/snake/content/pics/stoneShadow.png deleted file mode 100644 index 1bd56afd04..0000000000 Binary files a/examples/declarative/snake/content/pics/stoneShadow.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/yellowStar.png b/examples/declarative/snake/content/pics/yellowStar.png deleted file mode 100644 index 52fb9c4b78..0000000000 Binary files a/examples/declarative/snake/content/pics/yellowStar.png and /dev/null differ diff --git a/examples/declarative/snake/content/pics/yellowStone.png b/examples/declarative/snake/content/pics/yellowStone.png deleted file mode 100644 index c56124a895..0000000000 Binary files a/examples/declarative/snake/content/pics/yellowStone.png and /dev/null differ diff --git a/examples/declarative/snake/content/snake.js b/examples/declarative/snake/content/snake.js deleted file mode 100644 index 107c9f4591..0000000000 --- a/examples/declarative/snake/content/snake.js +++ /dev/null @@ -1,316 +0,0 @@ - -var snake = new Array; -var board = new Array; -var links = new Array; -var scheduledDirections = new Array; -var numRows = 1; -var numColumns = 1; -var linkComponent = Qt.createComponent("Link.qml"); -var cookieComponent = Qt.createComponent("Cookie.qml"); -var cookie; -var linksToGrow = 0; -var linksToDie = 0; -var waitForCookie = 0; -var growType = 0; -var skullMovementsBeforeDirectionChange = 0; - - -function rand(n) -{ - return (Math.floor(Math.random() * n)); -} - -function scheduleDirection(dir) -{ - if (state == "starting") { - direction = dir; - headDirection = direction; - head.rotation = headDirection; - } else if (state == "running"){ - direction = dir; - if(scheduledDirections[scheduledDirections.length-1]!=direction) - scheduledDirections.push(direction); - } -} - -function startNewGame() -{ - if (state == "starting") { - return; - } - - if (activeGame) { - endGame(); - startNewGameTimer.running = true; - return; - } - - state = "starting"; - - numRows = numRowsAvailable; - numColumns = numColumnsAvailable; - board = new Array(numRows * numColumns); - snake = new Array; - scheduledDirections = new Array; - growType = 0; - - skull.z = numRows * numColumns + 1; - - for (var i = 0; i < numRows * numColumns; ++i) { - if (i < links.length) { - var link = links[i]; - link.spawned = false; - link.dying = false; - } else { - if(linkComponent.status != Component.Ready) { - if(linkComponent.status == Component.Error) - console.log(linkComponent.errorString()); - else - console.log("Still loading linkComponent"); - continue;//TODO: Better error handling? - } - var link = linkComponent.createObject(playfield); - link.z = numRows * numColumns + 1 - i; - link.type = i == 0 ? 2 : 0; - link.spawned = false; - link.dying = false; - links.push(link); - } - } - - head = links[0]; - snake.push(head); - head.row = numRows/2 -1; - head.column = numColumns/2 -1; - head.spawned = true; - - linksToGrow = 5; - linksToDie = 0; - waitForCookie = 5; - score = 0; - startHeartbeatTimer.running = true; -} - -function endGame() -{ - activeGame = false; - for(var i in snake) - snake[i].dying = true; - if (cookie) { - cookie.dying = true; - cookie = 0; - } - lastScore = score; - highScores.saveScore(lastScore); - state = ""; -} - -function move() { - - if (!head) - return; - - var dir = direction; - - if (scheduledDirections.length) { - dir = scheduledDirections.shift(); - } - - if (state == "starting") { - var turn = (dir - headDirection); - head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); - headDirection = dir; - return; - } - - var row = head.row; - var column = head.column; - - if (dir == 0) { - row = row - 1; - } else if (dir == 1) { - column = column + 1 - } else if (dir == 2) { - row = row + 1; - } else if (dir == 3) { - column = column - 1; - } - - //validate the new position - if (row < 0 || row >= numRows - || column < 0 || column >= numColumns - || (row == skull.row && column == skull.column) - || !isFree(row, column)) { - var turn = (dir - headDirection); - head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); - headDirection = dir; - endGame(); - return; - } - - var newLink; - if (linksToGrow > 0) { - --linksToGrow; - newLink = links[snake.length]; - newLink.spawned = false; - newLink.rotation = snake[snake.length-1].rotation; - newLink.type = growType; - newLink.dying = false; - snake.push(newLink); - } else { - var lastLink = snake[snake.length-1]; - board[lastLink.row * numColumns + lastLink.column] = undefined; - } - - if (waitForCookie > 0) { - if (--waitForCookie == 0) - createCookie(cookie? (cookie.value+1) : 1); - } - - for (var i = snake.length-1; i > 0; --i) { - snake[i].row = snake[i-1].row; - snake[i].column = snake[i-1].column; - snake[i].rotation = snake[i-1].rotation; - } - - if (newLink) { - newLink.spawned = true; - } - - // move the head - head.row = row; - head.column = column; - board[row * numColumns + column] = head; - - var turn = (dir - headDirection); - head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); - headDirection = dir; - - var value = testCookie(row, column); - if (value > 0) { - linksToGrow += value; - score += value; - } -} - -function isFree(row, column) -{ - return board[row * numColumns + column] == undefined; -} - -function isHead(row, column) -{ - return head.column == column && head.row == row; -} - -function testCookie(row, column) -{ - if (cookie && !cookie.dying && cookie.row == row && cookie.column == column) { - var value = cookie.value; - waitForCookie = value; - growType = snake[snake.length-1].type == 1 ? 0 : 1; - cookie.dying = true; - cookie.z = numRows * numColumns + 2; - return value; - } - return 0; -} - -function moveSkull() -{ - - if (linksToDie > 0) { - --linksToDie; - var link = snake.pop(); - link.dying = true; - board[link.row * numColumns + link.column] = undefined; - if (score > 0) - --score; - if (snake.length == 0) { - endGame(); - return; - } - } - - var row = skull.row; - var column = skull.column; - if (isHead(row, column)) { - endGame(); - return; - } - row += skull.verticalMovement; - column += skull.horizontalMovement; - - var attempts = 4; - - while (skullMovementsBeforeDirectionChange == 0 || row < 0 || row >= numRows - || column < 0 || column >= numColumns - || (!isFree(row, column) && !isHead(row, column))) { - var d = rand(8); - skull.verticalMovement = 0; - skull.horizontalMovement = 0; - skullMovementsBeforeDirectionChange = rand(20)+1; - if (d == 0) { - skull.verticalMovement = -1 - } else if (d == 1) { - skull.horizontalMovement = -1; - } else if (d == 2) { - skull.verticalMovement = 1 - } else if (d == 3){ - skull.horizontalMovement = 1; - } else if (cookie) { - var rd = cookie.row - skull.row; - var rc = cookie.column - skull.column; - if (Math.abs(rd) > Math.abs(rc)) { - skull.verticalMovement = rd > 0 ? 1 : -1; - skullMovementsBeforeDirectionChange = Math.abs(rd); - } else { - skull.horizontalMovement= rc > 0 ? 1 : -1; - skullMovementsBeforeDirectionChange = Math.abs(rc); - } - } - row = skull.row + skull.verticalMovement; - column = skull.column + skull.horizontalMovement; - if (--attempts == 0) - return; - } - - skull.row = row; - skull.column = column; - --skullMovementsBeforeDirectionChange; - var value = testCookie(row, column); - if (value > 0) - linksToDie += value/2; - - if (isHead(row, column)) - endGame(); -} - -function createCookie(value) { - if (numRows * numColumns - snake.length < 10) - return; - - var column = rand(numColumns); - var row = rand(numRows); - while (!isFree(row, column)) { - column++; - if (column == numColumns) { - column = 0; - row++; - if (row == numRows) - row = 0; - } - } - - if(cookieComponent.status != Component.Ready) { - if(cookieComponent.status == Component.Error) - console.log(cookieComponent.errorString()); - else - console.log("Still loading cookieComponent"); - return;//TODO: Better error handling? - } - cookie = cookieComponent.createObject(head.parent); - cookie.value = value; - cookie.row = row; - cookie.column = column; -} diff --git a/examples/declarative/snake/snake.qml b/examples/declarative/snake/snake.qml deleted file mode 100644 index f25b626d02..0000000000 --- a/examples/declarative/snake/snake.qml +++ /dev/null @@ -1,272 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" as Content -import "content/snake.js" as Logic - -Rectangle { - id: screen; - SystemPalette { id: activePalette } - color: activePalette.window - property bool activeGame: false - - property int gridSize : 34 - property int margin: 4 - property int numRowsAvailable: Math.floor((height-32-2*margin)/gridSize) - property int numColumnsAvailable: Math.floor((width-2*margin)/gridSize) - - property int lastScore : 0 - - property int score: 0; - property int heartbeatInterval: 200 - property int halfbeatInterval: 160 - - width: 480 - height: 750 - - property int direction - property int headDirection - - property variant head; - - Content.HighScoreModel { - id: highScores - game: "Snake" - } - - Timer { - id: heartbeat; - interval: heartbeatInterval; - running: activeGame - repeat: true - onTriggered: { Logic.move() } - } - Timer { - id: halfbeat; - interval: halfbeatInterval; - repeat: true - running: heartbeat.running - onTriggered: { Logic.moveSkull() } - } - Timer { - id: startNewGameTimer; - interval: 700; - onTriggered: { Logic.startNewGame(); } - } - - Timer { - id: startHeartbeatTimer; - interval: 1000 ; - onTriggered: { state = "running"; activeGame = true; } - } - - Image{ - id: pauseDialog - z: 1 - source: "content/pics/pause.png" - anchors.centerIn: parent; - //opacity is deliberately not animated - opacity: 0 //Was !Qt.application.active && activeGame, but application doesn't work (QTBUG-23331) - } - - Image { - - Image { - id: title - source: "content/pics/snake.jpg" - fillMode: Image.PreserveAspectCrop - anchors.fill: parent - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - - Column { - spacing: 140 - anchors.verticalCenter: parent.verticalCenter; - anchors.left: parent.left; - anchors.right: parent.right; - - Text { - color: "white" - font.pointSize: 48 - font.italic: true; - font.bold: true; - text: "Snake" - anchors.horizontalCenter: parent.horizontalCenter; - } - - Text { - color: "white" - font.pointSize: 24 - anchors.horizontalCenter: parent.horizontalCenter; - //horizontalAlignment: Text.AlignHCenter - text: "Last Score:\t" + lastScore + "\nHighscore:\t" + highScores.topScore; - } - } - } - - source: "content/pics/background.png" - fillMode: Image.PreserveAspectCrop - - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: toolbar.top - - Rectangle { - id: playfield - border.width: 1 - border.color: "white" - color: "transparent" - anchors.horizontalCenter: parent.horizontalCenter - y: (screen.height - 32 - height)/2; - width: numColumnsAvailable * gridSize + 2*margin - height: numRowsAvailable * gridSize + 2*margin - - - Content.Skull { - id: skull - } - - MouseArea { - anchors.fill: parent - onPressed: { - if (screen.state == "") { - Logic.startNewGame(); - return; - } - if (direction == 0 || direction == 2) - Logic.scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3); - else - Logic.scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0); - } - } - } - - } - - Rectangle { - id: progressBar - opacity: 0 - Behavior on opacity { NumberAnimation { duration: 200 } } - color: "transparent" - border.width: 2 - border.color: "#221edd" - x: 50 - y: 50 - width: 200 - height: 30 - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: 40 - - Rectangle { - id: progressIndicator - color: "#221edd"; - width: 0; - height: 30; - } - } - - Rectangle { - id: toolbar - color: activePalette.window - height: 32; width: parent.width - anchors.bottom: screen.bottom - - Content.Button { - id: btnA; text: "New Game"; onClicked: Logic.startNewGame(); - anchors.left: parent.left; anchors.leftMargin: 3 - anchors.verticalCenter: parent.verticalCenter - } - - Content.Button { - text: "Quit" - anchors { left: btnA.right; leftMargin: 3; verticalCenter: parent.verticalCenter } - onClicked: Qt.quit(); - } - - Text { - color: activePalette.text - text: "Score: " + score; font.bold: true - anchors.right: parent.right; anchors.rightMargin: 3 - anchors.verticalCenter: parent.verticalCenter - } - } - - focus: true - Keys.onSpacePressed: Logic.startNewGame(); - Keys.onLeftPressed: if (state == "starting" || direction != 1) Logic.scheduleDirection(3); - Keys.onRightPressed: if (state == "starting" || direction != 3) Logic.scheduleDirection(1); - Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0); - Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2); - - states: [ - State { - name: "starting" - PropertyChanges {target: progressIndicator; width: 200} - PropertyChanges {target: title; opacity: 0} - PropertyChanges {target: progressBar; opacity: 1} - }, - State { - name: "running" - PropertyChanges {target: progressIndicator; width: 200} - PropertyChanges {target: title; opacity: 0} - PropertyChanges {target: skull; row: 0; column: 0; } - PropertyChanges {target: skull; spawned: 1} - } - ] - - transitions: [ - Transition { - from: "*" - to: "starting" - NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } - NumberAnimation { property: "opacity"; duration: 200 } - }, - Transition { - to: "starting" - NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } - NumberAnimation { property: "opacity"; duration: 200 } - } - ] - -} diff --git a/examples/declarative/snake/snake.qmlproject b/examples/declarative/snake/snake.qmlproject deleted file mode 100644 index fb015465d1..0000000000 --- a/examples/declarative/snake/snake.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "snake.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/sqllocalstorage/hello.qml b/examples/declarative/sqllocalstorage/hello.qml deleted file mode 100644 index 3496b86bd9..0000000000 --- a/examples/declarative/sqllocalstorage/hello.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 2.0 -import QtQuick.LocalStorage 2.0 as LS - -Rectangle { - color: "white" - width: 200 - height: 100 - - Text { - text: "?" - anchors.horizontalCenter: parent.horizontalCenter - function findGreetings() { - var db = LS.openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); - - db.transaction( - function(tx) { - // Create the database if it doesn't already exist - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - - // Add (another) greeting row - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - - // Show all added greetings - var rs = tx.executeSql('SELECT * FROM Greeting'); - - var r = "" - for(var i = 0; i < rs.rows.length; i++) { - r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" - } - text = r - } - ) - } - - Component.onCompleted: findGreetings() - } -} -//![0] diff --git a/examples/declarative/text/fonts/availableFonts.qml b/examples/declarative/text/fonts/availableFonts.qml deleted file mode 100644 index 0b87259556..0000000000 --- a/examples/declarative/text/fonts/availableFonts.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 480; height: 640; color: "steelblue" - - ListView { - anchors.fill: parent; model: Qt.fontFamilies() - - delegate: Item { - height: 40; width: ListView.view.width - Text { - anchors.centerIn: parent - text: modelData; font.family: modelData; font.pixelSize: 24; color: "white" - } - } - } -} diff --git a/examples/declarative/text/fonts/banner.qml b/examples/declarative/text/fonts/banner.qml deleted file mode 100644 index 6c9aa25fa1..0000000000 --- a/examples/declarative/text/fonts/banner.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: screen - - property int pixelSize: screen.height * 1.25 - property color textColor: "lightsteelblue" - property string text: "Hello world! " - - width: 640; height: 320 - color: "steelblue" - - Row { - y: -screen.height / 4.5 - - NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite } - Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - } -} diff --git a/examples/declarative/text/fonts/content/fonts/tarzeau_ocr_a.ttf b/examples/declarative/text/fonts/content/fonts/tarzeau_ocr_a.ttf deleted file mode 100644 index cf93f9651f..0000000000 Binary files a/examples/declarative/text/fonts/content/fonts/tarzeau_ocr_a.ttf and /dev/null differ diff --git a/examples/declarative/text/fonts/fonts.qml b/examples/declarative/text/fonts/fonts.qml deleted file mode 100644 index 78cef25eae..0000000000 --- a/examples/declarative/text/fonts/fonts.qml +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - property string myText: "The quick brown fox jumps over the lazy dog." - - width: 800; height: 480 - color: "steelblue" - - FontLoader { id: fixedFont; name: "Courier" } - FontLoader { id: localFont; source: "content/fonts/tarzeau_ocr_a.ttf" } - FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } - - Column { - anchors { fill: parent; leftMargin: 10; rightMargin: 10 } - spacing: 15 - - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideRight - font.family: "Times"; font.pointSize: 42 - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideLeft - font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideMiddle - font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideRight - font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideLeft - font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize } - } - Text { - text: { - if (webFont.status == FontLoader.Ready) myText - else if (webFont.status == FontLoader.Loading) "Loading..." - else if (webFont.status == FontLoader.Error) "Error loading font" - } - color: "lightsteelblue" - width: parent.width - elide: Text.ElideMiddle - font.family: webFont.name; font.pointSize: 42 - } - } -} diff --git a/examples/declarative/text/fonts/hello.qml b/examples/declarative/text/fonts/hello.qml deleted file mode 100644 index d9479fb208..0000000000 --- a/examples/declarative/text/fonts/hello.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: screen - - width: 800; height: 480 - color: "black" - - Item { - id: container - x: screen.width / 2; y: screen.height / 2 - - Text { - id: text - anchors.centerIn: parent - color: "white" - text: "Hello world!" - font.pixelSize: 60 - smooth: true - - SequentialAnimation on font.letterSpacing { - loops: Animation.Infinite; - NumberAnimation { from: 0; to: 150; easing.type: Easing.InQuad; duration: 3000 } - ScriptAction { - script: { - container.y = (screen.height / 4) + (Math.random() * screen.height / 2) - container.x = (screen.width / 4) + (Math.random() * screen.width / 2) - } - } - } - - SequentialAnimation on opacity { - loops: Animation.Infinite; - NumberAnimation { from: 1; to: 0; duration: 2600 } - PauseAnimation { duration: 400 } - } - } - } -} diff --git a/examples/declarative/text/imgtag/TextWithImage.qml b/examples/declarative/text/imgtag/TextWithImage.qml deleted file mode 100644 index bc09aa2a52..0000000000 --- a/examples/declarative/text/imgtag/TextWithImage.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Text { - width: parent.width - font.pointSize: 14 - wrapMode: Text.WordWrap - textFormat: Text.StyledText - horizontalAlignment: main.hAlign - - Rectangle { - border.color: "#efefef" - color: "transparent" - anchors.fill: parent - } -} diff --git a/examples/declarative/text/imgtag/images/face-sad.png b/examples/declarative/text/imgtag/images/face-sad.png deleted file mode 100644 index 24188b7985..0000000000 Binary files a/examples/declarative/text/imgtag/images/face-sad.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/images/face-smile-big.png b/examples/declarative/text/imgtag/images/face-smile-big.png deleted file mode 100644 index d05e0bf21e..0000000000 Binary files a/examples/declarative/text/imgtag/images/face-smile-big.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/images/face-smile.png b/examples/declarative/text/imgtag/images/face-smile.png deleted file mode 100644 index e5e1d1353c..0000000000 Binary files a/examples/declarative/text/imgtag/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/images/heart200.png b/examples/declarative/text/imgtag/images/heart200.png deleted file mode 100644 index cedd3ea608..0000000000 Binary files a/examples/declarative/text/imgtag/images/heart200.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/images/qtlogo.png b/examples/declarative/text/imgtag/images/qtlogo.png deleted file mode 100644 index 996719a4c6..0000000000 Binary files a/examples/declarative/text/imgtag/images/qtlogo.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/images/starfish_2.png b/examples/declarative/text/imgtag/images/starfish_2.png deleted file mode 100644 index 132c20ffd0..0000000000 Binary files a/examples/declarative/text/imgtag/images/starfish_2.png and /dev/null differ diff --git a/examples/declarative/text/imgtag/imgtag.qml b/examples/declarative/text/imgtag/imgtag.qml deleted file mode 100644 index 9d181af2cb..0000000000 --- a/examples/declarative/text/imgtag/imgtag.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: main - width: 320; height: 480 - focus: true - - property var hAlign: Text.AlignLeft - - Flickable { - anchors.fill: parent - contentWidth: parent.width - contentHeight: col.height + 20 - - Column { - id: col - x: 10; y: 10 - spacing: 20 - width: parent.width - 20 - - TextWithImage { - text: "This is a happy face" - } - TextWithImage { - text: "This is a veryhappy face aligned in the middle." - } - TextWithImage { - elide: Text.ElideRight - maximumLineCount: 2 - text: "This is a sad face aligned to the top. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatisLorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis." - } - TextWithImage { - text: "This is a tinyhappy face." - } - TextWithImage { - text: "This is a starfishaligned to the top and another onealigned to the bottom." - } - TextWithImage { - text: "Qt logosaligned in the middle with different sizes." - } - TextWithImage { - text: "Some hearts with different sizes." - } - TextWithImage { - text: "Resized imagefrom the internet." - } - TextWithImage { - text: "Imagefrom the internet." - } - TextWithImage { - height: 120 - verticalAlignment: Text.AlignVCenter - text: "This is a happy face with an explicit height." - } - } - } - - Keys.onUpPressed: main.hAlign = Text.AlignHCenter - Keys.onLeftPressed: main.hAlign = Text.AlignLeft - Keys.onRightPressed: main.hAlign = Text.AlignRight -} diff --git a/examples/declarative/text/styledtext-layout.qml b/examples/declarative/text/styledtext-layout.qml deleted file mode 100644 index 4571330568..0000000000 --- a/examples/declarative/text/styledtext-layout.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: main - width: 320; height: 480 - focus: true - - property real offset: 0 - property real margin: 10 - - Keys.onLeftPressed: myText.horizontalAlignment = Text.AlignLeft - Keys.onUpPressed: myText.horizontalAlignment = Text.AlignHCenter - Keys.onRightPressed: myText.horizontalAlignment = Text.AlignRight - Keys.onDownPressed: myText.horizontalAlignment = Text.AlignJustify - - Text { - id: myText - anchors.fill: parent - anchors.margins: 10 - wrapMode: Text.WordWrap - font.family: "Times New Roman" - font.pixelSize: 13 - textFormat: Text.StyledText - horizontalAlignment: Text.AlignJustify - - text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui sed eu egestas est facilis www.nokia.com.
          Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Phasellus id neque id velit facilisis cursus ac sit amet nibh. Donec enim arcu, pharetra non semper nec, iaculis eget elit. Nunc blandit condimentum odio vel egestas.
          • Coffee
            1. Espresso
            2. Cappuccino
            3. Flat White
            4. Latte
          • Juice
            1. Orange
            2. Apple
            3. Pineapple
            4. Tomato

          Proin consectetur sapien in ipsum lacinia sit amet mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Aenean ultricies lectus ut orci dictum quis convallis nisi ultrices. Nunc elit mi, iaculis a porttitor rutrum, venenatis malesuada nisi. Suspendisse turpis quam, euismod non imperdiet et, rutrum nec ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit." - - onLineLaidOut: { - line.width = width / 2 - (2 * margin) - if (line.number === 30) { - main.offset = line.y - } - if (line.number >= 30) { - line.x = width / 2 + margin - line.y -= main.offset - } - if ((line.y + line.height) > rect.y && line.y < (rect.y + rect.height)) { - if (line.number < 30) - line.width = Math.min((rect.x - line.x), line.width) - else { - line.x = Math.max((rect.x + rect.width), width / 2 + margin) - line.width = Math.min((width - margin - line.x), line.width) - } - } - } - - Item { - id: rect - x: 28; y: 20 - width: 60; height: 60 - - Rectangle { - anchors { fill: parent; leftMargin: 2; rightMargin: 2 } - color: "lightsteelblue"; opacity: 0.3 - } - - MouseArea { - anchors.fill: parent - drag.target: rect - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: mouse.button == Qt.RightButton ? myText.font.pixelSize -= 1 : myText.font.pixelSize += 1 - onPositionChanged: myText.doLayout() - } - } - } - -} diff --git a/examples/declarative/text/text.qml b/examples/declarative/text/text.qml deleted file mode 100644 index 14a88d2e91..0000000000 --- a/examples/declarative/text/text.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "../shared" - -Item { - height: 480 - width: 480 - LauncherList { - id: ll - anchors.fill: parent - Component.onCompleted: { - addExample("Hello", "An Animated Hello World", Qt.resolvedUrl("fonts/hello.qml")); - addExample("Fonts", "Using various fonts with a Text element", Qt.resolvedUrl("fonts/fonts.qml")); - addExample("Available Fonts", "A list of your available fonts", Qt.resolvedUrl("fonts/availableFonts.qml")); - addExample("Banner", "Large, scrolling text", Qt.resolvedUrl("fonts/banner.qml")); - } - } -} diff --git a/examples/declarative/text/text.qmlproject b/examples/declarative/text/text.qmlproject deleted file mode 100644 index c08d9b9a89..0000000000 --- a/examples/declarative/text/text.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "text.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/text/textselection/pics/endHandle.png b/examples/declarative/text/textselection/pics/endHandle.png deleted file mode 100644 index 1a4bc5d7a0..0000000000 Binary files a/examples/declarative/text/textselection/pics/endHandle.png and /dev/null differ diff --git a/examples/declarative/text/textselection/pics/endHandle.sci b/examples/declarative/text/textselection/pics/endHandle.sci deleted file mode 100644 index 4f51f24278..0000000000 --- a/examples/declarative/text/textselection/pics/endHandle.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 0 -border.top: 6 -border.bottom: 6 -border.right: 6 -source: endHandle.png diff --git a/examples/declarative/text/textselection/pics/startHandle.png b/examples/declarative/text/textselection/pics/startHandle.png deleted file mode 100644 index deedcd5c91..0000000000 Binary files a/examples/declarative/text/textselection/pics/startHandle.png and /dev/null differ diff --git a/examples/declarative/text/textselection/pics/startHandle.sci b/examples/declarative/text/textselection/pics/startHandle.sci deleted file mode 100644 index f9eae204c1..0000000000 --- a/examples/declarative/text/textselection/pics/startHandle.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 6 -border.top: 6 -border.bottom: 6 -border.right: 0 -source: startHandle.png diff --git a/examples/declarative/text/textselection/textselection.qml b/examples/declarative/text/textselection/textselection.qml deleted file mode 100644 index 7938ce5bf7..0000000000 --- a/examples/declarative/text/textselection/textselection.qml +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Rectangle { - id: editor - color: "lightGrey" - width: 640; height: 480 - - Rectangle { - color: "white" - anchors.fill: parent - anchors.margins: 20 - - BorderImage { - id: startHandle - source: "pics/startHandle.sci" - opacity: 0.0 - width: 10 - x: edit.positionToRectangle(edit.selectionStart).x - flick.contentX-width - y: edit.positionToRectangle(edit.selectionStart).y - flick.contentY - height: edit.positionToRectangle(edit.selectionStart).height - } - - BorderImage { - id: endHandle - source: "pics/endHandle.sci" - opacity: 0.0 - width: 10 - x: edit.positionToRectangle(edit.selectionEnd).x - flick.contentX - y: edit.positionToRectangle(edit.selectionEnd).y - flick.contentY - height: edit.positionToRectangle(edit.selectionEnd).height - } - - Flickable { - id: flick - - anchors.fill: parent - contentWidth: edit.paintedWidth - contentHeight: edit.paintedHeight - interactive: true - clip: true - - function ensureVisible(r) { - if (contentX >= r.x) - contentX = r.x; - else if (contentX+width <= r.x+r.width) - contentX = r.x+r.width-width; - if (contentY >= r.y) - contentY = r.y; - else if (contentY+height <= r.y+r.height) - contentY = r.y+r.height-height; - } - - TextEdit { - id: edit - width: flick.width - height: flick.height - focus: true - wrapMode: TextEdit.Wrap - textFormat: TextEdit.RichText - - onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) - - text: "

          Text Selection

          " - +"

          This example is a whacky text selection mechanisms, showing how these can be implemented in the TextEdit element, to cater for whatever style is appropriate for the target platform." - +"

          Press-and-hold to select a word, then drag the selection handles." - +"

          Drag outside the selection to scroll the text." - +"

          Click inside the selection to cut/copy/paste/cancel selection." - +"

          It's too whacky to let you paste if there is no current selection." - - } - } - - Item { - id: menu - opacity: 0.0 - width: 100 - height: 120 - anchors.centerIn: parent - - Rectangle { - border.width: 1 - border.color: "darkBlue" - radius: 15 - color: "#806080FF" - anchors.fill: parent - } - - Column { - anchors.centerIn: parent - spacing: 8 - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Cut" } - - MouseArea { - anchors.fill: parent - onClicked: { edit.cut(); editor.state = "" } - } - } - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Copy" } - - MouseArea { - anchors.fill: parent - onClicked: { edit.copy(); editor.state = "selection" } - } - } - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Paste" } - - MouseArea { - anchors.fill: parent - onClicked: { edit.paste(); edit.cursorPosition = edit.selectionEnd; editor.state = "" } - } - } - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Deselect" } - - MouseArea { - anchors.fill: parent - onClicked: { - edit.cursorPosition = edit.selectionEnd; - edit.deselect(); - editor.state = "" - } - } - } - } - } - } - - states: [ - State { - name: "selection" - PropertyChanges { target: startHandle; opacity: 1.0 } - PropertyChanges { target: endHandle; opacity: 1.0 } - }, - State { - name: "menu" - PropertyChanges { target: startHandle; opacity: 0.5 } - PropertyChanges { target: endHandle; opacity: 0.5 } - PropertyChanges { target: menu; opacity: 1.0 } - } - ] -} diff --git a/examples/declarative/threading/threadedlistmodel/dataloader.js b/examples/declarative/threading/threadedlistmodel/dataloader.js deleted file mode 100644 index 4d2aab323d..0000000000 --- a/examples/declarative/threading/threadedlistmodel/dataloader.js +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -WorkerScript.onMessage = function(msg) { - if (msg.action == 'appendCurrentTime') { - var data = {'time': new Date().toTimeString()}; - msg.model.append(data); - msg.model.sync(); // updates the changes to the list - } -} -// ![0] diff --git a/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject deleted file mode 100644 index e7c8e69f14..0000000000 --- a/examples/declarative/threading/threadedlistmodel/threadedlistmodel.qmlproject +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QmlProject 1.1 - -Project { - mainFile: "timedisplay.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/threading/threadedlistmodel/timedisplay.qml b/examples/declarative/threading/threadedlistmodel/timedisplay.qml deleted file mode 100644 index 48d0f659e5..0000000000 --- a/examples/declarative/threading/threadedlistmodel/timedisplay.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -import QtQuick 2.0 - -Rectangle { - color: "white" - width: 200 - height: 300 - - ListView { - anchors.fill: parent - model: listModel - delegate: Component { - Text { text: time } - } - - ListModel { id: listModel } - - WorkerScript { - id: worker - source: "dataloader.js" - } - - Timer { - id: timer - interval: 2000; repeat: true - running: true - triggeredOnStart: true - - onTriggered: { - var msg = {'action': 'appendCurrentTime', 'model': listModel}; - worker.sendMessage(msg); - } - } - } -} -// ![0] diff --git a/examples/declarative/threading/workerscript/workerscript.js b/examples/declarative/threading/workerscript/workerscript.js deleted file mode 100644 index f76471f920..0000000000 --- a/examples/declarative/threading/workerscript/workerscript.js +++ /dev/null @@ -1,15 +0,0 @@ -var lastx = 0; -var lasty = 0; - -WorkerScript.onMessage = function(message) { - var ydiff = message.y - lasty; - var xdiff = message.x - lastx; - - var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); - - lastx = message.x; - lasty = message.y; - - WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); -} - diff --git a/examples/declarative/threading/workerscript/workerscript.qml b/examples/declarative/threading/workerscript/workerscript.qml deleted file mode 100644 index 7fced8166c..0000000000 --- a/examples/declarative/threading/workerscript/workerscript.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 480; height: 320 - - WorkerScript { - id: myWorker - source: "workerscript.js" - - onMessage: { - console.log("Moved " + messageObject.xmove + " along the X axis."); - console.log("Moved " + messageObject.ymove + " along the Y axis."); - console.log("Moved " + messageObject.move + " pixels."); - } - } - - Rectangle { - width: 200; height: 200 - anchors.left: parent.left; anchors.leftMargin: 20 - color: "red" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); - } - } - - Rectangle { - width: 200; height: 200 - anchors.right: parent.right; anchors.rightMargin: 20 - color: "blue" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); - } - } - - Text { - text: "Click a Rectangle!" - anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } - } -} diff --git a/examples/declarative/threading/workerscript/workerscript.qmlproject b/examples/declarative/threading/workerscript/workerscript.qmlproject deleted file mode 100644 index 6d7a91feeb..0000000000 --- a/examples/declarative/threading/workerscript/workerscript.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "workerscript.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/touchinteraction/mousearea/mousearea-example.qml b/examples/declarative/touchinteraction/mousearea/mousearea-example.qml deleted file mode 100644 index 30e3e62864..0000000000 --- a/examples/declarative/touchinteraction/mousearea/mousearea-example.qml +++ /dev/null @@ -1,176 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: box - width: 400; height: 300 - - Rectangle { - id: redSquare - width: 120; height: 120 - anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10 - color: "red" - - Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - property string buttonID - - acceptedButtons: Qt.AllButtons - // Value 'All.Buttons' is eqivalent to: - // 'Qt::LeftButton | Qt::RightButton | Qt::MiddleButton .... | Qt::ExtraButton24' - - onEntered: info.text = 'Entered' - onExited: info.text = 'Exited (pressed=' + pressed + ')' - - onPressed: { - if (mouse.button == Qt.LeftButton) - buttonID = 'LeftButton' - else if (mouse.button == Qt.RightButton) - buttonID = 'RightButton' - else if (mouse.button == Qt.MidButton) - buttonID = 'MiddleButton' - else if (mouse.button == Qt.BackButton) - buttonID = 'BackButton' - else if (mouse.button == Qt.ForwardButton) - buttonID = 'ForwardButton' - else if (mouse.button == Qt.TaskButton) - buttonID = 'TaskButton' - else if (mouse.button == Qt.ExtraButton4) - buttonID = 'ExtraButton4' - else if (mouse.button == Qt.ExtraButton5) - buttonID = 'ExtraButton5' - else if (mouse.button == Qt.ExtraButton6) - buttonID = 'ExtraButton6' - else if (mouse.button == Qt.ExtraButton7) - buttonID = 'ExtraButton7' - else if (mouse.button == Qt.ExtraButton8) - buttonID = 'ExtraButton8' - else if (mouse.button == Qt.ExtraButton9) - buttonID = 'ExtraButton9' - else if (mouse.button == Qt.ExtraButton10) - buttonID = 'ExtraButton10' - else if (mouse.button == Qt.ExtraButton11) - buttonID = 'ExtraButton11' - else if (mouse.button == Qt.ExtraButton12) - buttonID = 'ExtraButton12' - else if (mouse.button == Qt.ExtraButton13) - buttonID = 'ExtraButton13' - else if (mouse.button == Qt.ExtraButton14) - buttonID = 'ExtraButton14' - else if (mouse.button == Qt.ExtraButton15) - buttonID = 'ExtraButton15' - else if (mouse.button == Qt.ExtraButton16) - buttonID = 'ExtraButton16' - else if (mouse.button == Qt.ExtraButton17) - buttonID = 'ExtraButton17' - else if (mouse.button == Qt.ExtraButton18) - buttonID = 'ExtraButton18' - else if (mouse.button == Qt.ExtraButton19) - buttonID = 'ExtraButton19' - else if (mouse.button == Qt.ExtraButton20) - buttonID = 'ExtraButton20' - else if (mouse.button == Qt.ExtraButton21) - buttonID = 'ExtraButton21' - else if (mouse.button == Qt.ExtraButton22) - buttonID = 'ExtraButton22' - else if (mouse.button == Qt.ExtraButton23) - buttonID = 'ExtraButton23' - else if (mouse.button == Qt.ExtraButton24) - buttonID = 'ExtraButton24' - - info.text = 'Pressed (' + buttonID + ' shift=' - + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')' - var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y) - posInfo.text = + mouse.x + ',' + mouse.y + ' in square' - + ' (' + posInBox.x + ',' + posInBox.y + ' in window)' - } - - onReleased: { - btn.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')' - posInfo.text = '' - } - - onPressAndHold: btn.text = 'Press and hold' - onClicked: btn.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')' - onDoubleClicked: btn.text = 'Double clicked' - } - } - - Rectangle { - id: blueSquare - width: 120; height: 120 - x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors - color: "blue" - - Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - drag.target: blueSquare - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: box.width - parent.width - drag.minimumY: 0 - drag.maximumY: box.height - parent.width - } - } - - Text { - id: info - anchors.bottom: btn.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 - - onTextChanged: console.log(text) - } - - Text { - id: btn - anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 - } - - Text { - id: posInfo - anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 - } -} diff --git a/examples/declarative/touchinteraction/multipointtouch/bearwhack.qml b/examples/declarative/touchinteraction/multipointtouch/bearwhack.qml deleted file mode 100644 index db46473c05..0000000000 --- a/examples/declarative/touchinteraction/multipointtouch/bearwhack.qml +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content" - -Item { - id: root - height: 640 - width: 320 - Item { - id: startScreen - anchors.fill: parent - z: 1000 - Image { - source: "content/title.png" - anchors.centerIn: parent - } - MouseArea{ - anchors.fill: parent - onClicked: {//Game Start - parent.visible = false; - } - } - } - Rectangle { - id: bg - anchors.fill: parent - gradient: Gradient { - GradientStop { position: 0.0; color: "DarkBlue" } - GradientStop { position: 0.8; color: "SkyBlue" } - GradientStop { position: 0.81; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - BearWhackParticleSystem { - id: particleSystem - anchors.fill: parent - running: !startScreen.visible - } - - property int score: 0 - - Text { - anchors.right: parent.right - anchors.margins: 4 - anchors.top: parent.top - color: "white" - function padded(num) { - var ret = num.toString(); - while (ret.length < 6) - ret = "0" + ret; - return ret; - } - text: "Score: " + padded(score) - } - MultiPointTouchArea { - anchors.fill: parent - touchPoints: [//Support up to 4 touches at once? - AugmentedTouchPoint{ system: particleSystem }, - AugmentedTouchPoint{ system: particleSystem }, - AugmentedTouchPoint{ system: particleSystem }, - AugmentedTouchPoint{ system: particleSystem } - ] - } - MouseArea{ - anchors.fill: parent - id: ma - onPressedChanged: { - if (pressed) { - timer.restart(); - sgoal.enabled = true; - particleSystem.explode(mouseX,mouseY); - } - } - Timer { - id: timer - interval: 100 - running: false - repeat: false - onTriggered: sgoal.enabled = false - } - SpriteGoal { - id: sgoal - x: ma.mouseX - 16 - y: ma.mouseY - 16 - width: 32 - height: 32 - system: particleSystem - parent: particleSystem - goalState: "falling" - enabled: false - } - } -} diff --git a/examples/declarative/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml b/examples/declarative/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml deleted file mode 100644 index aede1a8f4e..0000000000 --- a/examples/declarative/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -TouchPoint { - id: container - property ParticleSystem system - onPressedChanged: { - if (pressed) { - timer.restart(); - child.enabled = true; - system.explode(x,y); - } - } - property QtObject obj: Timer { - id: timer - interval: 100 - running: false - repeat: false - onTriggered: child.enabled = false - } - property Item child: SpriteGoal { - enabled: false - x: container.area.x - 16 - y: container.area.y - 16 - width: container.area.width + 32 - height: container.area.height + 32 //+32 so it doesn't have to hit the exact center - system: container.system - parent: container.system - goalState: "falling" - } -} diff --git a/examples/declarative/touchinteraction/multipointtouch/content/Bear0.png b/examples/declarative/touchinteraction/multipointtouch/content/Bear0.png deleted file mode 100644 index 64a02cec8e..0000000000 Binary files a/examples/declarative/touchinteraction/multipointtouch/content/Bear0.png and /dev/null differ diff --git a/examples/declarative/touchinteraction/multipointtouch/content/Bear1.png b/examples/declarative/touchinteraction/multipointtouch/content/Bear1.png deleted file mode 100644 index 3b88f3b32e..0000000000 Binary files a/examples/declarative/touchinteraction/multipointtouch/content/Bear1.png and /dev/null differ diff --git a/examples/declarative/touchinteraction/multipointtouch/content/Bear2.png b/examples/declarative/touchinteraction/multipointtouch/content/Bear2.png deleted file mode 100644 index 337b636070..0000000000 Binary files a/examples/declarative/touchinteraction/multipointtouch/content/Bear2.png and /dev/null differ diff --git a/examples/declarative/touchinteraction/multipointtouch/content/Bear3.png b/examples/declarative/touchinteraction/multipointtouch/content/Bear3.png deleted file mode 100644 index f0e68590f4..0000000000 Binary files a/examples/declarative/touchinteraction/multipointtouch/content/Bear3.png and /dev/null differ diff --git a/examples/declarative/touchinteraction/multipointtouch/content/BearB.png b/examples/declarative/touchinteraction/multipointtouch/content/BearB.png deleted file mode 100644 index c9a84ae1d4..0000000000 Binary files a/examples/declarative/touchinteraction/multipointtouch/content/BearB.png and /dev/null differ diff --git a/examples/declarative/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml b/examples/declarative/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml deleted file mode 100644 index 05d74ab0ea..0000000000 --- a/examples/declarative/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -ParticleSystem { - id: particleSystem - function explode(x,y) { - fireEmitter.burst(100,x,y); - } - - Emitter { - id: emitter - group: "bears" - width: parent.width - emitRate: 1 - NumberAnimation on emitRate { - id: goFaster - from: 1 - to: 16 - running: particleSystem.running - loops: 1 - duration: 60000 * 5 - easing.type: Easing.Linear - } - lifeSpan: 4000 + 800*(16-emitRate) - maximumEmitted: 128 - size: 64 - speed: PointDirection{ y: 40 + 10 * emitter.emitRate } - } - - Emitter { - id: fireEmitter - enabled: false - maximumEmitted: 6000 - group: "flame" - emitRate: 1000 - size: 16 - endSize: 8 - speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 120;} PointDirection { y: -60 }} - lifeSpan: 400 - } - Emitter { - id: heartEmitter - enabled: false - maximumEmitted: 6000 - group: "hearts" - emitRate: 1000 - size: 16 - endSize: 8 - speed: AngleDirection {angleVariation: 180; magnitudeVariation: 180;} - lifeSpan: 600 - } - Emitter { - id: bloodEmitter - enabled: false - maximumEmitted: 6000 - group: "blood" - emitRate: 1000 - size: 16 - endSize: 8 - speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 80;} PointDirection { y: 40 }} - lifeSpan: 600 - } - - Affector { - width: parent.width - height: 64 - once: true - y: parent.height - 32 - groups: "bears" - onAffectParticles: { - for (var i=0;i= 200) - return ListView.view.width / Math.floor(ListView.view.width / 200.0); - else - return 200; - } - - height: { - if (ListView.view && ListView.view.height >= 240) - return ListView.view.height; - else - return 240; - } - - property alias city: cityLabel.text - property int hours - property int minutes - property int seconds - property real shift - property bool night: false - property bool internationalTime: true //Unset for local time - - function timeChanged() { - var date = new Date; - hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() - night = ( hours < 7 || hours > 19 ) - minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes() - seconds = date.getUTCSeconds(); - } - - Timer { - interval: 100; running: true; repeat: true; - onTriggered: clock.timeChanged() - } - - Item { - anchors.centerIn: parent - width: 200; height: 240 - - Image { id: background; source: "clock.png"; visible: clock.night == false } - Image { source: "clock-night.png"; visible: clock.night == true } - - - Image { - x: 92.5; y: 27 - source: "hour.png" - smooth: true - transform: Rotation { - id: hourRotation - origin.x: 7.5; origin.y: 73; - angle: (clock.hours * 30) + (clock.minutes * 0.5) - Behavior on angle { - SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - x: 93.5; y: 17 - source: "minute.png" - smooth: true - transform: Rotation { - id: minuteRotation - origin.x: 6.5; origin.y: 83; - angle: clock.minutes * 6 - Behavior on angle { - SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - x: 97.5; y: 20 - source: "second.png" - smooth: true - transform: Rotation { - id: secondRotation - origin.x: 2.5; origin.y: 80; - angle: clock.seconds * 6 - Behavior on angle { - SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - anchors.centerIn: background; source: "center.png" - } - - Text { - id: cityLabel - y: 210; anchors.horizontalCenter: parent.horizontalCenter - color: "white" - font.family: "Helvetica" - font.bold: true; font.pixelSize: 16 - style: Text.Raised; styleColor: "black" - } - } -} diff --git a/examples/declarative/toys/clocks/content/QuitButton.qml b/examples/declarative/toys/clocks/content/QuitButton.qml deleted file mode 100644 index 702b892d23..0000000000 --- a/examples/declarative/toys/clocks/content/QuitButton.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -Image { - source: "quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -10 - onClicked: Qt.quit() - } -} diff --git a/examples/declarative/toys/clocks/content/arrow.png b/examples/declarative/toys/clocks/content/arrow.png deleted file mode 100644 index e437312217..0000000000 Binary files a/examples/declarative/toys/clocks/content/arrow.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/background.png b/examples/declarative/toys/clocks/content/background.png deleted file mode 100644 index a885950862..0000000000 Binary files a/examples/declarative/toys/clocks/content/background.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/center.png b/examples/declarative/toys/clocks/content/center.png deleted file mode 100644 index 7fbd802a44..0000000000 Binary files a/examples/declarative/toys/clocks/content/center.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/clock-night.png b/examples/declarative/toys/clocks/content/clock-night.png deleted file mode 100644 index cc7151a397..0000000000 Binary files a/examples/declarative/toys/clocks/content/clock-night.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/clock.png b/examples/declarative/toys/clocks/content/clock.png deleted file mode 100644 index 462edacc0e..0000000000 Binary files a/examples/declarative/toys/clocks/content/clock.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/hour.png b/examples/declarative/toys/clocks/content/hour.png deleted file mode 100644 index f8061a1235..0000000000 Binary files a/examples/declarative/toys/clocks/content/hour.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/minute.png b/examples/declarative/toys/clocks/content/minute.png deleted file mode 100644 index 1297ec7c2b..0000000000 Binary files a/examples/declarative/toys/clocks/content/minute.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/quit.png b/examples/declarative/toys/clocks/content/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/declarative/toys/clocks/content/quit.png and /dev/null differ diff --git a/examples/declarative/toys/clocks/content/second.png b/examples/declarative/toys/clocks/content/second.png deleted file mode 100644 index 4aa9fb5e8e..0000000000 Binary files a/examples/declarative/toys/clocks/content/second.png and /dev/null differ diff --git a/examples/declarative/toys/corkboards/content/Day.qml b/examples/declarative/toys/corkboards/content/Day.qml deleted file mode 100644 index 7fe625c305..0000000000 --- a/examples/declarative/toys/corkboards/content/Day.qml +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Component { - Item { - property variant stickies - - id: page - width: ListView.view.width+40; height: ListView.view.height - - - Image { - source: "cork.jpg" - width: page.ListView.view.width - height: page.ListView.view.height - fillMode: Image.PreserveAspectCrop - clip: true - } - - MouseArea { - anchors.fill: parent - onClicked: page.focus = false; - } - - Text { - text: name; x: 15; y: 8; height: 40; width: 370 - font.pixelSize: 18; font.bold: true; color: "white" - style: Text.Outline; styleColor: "black" - } - - Repeater { - model: notes - Item { - id: stickyPage - - property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100 - property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50 - - x: randomX; y: randomY - - rotation: -flickable.horizontalVelocity / 100; - Behavior on rotation { - SpringAnimation { spring: 2.0; damping: 0.15 } - } - - Item { - id: sticky - scale: 0.7 - - Image { - id: stickyImage - x: 8 + -width * 0.6 / 2; y: -20 - source: "note-yellow.png" - scale: 0.6; transformOrigin: Item.TopLeft - smooth: true - } - - TextEdit { - id: myText - x: -104; y: 36; width: 215; height: 200 - smooth: true - font.pixelSize: 24 - readOnly: false - rotation: -8 - text: noteText - } - - Item { - x: stickyImage.x; y: -20 - width: stickyImage.width * stickyImage.scale - height: stickyImage.height * stickyImage.scale - - MouseArea { - id: mouse - anchors.fill: parent - drag.target: stickyPage - drag.axis: Drag.XandYAxis - drag.minimumY: 0 - drag.maximumY: page.height - 80 - drag.minimumX: 100 - drag.maximumX: page.width - 140 - onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); } - } - } - } - - Image { - x: -width / 2; y: -height * 0.5 / 2 - source: "tack.png" - scale: 0.7; transformOrigin: Item.TopLeft - } - - states: State { - name: "pressed" - when: mouse.pressed - PropertyChanges { target: sticky; rotation: 8; scale: 1 } - PropertyChanges { target: page; z: 8 } - } - - transitions: Transition { - NumberAnimation { properties: "rotation,scale"; duration: 200 } - } - } - } - } -} - - - - - - - - diff --git a/examples/declarative/toys/corkboards/content/cork.jpg b/examples/declarative/toys/corkboards/content/cork.jpg deleted file mode 100644 index 160bc002bf..0000000000 Binary files a/examples/declarative/toys/corkboards/content/cork.jpg and /dev/null differ diff --git a/examples/declarative/toys/corkboards/content/note-yellow.png b/examples/declarative/toys/corkboards/content/note-yellow.png deleted file mode 100644 index 8ddecc8b03..0000000000 Binary files a/examples/declarative/toys/corkboards/content/note-yellow.png and /dev/null differ diff --git a/examples/declarative/toys/corkboards/content/tack.png b/examples/declarative/toys/corkboards/content/tack.png deleted file mode 100644 index cef2d1cd23..0000000000 Binary files a/examples/declarative/toys/corkboards/content/tack.png and /dev/null differ diff --git a/examples/declarative/toys/corkboards/corkboards.qml b/examples/declarative/toys/corkboards/corkboards.qml deleted file mode 100644 index dc3aa6b378..0000000000 --- a/examples/declarative/toys/corkboards/corkboards.qml +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - width: 800; height: 480 - color: "#464646" - - ListModel { - id: list - - ListElement { - name: "Sunday" - notes: [ - ListElement { noteText: "Lunch" }, - ListElement { noteText: "Birthday Party" } - ] - } - - ListElement { - name: "Monday" - notes: [ - ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, - ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } - ] - } - - ListElement { - name: "Tuesday" - notes: [ - ListElement { noteText: "Walk dog" }, - ListElement { noteText: "Buy newspaper" } - ] - } - - ListElement { - name: "Wednesday" - notes: [ ListElement { noteText: "Cook dinner" } ] - } - - ListElement { - name: "Thursday" - notes: [ - ListElement { noteText: "Meeting\n5.30pm" }, - ListElement { noteText: "Weed garden" } - ] - } - - ListElement { - name: "Friday" - notes: [ - ListElement { noteText: "More work" }, - ListElement { noteText: "Grocery shopping" } - ] - } - - ListElement { - name: "Saturday" - notes: [ - ListElement { noteText: "Drink" }, - ListElement { noteText: "Download Qt\nPlay with QML" } - ] - } - } - - ListView { - id: flickable - - anchors.fill: parent - focus: true - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem - model: list - delegate: Day { } - } -} diff --git a/examples/declarative/toys/dynamicscene/content/Button.qml b/examples/declarative/toys/dynamicscene/content/Button.qml deleted file mode 100644 index 014692274a..0000000000 --- a/examples/declarative/toys/dynamicscene/content/Button.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property variant text - signal clicked - - height: text.height + 10; width: text.width + 20 - border.width: 1 - radius: 4 - smooth: true - - gradient: Gradient { - GradientStop { - position: 0.0 - color: !mouseArea.pressed ? activePalette.light : activePalette.button - } - GradientStop { - position: 1.0 - color: !mouseArea.pressed ? activePalette.button : activePalette.dark - } - } - - SystemPalette { id: activePalette } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked() - } - - Text { - id: text - anchors.centerIn:parent - font.pointSize: 10 - text: parent.text - color: activePalette.buttonText - } -} diff --git a/examples/declarative/toys/dynamicscene/content/GenericSceneItem.qml b/examples/declarative/toys/dynamicscene/content/GenericSceneItem.qml deleted file mode 100644 index 0408aa87fb..0000000000 --- a/examples/declarative/toys/dynamicscene/content/GenericSceneItem.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - property bool created: false - property string image - - source: image - -} diff --git a/examples/declarative/toys/dynamicscene/content/PaletteItem.qml b/examples/declarative/toys/dynamicscene/content/PaletteItem.qml deleted file mode 100644 index e993f89989..0000000000 --- a/examples/declarative/toys/dynamicscene/content/PaletteItem.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "itemCreation.js" as Code - -Image { - id: paletteItem - - property string componentFile - property string image - - source: image - - MouseArea { - anchors.fill: parent - - onPressed: Code.startDrag(mouse); - onPositionChanged: Code.continueDrag(mouse); - onReleased: Code.endDrag(mouse); - } -} diff --git a/examples/declarative/toys/dynamicscene/content/PerspectiveItem.qml b/examples/declarative/toys/dynamicscene/content/PerspectiveItem.qml deleted file mode 100644 index f651369452..0000000000 --- a/examples/declarative/toys/dynamicscene/content/PerspectiveItem.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: rootItem - - property bool created: false - property string image - - property double scaledBottom: y + (height + height*scale) / 2 - property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset) - - source: image - opacity: onLand ? 1 : 0.25 - scale: Math.max((y + height - 250) * 0.01, 0.3) - smooth: true - - onCreatedChanged: { - if (created && !onLand) - rootItem.destroy(); - else - z = scaledBottom; - } - - onYChanged: z = scaledBottom; -} diff --git a/examples/declarative/toys/dynamicscene/content/Sun.qml b/examples/declarative/toys/dynamicscene/content/Sun.qml deleted file mode 100644 index b84516eecc..0000000000 --- a/examples/declarative/toys/dynamicscene/content/Sun.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: sun - - property bool created: false - property string image: "images/sun.png" - - source: image - - // once item is created, start moving offscreen - NumberAnimation on y { - to: (window.height / 2) + window.centerOffset - running: created - onRunningChanged: { - if (running) - duration = (window.height + window.centerOffset - sun.y) * 10; - else - state = "OffScreen" - } - } - - states: State { - name: "OffScreen" - StateChangeScript { - script: { sun.created = false; sun.destroy() } - } - } - - onCreatedChanged: { - if (created) { - sun.z = 1; // above the sky but below the ground layer - window.activeSuns++; - } else { - window.activeSuns--; - } - } -} diff --git a/examples/declarative/toys/dynamicscene/content/images/NOTE b/examples/declarative/toys/dynamicscene/content/images/NOTE deleted file mode 100644 index fcd87f9132..0000000000 --- a/examples/declarative/toys/dynamicscene/content/images/NOTE +++ /dev/null @@ -1 +0,0 @@ -Images (except star.png) are from the KDE project. diff --git a/examples/declarative/toys/dynamicscene/content/images/face-smile.png b/examples/declarative/toys/dynamicscene/content/images/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/moon.png b/examples/declarative/toys/dynamicscene/content/images/moon.png deleted file mode 100644 index 1c0d6066a8..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/moon.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/rabbit_brown.png b/examples/declarative/toys/dynamicscene/content/images/rabbit_brown.png deleted file mode 100644 index ebfdeed332..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/rabbit_brown.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/rabbit_bw.png b/examples/declarative/toys/dynamicscene/content/images/rabbit_bw.png deleted file mode 100644 index 7bff9b92ca..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/rabbit_bw.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/star.png b/examples/declarative/toys/dynamicscene/content/images/star.png deleted file mode 100644 index 27ef924267..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/star.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/sun.png b/examples/declarative/toys/dynamicscene/content/images/sun.png deleted file mode 100644 index 7713ca5ce7..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/sun.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/images/tree_s.png b/examples/declarative/toys/dynamicscene/content/images/tree_s.png deleted file mode 100644 index 6eac35a729..0000000000 Binary files a/examples/declarative/toys/dynamicscene/content/images/tree_s.png and /dev/null differ diff --git a/examples/declarative/toys/dynamicscene/content/itemCreation.js b/examples/declarative/toys/dynamicscene/content/itemCreation.js deleted file mode 100644 index 40f5415f9f..0000000000 --- a/examples/declarative/toys/dynamicscene/content/itemCreation.js +++ /dev/null @@ -1,62 +0,0 @@ -var itemComponent = null; -var draggedItem = null; -var startingMouse; -var posnInWindow; - -function startDrag(mouse) -{ - posnInWindow = paletteItem.mapToItem(window, 0, 0); - startingMouse = { x: mouse.x, y: mouse.y } - loadComponent(); -} - -//Creation is split into two functions due to an asynchronous wait while -//possible external files are loaded. - -function loadComponent() { - if (itemComponent != null) { // component has been previously loaded - createItem(); - return; - } - - itemComponent = Qt.createComponent(paletteItem.componentFile); - if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately - component.statusChanged.connect(createItem); - else - createItem(); -} - -function createItem() { - if (itemComponent.status == Component.Ready && draggedItem == null) { - draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); - // make sure created item is above the ground layer - } else if (itemComponent.status == Component.Error) { - draggedItem = null; - console.log("error creating component"); - console.log(itemComponent.errorString()); - } -} - -function continueDrag(mouse) -{ - if (draggedItem == null) - return; - - draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; - draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; -} - -function endDrag(mouse) -{ - if (draggedItem == null) - return; - - if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox - draggedItem.destroy(); - draggedItem = null; - } else { - draggedItem.created = true; - draggedItem = null; - } -} - diff --git a/examples/declarative/toys/dynamicscene/dynamicscene.qml b/examples/declarative/toys/dynamicscene/dynamicscene.qml deleted file mode 100644 index e64eb0fd0f..0000000000 --- a/examples/declarative/toys/dynamicscene/dynamicscene.qml +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content" - -Item { - id: window - - property int activeSuns: 0 - property int centerOffset: 72 - - height: 480; width: 360 - - - MouseArea { - anchors.fill: parent - onClicked: window.focus = false; - } - - //This is the message box that pops up when there's an error - Rectangle { - id: dialog - - opacity: 0 - anchors.centerIn: parent - width: dialogText.width + 6; height: dialogText.height + 6 - border.color: 'black' - color: 'lightsteelblue' - z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. - - function show(str){ - dialogText.text = str; - dialogAnim.start(); - } - - Text { - id: dialogText - x: 3; y: 3 - font.pixelSize: 14 - } - - SequentialAnimation { - id: dialogAnim - NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } - PauseAnimation { duration: 5000 } - NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } - } - } - - Item { - id: scene - anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right} - z: 10 - } - - // sky - Rectangle { - id: sky - anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } - GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } - } - } - - // stars (when there's no sun) - ParticleSystem { - id: particlesystem - anchors.fill: sky - - ImageParticle { - id: stars - source: "content/images/star.png" - groups: ["stars"] - opacity: .5 - } - - Emitter { - id: starsemitter - anchors.fill: parent - emitRate: parent.width / 50 - lifeSpan: 5000 - group: "stars" - } - } - - // ground - Rectangle { - id: ground - z: 2 // just above the sun so that the sun can set behind it - anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - SystemPalette { id: activePalette } - - // right-hand panel - Rectangle { - id: toolbox - - height: centerOffset * 2 - color: activePalette.window - anchors { right: parent.right; top: parent.top; left: parent.left} - - Column { - anchors.centerIn: parent - spacing: 8 - - Text { text: "Drag an item into the scene." } - - Rectangle { - width: palette.width + 10; height: palette.height + 10 - border.color: "black" - - Row { - id: palette - anchors.centerIn: parent - spacing: 8 - - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "Sun.qml" - source: "content/images/sun.png" - image: "images/sun.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "GenericSceneItem.qml" - source: "content/images/moon.png" - image: "images/moon.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/tree_s.png" - image: "images/tree_s.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/rabbit_brown.png" - image: "images/rabbit_brown.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/rabbit_bw.png" - image: "images/rabbit_bw.png" - } - } - } - - Text { text: "Active Suns: " + activeSuns } - } - } - - //Popup toolbox down the bottom - Rectangle { - id: popupToolbox - z: 1000 - width: parent.width - height: popupColumn.height + 16 - color: activePalette.window - - property bool poppedUp: false - property int downY: window.height - (createButton.height + 16) - property int upY: window.height - (popupColumn.height + 16) - y: poppedUp ? upY : downY - Behavior on y { NumberAnimation {}} - - Column { - id: popupColumn - y: 8 - anchors.centerIn: parent - spacing: 8 - - Row { - height: createButton.height - spacing: 8 - Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } - Button { - id: popupButton - text: popupToolbox.poppedUp ? "Hide" : "Show" - onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp - } - Button { - id: createButton - text: "Create" - onClicked: { - try { - Qt.createQmlObject(qmlText.text, scene, 'CustomObject'); - } catch(err) { - dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); - } - } - } - - } - - Rectangle { - width: 360; height: 240 - - TextEdit { - id: qmlText - anchors.fill: parent; anchors.margins: 5 - readOnly: false - font.pixelSize: 14 - selectByMouse: true - wrapMode: TextEdit.WordWrap - - text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" - } - } - } - } - - //Day state, for when a sun is added to the scene - states: State { - name: "Day" - when: window.activeSuns > 0 - - PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } - PropertyChanges { target: gradientStopB; color: "SkyBlue" } - PropertyChanges { target: stars; opacity: 0 } - } - - //! [top-level transitions] - transitions: Transition { - PropertyAnimation { duration: 3000 } - ColorAnimation { duration: 3000 } - } - //! [top-level transitions] -} diff --git a/examples/declarative/toys/tic-tac-toe/content/Button.qml b/examples/declarative/toys/tic-tac-toe/content/Button.qml deleted file mode 100644 index 6dd141f838..0000000000 --- a/examples/declarative/toys/tic-tac-toe/content/Button.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text - property bool pressed: false - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 6 - border { width: 1; color: Qt.darker(container.color) } - radius: 8 - color: "lightgray" - smooth: true - - gradient: Gradient { - GradientStop { - position: 0.0 - color: container.pressed ? "darkgray" : "white" - } - GradientStop { - position: 1.0 - color: container.color - } - } - - MouseArea { - anchors.fill: parent - onClicked: container.clicked() - } - - Text { - id: buttonLabel - anchors.centerIn: container - text: container.text - font.pixelSize: 14 - } -} diff --git a/examples/declarative/toys/tic-tac-toe/content/TicTac.qml b/examples/declarative/toys/tic-tac-toe/content/TicTac.qml deleted file mode 100644 index e74bc6bcda..0000000000 --- a/examples/declarative/toys/tic-tac-toe/content/TicTac.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - signal clicked - - states: [ - State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } }, - State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } } - ] - - Image { - id: image - anchors.centerIn: parent - } - - MouseArea { - anchors.fill: parent - onClicked: parent.clicked() - } -} diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/board.png b/examples/declarative/toys/tic-tac-toe/content/pics/board.png deleted file mode 100644 index 7e5b7ba27c..0000000000 Binary files a/examples/declarative/toys/tic-tac-toe/content/pics/board.png and /dev/null differ diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/o.png b/examples/declarative/toys/tic-tac-toe/content/pics/o.png deleted file mode 100644 index abc7ee020b..0000000000 Binary files a/examples/declarative/toys/tic-tac-toe/content/pics/o.png and /dev/null differ diff --git a/examples/declarative/toys/tic-tac-toe/content/pics/x.png b/examples/declarative/toys/tic-tac-toe/content/pics/x.png deleted file mode 100644 index ddc65c83b8..0000000000 Binary files a/examples/declarative/toys/tic-tac-toe/content/pics/x.png and /dev/null differ diff --git a/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js b/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js deleted file mode 100644 index 5a166b750f..0000000000 --- a/examples/declarative/toys/tic-tac-toe/content/tic-tac-toe.js +++ /dev/null @@ -1,149 +0,0 @@ -function winner(board) -{ - for (var i=0; i<3; ++i) { - if (board.children[i].state != "" - && board.children[i].state == board.children[i+3].state - && board.children[i].state == board.children[i+6].state) - return true - - if (board.children[i*3].state != "" - && board.children[i*3].state == board.children[i*3+1].state - && board.children[i*3].state == board.children[i*3+2].state) - return true - } - - if (board.children[0].state != "" - && board.children[0].state == board.children[4].state != "" - && board.children[0].state == board.children[8].state != "") - return true - - if (board.children[2].state != "" - && board.children[2].state == board.children[4].state != "" - && board.children[2].state == board.children[6].state != "") - return true - - return false -} - -function restartGame() -{ - game.running = true - - for (var i=0; i<9; ++i) - board.children[i].state = "" -} - -function makeMove(pos, player) -{ - board.children[pos].state = player - if (winner(board)) { - gameFinished(player + " wins") - return true - } else { - return false - } -} - -function canPlayAtPos(pos) -{ - return board.children[pos].state == "" -} - -function computerTurn() -{ - var r = Math.random(); - if (r < game.difficulty) - smartAI(); - else - randomAI(); -} - -function smartAI() -{ - function boardCopy(a) { - var ret = new Object; - ret.children = new Array(9); - for (var i = 0; i<9; i++) { - ret.children[i] = new Object; - ret.children[i].state = a.children[i].state; - } - return ret; - } - - for (var i=0; i<9; i++) { - var simpleBoard = boardCopy(board); - if (canPlayAtPos(i)) { - simpleBoard.children[i].state = "O"; - if (winner(simpleBoard)) { - makeMove(i, "O") - return - } - } - } - for (var i=0; i<9; i++) { - var simpleBoard = boardCopy(board); - if (canPlayAtPos(i)) { - simpleBoard.children[i].state = "X"; - if (winner(simpleBoard)) { - makeMove(i, "O") - return - } - } - } - - function thwart(a,b,c) { //If they are at a, try b or c - if (board.children[a].state == "X") { - if (canPlayAtPos(b)) { - makeMove(b, "O") - return true - } else if (canPlayAtPos(c)) { - makeMove(c, "O") - return true - } - } - return false; - } - - if (thwart(4,0,2)) return; - if (thwart(0,4,3)) return; - if (thwart(2,4,1)) return; - if (thwart(6,4,7)) return; - if (thwart(8,4,5)) return; - if (thwart(1,4,2)) return; - if (thwart(3,4,0)) return; - if (thwart(5,4,8)) return; - if (thwart(7,4,6)) return; - - for (var i =0; i<9; i++) { - if (canPlayAtPos(i)) { - makeMove(i, "O") - return - } - } - restartGame(); -} - -function randomAI() -{ - var unfilledPosns = new Array(); - - for (var i=0; i<9; ++i) { - if (canPlayAtPos(i)) - unfilledPosns.push(i); - } - - if (unfilledPosns.length == 0) { - restartGame(); - } else { - var choice = unfilledPosns[Math.floor(Math.random() * unfilledPosns.length)]; - makeMove(choice, "O"); - } -} - -function gameFinished(message) -{ - messageDisplay.text = message - messageDisplay.visible = true - game.running = false -} - diff --git a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml deleted file mode 100644 index 8d15233eaa..0000000000 --- a/examples/declarative/toys/tic-tac-toe/tic-tac-toe.qml +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" -import "content/tic-tac-toe.js" as Logic - -Rectangle { - id: game - - property bool running: true - property real difficulty: 1.0 //chance it will actually think - - width: display.width; height: display.height + 10 - - Image { - id: boardImage - source: "content/pics/board.png" - } - - - Column { - id: display - - Grid { - id: board - width: boardImage.width; height: boardImage.height - columns: 3 - - Repeater { - model: 9 - - TicTac { - width: board.width/3 - height: board.height/3 - - onClicked: { - if (game.running && Logic.canPlayAtPos(index)) { - if (!Logic.makeMove(index, "X")) - Logic.computerTurn(); - } - } - } - } - } - - Row { - spacing: 4 - anchors.horizontalCenter: parent.horizontalCenter - - Button { - text: "Hard" - pressed: game.difficulty == 1.0 - onClicked: { game.difficulty = 1.0 } - } - Button { - text: "Moderate" - pressed: game.difficulty == 0.8 - onClicked: { game.difficulty = 0.8 } - } - Button { - text: "Easy" - pressed: game.difficulty == 0.2 - onClicked: { game.difficulty = 0.2 } - } - } - } - - - Text { - id: messageDisplay - anchors.centerIn: parent - color: "blue" - style: Text.Outline; styleColor: "white" - font.pixelSize: 50; font.bold: true - visible: false - - Timer { - running: messageDisplay.visible - onTriggered: { - messageDisplay.visible = false; - Logic.restartGame(); - } - } - } -} diff --git a/examples/declarative/toys/tvtennis/tvtennis.qml b/examples/declarative/toys/tvtennis/tvtennis.qml deleted file mode 100644 index 63866e3ce6..0000000000 --- a/examples/declarative/toys/tvtennis/tvtennis.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - width: 640; height: 480 - color: "Black" - - // Make a ball to bounce - Rectangle { - id: ball - - // Add a property for the target y coordinate - property variant direction : "right" - - x: 20; width: 20; height: 20; z: 1 - color: "Lime" - - // Move the ball to the right and back to the left repeatedly - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { to: page.width - 40; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "left" } - NumberAnimation { to: 20; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "right" } - } - - // Make y move with a velocity of 200 - Behavior on y { SpringAnimation{ velocity: 200; } - } - - Component.onCompleted: y = page.height-10; // start the ball motion - - // Detect the ball hitting the top or bottom of the view and bounce it - onYChanged: { - if (y <= 0) { - y = page.height - 20; - } else if (y >= page.height - 20) { - y = 0; - } - } - } - - // Place bats to the left and right of the view, following the y - // coordinates of the ball. - Rectangle { - id: leftBat - color: "Lime" - x: 2; width: 20; height: 90 - y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ velocity: 300 } } - } - Rectangle { - id: rightBat - color: "Lime" - x: page.width - 22; width: 20; height: 90 - y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ velocity: 300 } } - } - - // The rest, to make it look realistic, if neither ever scores... - Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } - Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } - Repeater { - model: page.height / 20 - Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview1/PetsModel.qml b/examples/declarative/tutorials/dynamicview/dynamicview1/PetsModel.qml deleted file mode 100644 index f07613c968..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview1/PetsModel.qml +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } -//![0] - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -//![1] -} -//![1] diff --git a/examples/declarative/tutorials/dynamicview/dynamicview1/dynamicview.qml b/examples/declarative/tutorials/dynamicview/dynamicview1/dynamicview.qml deleted file mode 100644 index 1a9dd453ce..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview1/dynamicview.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: root - - width: 300; height: 400 - -//![1] - Component { - id: dragDelegate - - Rectangle { - id: content - - anchors { left: parent.left; right: parent.right } - height: column.implicitHeight + 4 - - border.width: 1 - border.color: "lightsteelblue" - - radius: 2 - - Column { - id: column - anchors { fill: parent; margins: 2 } - - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - Text { text: 'Size: ' + size } - } - } - } -//![1] -//![2] - ListView { - id: view - - anchors { fill: parent; margins: 2 } - - model: PetsModel {} - delegate: dragDelegate - - spacing: 4 - cacheBuffer: 50 - } -//![2] -} -//![0] diff --git a/examples/declarative/tutorials/dynamicview/dynamicview2/PetsModel.qml b/examples/declarative/tutorials/dynamicview/dynamicview2/PetsModel.qml deleted file mode 100644 index 4f2087d95e..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview2/PetsModel.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview2/dynamicview.qml b/examples/declarative/tutorials/dynamicview/dynamicview2/dynamicview.qml deleted file mode 100644 index 9e654a685c..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview2/dynamicview.qml +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - - width: 300; height: 400 - -//![0] - Component { - id: dragDelegate - -//![1] - MouseArea { - id: dragArea - - property bool held: false - - anchors { left: parent.left; right: parent.right } - height: content.height - - drag.target: held ? content : undefined - drag.axis: Drag.YAxis - - onPressAndHold: held = true - onReleased: held = false - - Rectangle { - id: content -//![1] - anchors { - horizontalCenter: parent.horizontalCenter - verticalCenter: parent.verticalCenter - } - width: dragArea.width; height: column.implicitHeight + 4 - - border.width: 1 - border.color: "lightsteelblue" -//![3] - color: dragArea.held ? "lightsteelblue" : "white" - Behavior on color { ColorAnimation { duration: 100 } } -//![3] - radius: 2 -//![4] - states: State { - when: dragArea.held - - ParentChange { target: content; parent: root } - AnchorChanges { - target: content - anchors { horizontalCenter: undefined; verticalCenter: undefined } - } - } -//![4] - Column { - id: column - anchors { fill: parent; margins: 2 } - - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - Text { text: 'Size: ' + size } - } -//![2] - } - } -//![2] - } -//![0] - - ListView { - id: view - - anchors { fill: parent; margins: 2 } - - model: PetsModel {} - delegate: dragDelegate - - spacing: 4 - cacheBuffer: 50 - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview3/PetsModel.qml b/examples/declarative/tutorials/dynamicview/dynamicview3/PetsModel.qml deleted file mode 100644 index 4f2087d95e..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview3/PetsModel.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview3/dynamicview.qml b/examples/declarative/tutorials/dynamicview/dynamicview3/dynamicview.qml deleted file mode 100644 index 5a579f78d9..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview3/dynamicview.qml +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -//![0] -Rectangle { - id: root - - width: 300; height: 400 - - Component { - id: dragDelegate - - MouseArea { - id: dragArea - - property bool held: false - - anchors { left: parent.left; right: parent.right } - height: content.height - - drag.target: held ? content : undefined - drag.axis: Drag.YAxis - - onPressAndHold: held = true - onReleased: held = false - - Rectangle { - id: content -//![0] - anchors { - horizontalCenter: parent.horizontalCenter - verticalCenter: parent.verticalCenter - } - width: dragArea.width; height: column.implicitHeight + 4 - - border.width: 1 - border.color: "lightsteelblue" - - color: dragArea.held ? "lightsteelblue" : "white" - Behavior on color { ColorAnimation { duration: 100 } } - - radius: 2 -//![1] - Drag.active: dragArea.held - Drag.source: dragArea - Drag.hotSpot.x: width / 2 - Drag.hotSpot.y: height / 2 -//![1] - states: State { - when: dragArea.held - - ParentChange { target: content; parent: root } - AnchorChanges { - target: content - anchors { horizontalCenter: undefined; verticalCenter: undefined } - } - } - - Column { - id: column - anchors { fill: parent; margins: 2 } - - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - Text { text: 'Size: ' + size } - } -//![2] - } -//![3] - DropArea { - anchors { fill: parent; margins: 10 } - - onEntered: { - visualModel.items.move( - drag.source.VisualDataModel.itemsIndex, - dragArea.VisualDataModel.itemsIndex) - } - } -//![3] - } - } -//![2] -//![4] - VisualDataModel { - id: visualModel - - model: PetsModel {} - delegate: dragDelegate - } - - ListView { - id: view - - anchors { fill: parent; margins: 2 } - - model: visualModel - - spacing: 4 - cacheBuffer: 50 - } -//![4] -//![5] -} -//![5] diff --git a/examples/declarative/tutorials/dynamicview/dynamicview4/ListSelector.qml b/examples/declarative/tutorials/dynamicview/dynamicview4/ListSelector.qml deleted file mode 100644 index c6b8287beb..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview4/ListSelector.qml +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: selector - - property alias list: view.model - property alias selectedIndex: view.currentIndex - property alias label: labelText.text - property bool expanded - - width: 100; height: labelText.implicitHeight + 26 - - Rectangle { - anchors { left: parent.left; right: parent.right; bottom: parent.bottom; } - - height: labelText.implicitHeight + 4 + (expanded ? 20 * view.count : 20) - Behavior on height { NumberAnimation { duration: 300 } } - - radius: 2 - border.width: 1 - border.color: "yellow" - color: "yellow" - - MouseArea { - anchors.fill: parent - - onClicked: selector.expanded = !selector.expanded - - Text { - id: labelText - anchors { left: parent.left; top: parent.top; margins: 2 } - } - - Rectangle { - anchors { - left: parent.left; top: labelText.bottom; - right: parent.right; bottom: parent.bottom; - margins: 2 - leftMargin: 10 - } - - radius: 2 - color: "white" - - ListView { - id: view - - anchors.fill: parent - - clip: true - - delegate: Text { - anchors { left: parent.left; right: parent.right } - height: 20 - - verticalAlignment: Text.AlignVCenter - - text: modelData - - MouseArea { - anchors.fill: parent - - onClicked: { - view.currentIndex = index - selector.expanded = !selector.expanded - } - } - } - highlight: Rectangle { - anchors { left: parent.left; right: parent.right } - height: 20 - radius: 2 - - color: "yellow" - } - } - } - } - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview4/PetsModel.qml b/examples/declarative/tutorials/dynamicview/dynamicview4/PetsModel.qml deleted file mode 100644 index 4f2087d95e..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview4/PetsModel.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -ListModel { - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -} diff --git a/examples/declarative/tutorials/dynamicview/dynamicview4/dynamicview.qml b/examples/declarative/tutorials/dynamicview/dynamicview4/dynamicview.qml deleted file mode 100644 index 9bd4e0c438..0000000000 --- a/examples/declarative/tutorials/dynamicview/dynamicview4/dynamicview.qml +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: root - - width: 300; height: 400 - - Component { - id: dragDelegate - - MouseArea { - id: dragArea - - property bool held: false - - anchors { left: parent.left; right: parent.right } - height: content.height - - enabled: visualModel.sortOrder == visualModel.lessThan.length - - drag.target: held ? content : undefined - drag.axis: Drag.YAxis - - onPressAndHold: held = true - onReleased: held = false - - Rectangle { - id: content - - anchors { - horizontalCenter: parent.horizontalCenter - verticalCenter: parent.verticalCenter - } - width: dragArea.width; height: column.implicitHeight + 4 - - border.width: 1 - border.color: "lightsteelblue" - - color: dragArea.held ? "lightsteelblue" : "white" - Behavior on color { ColorAnimation { duration: 100 } } - - radius: 2 - - Drag.active: dragArea.held - Drag.source: dragArea - Drag.hotSpot.x: width / 2 - Drag.hotSpot.y: height / 2 - - states: State { - when: dragArea.held - - ParentChange { target: content; parent: root } - AnchorChanges { - target: content - anchors { horizontalCenter: undefined; verticalCenter: undefined } - } - } - - Column { - id: column - anchors { fill: parent; margins: 2 } - - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - Text { text: 'Size: ' + size } - } - } - - DropArea { - anchors { fill: parent; margins: 10 } - - onEntered: { - visualModel.items.move( - drag.source.VisualDataModel.itemsIndex, - dragArea.VisualDataModel.itemsIndex) - } - } - } - } -//![0] - VisualDataModel { - id: visualModel -//![4] - property var lessThan: [ - function(left, right) { return left.name < right.name }, - function(left, right) { return left.type < right.type }, - function(left, right) { return left.age < right.age }, - function(left, right) { - if (left.size == "Small") - return true - else if (right.size == "Small") - return false - else if (left.size == "Medium") - return true - else - return false - } - ] -//![4] -//![6] - - property int sortOrder: orderSelector.selectedIndex - onSortOrderChanged: items.setGroups(0, items.count, "unsorted") - -//![6] -//![3] - function insertPosition(lessThan, item) { - var lower = 0 - var upper = items.count - while (lower < upper) { - var middle = Math.floor(lower + (upper - lower) / 2) - var result = lessThan(item.model, items.get(middle).model); - if (result) { - upper = middle - } else { - lower = middle + 1 - } - } - return lower - } - - function sort(lessThan) { - while (unsortedItems.count > 0) { - var item = unsortedItems.get(0) - var index = insertPosition(lessThan, item) - - item.groups = "items" - items.move(item.itemsIndex, index) - } - } -//![3] - -//![1] - items.includeByDefault: false -//![5] - groups: VisualDataGroup { - id: unsortedItems - name: "unsorted" - - includeByDefault: true -//![1] - onChanged: { - if (visualModel.sortOrder == visualModel.lessThan.length) - setGroups(0, count, "items") - else - visualModel.sort(visualModel.lessThan[visualModel.sortOrder]) - } -//![2] - } -//![2] -//![5] - model: PetsModel {} - delegate: dragDelegate - } -//![0] - ListView { - id: view - - anchors { - left: parent.left; top: parent.top; right: parent.right; bottom: orderSelector.top; - margins: 2 - } - - model: visualModel - - spacing: 4 - cacheBuffer: 50 - } - - ListSelector { - id: orderSelector - - anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 } - - label: "Sort By" - list: [ "Name", "Type", "Age", "Size", "Custom" ] - } -} diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml deleted file mode 100644 index 6f0c1d3a23..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/app.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - id: aPieChart - anchors.centerIn: parent - width: 100; height: 100 - name: "A simple pie chart" - color: "red" - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: aPieChart.name - } -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro deleted file mode 100644 index affc57ce1f..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += declarative quick - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp deleted file mode 100644 index ed9e412bd6..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp b/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp deleted file mode 100644 index bc81d6a3a0..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include - -//![0] -PieChart::PieChart(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} -//![0] - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -void PieChart::setColor(const QColor &color) -{ - m_color = color; -} - -//![1] -void PieChart::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} -//![1] - diff --git a/examples/declarative/tutorials/extending/chapter1-basics/piechart.h b/examples/declarative/tutorials/extending/chapter1-basics/piechart.h deleted file mode 100644 index 71a8786e7d..0000000000 --- a/examples/declarative/tutorials/extending/chapter1-basics/piechart.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -//![0] -#include -#include - -class PieChart : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QColor color READ color WRITE setColor) - -public: - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - -private: - QString m_name; - QColor m_color; -}; -//![0] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter2-methods/app.qml b/examples/declarative/tutorials/extending/chapter2-methods/app.qml deleted file mode 100644 index eee0933734..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/app.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - id: aPieChart - anchors.centerIn: parent - width: 100; height: 100 - color: "red" - - onChartCleared: console.log("The chart has been cleared") - } - - MouseArea { - anchors.fill: parent - onClicked: aPieChart.clearChart() - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: "Click anywhere to clear the chart" - } -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro deleted file mode 100644 index affc57ce1f..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += declarative quick - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp deleted file mode 100644 index ed9e412bd6..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp b/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp deleted file mode 100644 index 71be74e943..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include - -PieChart::PieChart(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -void PieChart::setColor(const QColor &color) -{ - m_color = color; -} - -void PieChart::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} - -//![0] -void PieChart::clearChart() -{ - setColor(QColor(Qt::transparent)); - update(); - - emit chartCleared(); -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter2-methods/piechart.h b/examples/declarative/tutorials/extending/chapter2-methods/piechart.h deleted file mode 100644 index 7650d6e8d7..0000000000 --- a/examples/declarative/tutorials/extending/chapter2-methods/piechart.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include -#include - -//![0] -class PieChart : public QQuickPaintedItem -{ -//![0] - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QColor color READ color WRITE setColor) - -//![1] -public: -//![1] - - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - -//![2] - Q_INVOKABLE void clearChart(); - -signals: - void chartCleared(); -//![2] - -private: - QString m_name; - QColor m_color; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml deleted file mode 100644 index 4ad929132c..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - Row { - anchors.centerIn: parent - spacing: 20 - - PieChart { - id: chartA - width: 100; height: 100 - color: "red" - } - - PieChart { - id: chartB - width: 100; height: 100 - color: chartA.color - } - } - - MouseArea { - anchors.fill: parent - onClicked: { chartA.color = "blue" } - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: "Click anywhere to change the chart color" - } -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro deleted file mode 100644 index affc57ce1f..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += declarative quick - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp deleted file mode 100644 index ed9e412bd6..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp deleted file mode 100644 index 2a392125da..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include - -PieChart::PieChart(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -//![0] -void PieChart::setColor(const QColor &color) -{ - if (color != m_color) { - m_color = color; - update(); // repaint with the new color - emit colorChanged(); - } -} -//![0] - -void PieChart::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} - -void PieChart::clearChart() -{ - setColor(QColor(Qt::transparent)); - update(); -} diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.h b/examples/declarative/tutorials/extending/chapter3-bindings/piechart.h deleted file mode 100644 index 77075b5727..0000000000 --- a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include -#include - -//![0] -class PieChart : public QQuickPaintedItem -{ -//![0] - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) -public: -//![1] - - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - - Q_INVOKABLE void clearChart(); - -//![2] -signals: - void colorChanged(); -//![2] - -private: - QString m_name; - QColor m_color; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml deleted file mode 100644 index 06490773f4..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - id: chart - anchors.centerIn: parent - width: 100; height: 100 - - pieSlice: PieSlice { - anchors.fill: parent - color: "red" - } - } - - Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color) -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro deleted file mode 100644 index 6724fa0375..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += declarative quick - -HEADERS += piechart.h \ - pieslice.h -SOURCES += piechart.cpp \ - pieslice.cpp \ - main.cpp diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp deleted file mode 100644 index 537ea766fc..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -#include -#include - -//![0] -int main(int argc, char *argv[]) -{ -//![0] - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - -//![1] - qmlRegisterType("Charts", 1, 0, "PieSlice"); -//![1] - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); - -//![2] -} -//![2] diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp deleted file mode 100644 index 3cf9bdc00c..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QQuickItem *parent) - : QQuickItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -PieSlice *PieChart::pieSlice() const -{ - return m_pieSlice; -} - -//![0] -void PieChart::setPieSlice(PieSlice *pieSlice) -{ - m_pieSlice = pieSlice; - pieSlice->setParentItem(this); -} -//![0] - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h deleted file mode 100644 index b89db5a2b1..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -//![0] -class PieChart : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) -//![0] - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] -public: -//![1] - - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - -//![2] - PieSlice *pieSlice() const; - void setPieSlice(PieSlice *pieSlice); -//![2] - -private: - QString m_name; - PieSlice *m_pieSlice; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp deleted file mode 100644 index 654a46fc8d..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "pieslice.h" - -#include - -PieSlice::PieSlice(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -void PieSlice::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} - diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h deleted file mode 100644 index 8fc445d471..0000000000 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIESLICE_H -#define PIESLICE_H - -#include -#include - -//![0] -class PieSlice : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - -public: - PieSlice(QQuickItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter); - -private: - QColor m_color; -}; -//![0] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml b/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml deleted file mode 100644 index 37b0626948..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 2.0 - -Item { - width: 300; height: 200 - - PieChart { - anchors.centerIn: parent - width: 100; height: 100 - - slices: [ - PieSlice { - anchors.fill: parent - color: "red" - fromAngle: 0; angleSpan: 110 - }, - PieSlice { - anchors.fill: parent - color: "black" - fromAngle: 110; angleSpan: 50 - }, - PieSlice { - anchors.fill: parent - color: "blue" - fromAngle: 160; angleSpan: 100 - } - ] - } -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro deleted file mode 100644 index 6724fa0375..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += declarative quick - -HEADERS += piechart.h \ - pieslice.h -SOURCES += piechart.cpp \ - pieslice.cpp \ - main.cpp diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp b/examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp deleted file mode 100644 index 59587733eb..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -#include -#include - -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - qmlRegisterType("Charts", 1, 0, "PieSlice"); - - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp deleted file mode 100644 index bfcb607e60..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QQuickItem *parent) - : QQuickItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -//![0] -QDeclarativeListProperty PieChart::slices() -{ - return QDeclarativeListProperty(this, 0, &PieChart::append_slice); -} - -void PieChart::append_slice(QDeclarativeListProperty *list, PieSlice *slice) -{ - PieChart *chart = qobject_cast(list->object); - if (chart) { - slice->setParentItem(chart); - chart->m_slices.append(slice); - } -} -//![0] diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h b/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h deleted file mode 100644 index 9beabda5f3..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -//![0] -class PieChart : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty slices READ slices) -//![0] - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] -public: -//![1] - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - -//![2] - QDeclarativeListProperty slices(); - -private: - static void append_slice(QDeclarativeListProperty *list, PieSlice *slice); - - QString m_name; - QList m_slices; -}; -//![2] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp deleted file mode 100644 index 5bca2d58d8..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "pieslice.h" - -#include - -PieSlice::PieSlice(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -int PieSlice::fromAngle() const -{ - return m_fromAngle; -} - -void PieSlice::setFromAngle(int angle) -{ - m_fromAngle = angle; -} - -int PieSlice::angleSpan() const -{ - return m_angleSpan; -} - -void PieSlice::setAngleSpan(int angle) -{ - m_angleSpan = angle; -} - -void PieSlice::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); -} - diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h deleted file mode 100644 index f6497fcbae..0000000000 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIESLICE_H -#define PIESLICE_H - -#include -#include - -//![0] -class PieSlice : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) - Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) -//![0] - -public: - PieSlice(QQuickItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - int fromAngle() const; - void setFromAngle(int angle); - - int angleSpan() const; - void setAngleSpan(int span); - - void paint(QPainter *painter); - -private: - QColor m_color; - int m_fromAngle; - int m_angleSpan; -}; - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir b/examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir deleted file mode 100644 index 72650d8243..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin chartsplugin \ No newline at end of file diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/app.qml b/examples/declarative/tutorials/extending/chapter6-plugins/app.qml deleted file mode 100644 index b6eac44e27..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/app.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 -import "ChartsPlugin" 1.0 - -Item { - width: 300; height: 200 - - PieChart { - anchors.centerIn: parent - width: 100; height: 100 - - slices: [ - PieSlice { - anchors.fill: parent - color: "red" - fromAngle: 0; angleSpan: 110 - }, - PieSlice { - anchors.fill: parent - color: "black" - fromAngle: 110; angleSpan: 50 - }, - PieSlice { - anchors.fill: parent - color: "blue" - fromAngle: 160; angleSpan: 100 - } - ] - } -} - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro deleted file mode 100644 index c243ec4572..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative quick - -DESTDIR = ChartsPlugin -TARGET = chartsplugin - -OBJECTS_DIR = tmp -MOC_DIR = tmp - -HEADERS += piechart.h \ - pieslice.h \ - chartsplugin.h - -SOURCES += piechart.cpp \ - pieslice.cpp \ - chartsplugin.cpp - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp deleted file mode 100644 index d75f810964..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "chartsplugin.h" -//![0] -#include "piechart.h" -#include "pieslice.h" -#include - -void ChartsPlugin::registerTypes(const char *uri) -{ - qmlRegisterType(uri, 1, 0, "PieChart"); - qmlRegisterType(uri, 1, 0, "PieSlice"); -} - -//![0] - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h deleted file mode 100644 index 863564b09c..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef CHARTSPLUGIN_H -#define CHARTSPLUGIN_H - -//![0] -#include - -class ChartsPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "chartsplugin.json") - -public: - void registerTypes(const char *uri); -}; -//![0] - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp deleted file mode 100644 index 2a8f40289e..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QQuickItem *parent) - : QQuickItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QDeclarativeListProperty PieChart::slices() -{ - return QDeclarativeListProperty(this, 0, &PieChart::append_slice); -} - -void PieChart::append_slice(QDeclarativeListProperty *list, PieSlice *slice) -{ - PieChart *chart = qobject_cast(list->object); - if (chart) { - slice->setParentItem(chart); - chart->m_slices.append(slice); - } -} - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.h b/examples/declarative/tutorials/extending/chapter6-plugins/piechart.h deleted file mode 100644 index fe6b96afdc..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -class PieChart : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty slices READ slices) - Q_PROPERTY(QString name READ name WRITE setName) - -public: - PieChart(QQuickItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QDeclarativeListProperty slices(); - -private: - static void append_slice(QDeclarativeListProperty *list, PieSlice *slice); - - QString m_name; - QList m_slices; -}; - -#endif - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp deleted file mode 100644 index 5bca2d58d8..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "pieslice.h" - -#include - -PieSlice::PieSlice(QQuickItem *parent) - : QQuickPaintedItem(parent) -{ -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -int PieSlice::fromAngle() const -{ - return m_fromAngle; -} - -void PieSlice::setFromAngle(int angle) -{ - m_fromAngle = angle; -} - -int PieSlice::angleSpan() const -{ - return m_angleSpan; -} - -void PieSlice::setAngleSpan(int angle) -{ - m_angleSpan = angle; -} - -void PieSlice::paint(QPainter *painter) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::HighQualityAntialiasing, true); - painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); -} - diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h b/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h deleted file mode 100644 index 8a636fb3e7..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIESLICE_H -#define PIESLICE_H - -#include -#include - -class PieSlice : public QQuickPaintedItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) - Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) - -public: - PieSlice(QQuickItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - int fromAngle() const; - void setFromAngle(int angle); - - int angleSpan() const; - void setAngleSpan(int span); - - void paint(QPainter *painter); - -private: - QColor m_color; - int m_fromAngle; - int m_angleSpan; -}; - -#endif - diff --git a/examples/declarative/tutorials/extending/extending.pro b/examples/declarative/tutorials/extending/extending.pro deleted file mode 100644 index 967473fda0..0000000000 --- a/examples/declarative/tutorials/extending/extending.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - chapter1-basics \ - chapter2-methods \ - chapter3-bindings \ - chapter4-customPropertyTypes \ - chapter5-listproperties \ - chapter6-plugins - diff --git a/examples/declarative/tutorials/helloworld/Cell.qml b/examples/declarative/tutorials/helloworld/Cell.qml deleted file mode 100644 index 7140dcb2c1..0000000000 --- a/examples/declarative/tutorials/helloworld/Cell.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -//![1] -Item { - id: container -//![4] - property alias cellColor: rectangle.color -//![4] -//![5] - signal clicked(color cellColor) -//![5] - - width: 40; height: 25 -//![1] - -//![2] - Rectangle { - id: rectangle - border.color: "white" - anchors.fill: parent - } -//![2] - -//![3] - MouseArea { - anchors.fill: parent - onClicked: container.clicked(container.cellColor) - } -//![3] -} -//![0] diff --git a/examples/declarative/tutorials/helloworld/tutorial1.qml b/examples/declarative/tutorials/helloworld/tutorial1.qml deleted file mode 100644 index f0eb42d696..0000000000 --- a/examples/declarative/tutorials/helloworld/tutorial1.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -//![3] -import QtQuick 2.0 -//![3] - -//![1] -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" -//![1] - -//![2] - Text { - id: helloText - text: "Hello world!" - y: 30 - anchors.horizontalCenter: page.horizontalCenter - font.pointSize: 24; font.bold: true - } -//![2] -} -//![0] diff --git a/examples/declarative/tutorials/helloworld/tutorial2.qml b/examples/declarative/tutorials/helloworld/tutorial2.qml deleted file mode 100644 index c5c045aace..0000000000 --- a/examples/declarative/tutorials/helloworld/tutorial2.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" - - Text { - id: helloText - text: "Hello world!" - y: 30 - anchors.horizontalCenter: page.horizontalCenter - font.pointSize: 24; font.bold: true - } - - Grid { - id: colorPicker - x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 - rows: 2; columns: 3; spacing: 3 - -//![1] - Cell { cellColor: "red"; onClicked: helloText.color = cellColor } -//![1] - Cell { cellColor: "green"; onClicked: helloText.color = cellColor } - Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } - Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "black"; onClicked: helloText.color = cellColor } - } -} -//![0] diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml deleted file mode 100644 index c804bfca1d..0000000000 --- a/examples/declarative/tutorials/helloworld/tutorial3.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" - - Text { - id: helloText - text: "Hello world!" - y: 30 - anchors.horizontalCenter: page.horizontalCenter - font.pointSize: 24; font.bold: true - -//![1] - MouseArea { id: mouseArea; anchors.fill: parent } -//![1] - -//![2] - states: State { - name: "down"; when: mouseArea.pressed == true - PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" } - } -//![2] - -//![3] - transitions: Transition { - from: ""; to: "down"; reversible: true - ParallelAnimation { - NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: Easing.InOutQuad } - ColorAnimation { duration: 500 } - } - } -//![3] - } - - Grid { - id: colorPicker - x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 - rows: 2; columns: 3; spacing: 3 - - Cell { cellColor: "red"; onClicked: helloText.color = cellColor } - Cell { cellColor: "green"; onClicked: helloText.color = cellColor } - Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } - Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "black"; onClicked: helloText.color = cellColor } - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/Block.qml b/examples/declarative/tutorials/samegame/samegame1/Block.qml deleted file mode 100644 index 32ef8c2bba..0000000000 --- a/examples/declarative/tutorials/samegame/samegame1/Block.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Item { - id: block - - Image { - id: img - anchors.fill: parent - source: "../shared/pics/redStone.png" - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml deleted file mode 100644 index 6d1d1268de..0000000000 --- a/examples/declarative/tutorials/samegame/samegame1/Button.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml deleted file mode 100644 index 73e2cc31fd..0000000000 --- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - } - - Rectangle { - id: toolBar - width: parent.width; height: 30 - color: activePalette.window - anchors.bottom: screen.bottom - - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: console.log("This doesn't do anything yet...") - } - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: Who knows?" - } - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame1.qmlproject b/examples/declarative/tutorials/samegame/samegame1/samegame1.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/tutorials/samegame/samegame1/samegame1.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/tutorials/samegame/samegame2/Block.qml b/examples/declarative/tutorials/samegame/samegame2/Block.qml deleted file mode 100644 index 8056b39480..0000000000 --- a/examples/declarative/tutorials/samegame/samegame2/Block.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: block - - Image { - id: img - anchors.fill: parent - source: "../shared/pics/redStone.png" - } -} diff --git a/examples/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml deleted file mode 100644 index 248c20cf0f..0000000000 --- a/examples/declarative/tutorials/samegame/samegame2/Button.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.js b/examples/declarative/tutorials/samegame/samegame2/samegame.js deleted file mode 100644 index c749dc17b1..0000000000 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.js +++ /dev/null @@ -1,63 +0,0 @@ -//![0] -var blockSize = 40; -var maxColumn = 10; -var maxRow = 15; -var maxIndex = maxColumn * maxRow; -var board = new Array(maxIndex); -var component; - -//Index function used instead of a 2D array -function index(column, row) { - return column + (row * maxColumn); -} - -function startNewGame() { - //Delete blocks from previous game - for (var i = 0; i < maxIndex; i++) { - if (board[i] != null) - board[i].destroy(); - } - - //Calculate board size - maxColumn = Math.floor(background.width / blockSize); - maxRow = Math.floor(background.height / blockSize); - maxIndex = maxRow * maxColumn; - - //Initialize Board - board = new Array(maxIndex); - for (var column = 0; column < maxColumn; column++) { - for (var row = 0; row < maxRow; row++) { - board[index(column, row)] = null; - createBlock(column, row); - } - } -} - -function createBlock(column, row) { - if (component == null) - component = Qt.createComponent("Block.qml"); - - // Note that if Block.qml was not a local file, component.status would be - // Loading and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and ready before calling createObject(). - if (component.status == Component.Ready) { - var dynamicObject = component.createObject(background); - if (dynamicObject == null) { - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.x = column * blockSize; - dynamicObject.y = row * blockSize; - dynamicObject.width = blockSize; - dynamicObject.height = blockSize; - board[index(column, row)] = dynamicObject; - } else { - console.log("error loading block component"); - console.log(component.errorString()); - return false; - } - return true; -} -//![0] - diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml deleted file mode 100644 index c50010e97d..0000000000 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -//![2] -import "samegame.js" as SameGame -//![2] - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - } - - Rectangle { - id: toolBar - width: parent.width; height: 32 - color: activePalette.window - anchors.bottom: screen.bottom - -//![1] - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: SameGame.startNewGame() - } -//![1] - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: Who knows?" - } - } -} diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame2.qmlproject b/examples/declarative/tutorials/samegame/samegame2/samegame2.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/tutorials/samegame/samegame2/samegame2.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/tutorials/samegame/samegame3/Block.qml b/examples/declarative/tutorials/samegame/samegame3/Block.qml deleted file mode 100644 index 9c41048fcb..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/Block.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Item { - id: block - - property int type: 0 - - Image { - id: img - - anchors.fill: parent - source: { - if (type == 0) - return "../shared/pics/redStone.png"; - else if (type == 1) - return "../shared/pics/blueStone.png"; - else - return "../shared/pics/greenStone.png"; - } - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml deleted file mode 100644 index 248c20cf0f..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/Button.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml deleted file mode 100644 index df1fa37d6a..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - id: container - - function show(text) { - dialogText.text = text; - container.opacity = 1; - } - - function hide() { - container.opacity = 0; - } - - width: dialogText.width + 20 - height: dialogText.height + 20 - opacity: 0 - - Text { - id: dialogText - anchors.centerIn: parent - text: "" - } - - MouseArea { - anchors.fill: parent - onClicked: hide(); - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js deleted file mode 100644 index df5bdfb049..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.js +++ /dev/null @@ -1,174 +0,0 @@ -/* This script file handles the game logic */ -var maxColumn = 10; -var maxRow = 15; -var maxIndex = maxColumn * maxRow; -var board = new Array(maxIndex); -var component; - -//Index function used instead of a 2D array -function index(column, row) { - return column + (row * maxColumn); -} - -function startNewGame() { - //Calculate board size - maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); - maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); - maxIndex = maxRow * maxColumn; - - //Close dialogs - dialog.hide(); - - //Initialize Board - board = new Array(maxIndex); - gameCanvas.score = 0; - for (var column = 0; column < maxColumn; column++) { - for (var row = 0; row < maxRow; row++) { - board[index(column, row)] = null; - createBlock(column, row); - } - } -} - -function createBlock(column, row) { - if (component == null) - component = Qt.createComponent("Block.qml"); - - // Note that if Block.qml was not a local file, component.status would be - // Loading and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and ready before calling createObject(). - if (component.status == Component.Ready) { - var dynamicObject = component.createObject(gameCanvas); - if (dynamicObject == null) { - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.type = Math.floor(Math.random() * 3); - dynamicObject.x = column * gameCanvas.blockSize; - dynamicObject.y = row * gameCanvas.blockSize; - dynamicObject.width = gameCanvas.blockSize; - dynamicObject.height = gameCanvas.blockSize; - board[index(column, row)] = dynamicObject; - } else { - console.log("error loading block component"); - console.log(component.errorString()); - return false; - } - return true; -} - -var fillFound; //Set after a floodFill call to the number of blocks found -var floodBoard; //Set to 1 if the floodFill reaches off that node - -//![1] -function handleClick(xPos, yPos) { - var column = Math.floor(xPos / gameCanvas.blockSize); - var row = Math.floor(yPos / gameCanvas.blockSize); - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (board[index(column, row)] == null) - return; - //If it's a valid block, remove it and all connected (does nothing if it's not connected) - floodFill(column, row, -1); - if (fillFound <= 0) - return; - gameCanvas.score += (fillFound - 1) * (fillFound - 1); - shuffleDown(); - victoryCheck(); -} -//![1] - -function floodFill(column, row, type) { - if (board[index(column, row)] == null) - return; - var first = false; - if (type == -1) { - first = true; - type = board[index(column, row)].type; - - //Flood fill initialization - fillFound = 0; - floodBoard = new Array(maxIndex); - } - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) - return; - floodBoard[index(column, row)] = 1; - floodFill(column + 1, row, type); - floodFill(column - 1, row, type); - floodFill(column, row + 1, type); - floodFill(column, row - 1, type); - if (first == true && fillFound == 0) - return; //Can't remove single blocks - board[index(column, row)].opacity = 0; - board[index(column, row)] = null; - fillFound += 1; -} - -function shuffleDown() { - //Fall down - for (var column = 0; column < maxColumn; column++) { - var fallDist = 0; - for (var row = maxRow - 1; row >= 0; row--) { - if (board[index(column, row)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - var obj = board[index(column, row)]; - obj.y += fallDist * gameCanvas.blockSize; - board[index(column, row + fallDist)] = obj; - board[index(column, row)] = null; - } - } - } - } - //Fall to the left - var fallDist = 0; - for (var column = 0; column < maxColumn; column++) { - if (board[index(column, maxRow - 1)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - for (var row = 0; row < maxRow; row++) { - var obj = board[index(column, row)]; - if (obj == null) - continue; - obj.x -= fallDist * gameCanvas.blockSize; - board[index(column - fallDist, row)] = obj; - board[index(column, row)] = null; - } - } - } - } -} - -//![2] -function victoryCheck() { - //Award bonus points if no blocks left - var deservesBonus = true; - for (var column = maxColumn - 1; column >= 0; column--) - if (board[index(column, maxRow - 1)] != null) - deservesBonus = false; - if (deservesBonus) - gameCanvas.score += 500; - - //Check whether game has finished - if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) - dialog.show("Game Over. Your score is " + gameCanvas.score); -} -//![2] - -//only floods up and right, to see if it can find adjacent same-typed blocks -function floodMoveCheck(column, row, type) { - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return false; - if (board[index(column, row)] == null) - return false; - var myType = board[index(column, row)].type; - if (type == myType) - return true; - return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); -} - diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml deleted file mode 100644 index f14829ef63..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 -import "samegame.js" as SameGame - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - -//![1] - Item { - id: gameCanvas - - property int score: 0 - property int blockSize: 40 - - width: parent.width - (parent.width % blockSize) - height: parent.height - (parent.height % blockSize) - anchors.centerIn: parent - - MouseArea { - anchors.fill: parent - onClicked: SameGame.handleClick(mouse.x, mouse.y) - } - } -//![1] - } - -//![2] - Dialog { - id: dialog - anchors.centerIn: parent - z: 100 - } -//![2] - - Rectangle { - id: toolBar - width: parent.width; height: 30 - color: activePalette.window - anchors.bottom: screen.bottom - - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: SameGame.startNewGame() - } - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: Who knows?" - } - } -} -//![0] diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame3.qmlproject b/examples/declarative/tutorials/samegame/samegame3/samegame3.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/tutorials/samegame/samegame3/samegame3.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml deleted file mode 100644 index 3786b9c0d1..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import Qt.labs.particles 1.0 - -Item { - id: block - - property int type: 0 - property bool dying: false - - //![1] - property bool spawned: false - - Behavior on x { - enabled: spawned; - SpringAnimation{ spring: 2; damping: 0.2 } - } - Behavior on y { - SpringAnimation{ spring: 2; damping: 0.2 } - } - //![1] - - //![2] - Image { - id: img - - anchors.fill: parent - source: { - if (type == 0) - return "../../shared/pics/redStone.png"; - else if (type == 1) - return "../../shared/pics/blueStone.png"; - else - return "../../shared/pics/greenStone.png"; - } - opacity: 0 - - Behavior on opacity { - NumberAnimation { properties:"opacity"; duration: 200 } - } - } - //![2] - - //![3] - Particles { - id: particles - - width: 1; height: 1 - anchors.centerIn: parent - - emissionRate: 0 - lifeSpan: 700; lifeSpanDeviation: 600 - angle: 0; angleDeviation: 360; - velocity: 100; velocityDeviation: 30 - source: { - if (type == 0) - return "../../shared/pics/redStar.png"; - else if (type == 1) - return "../../shared/pics/blueStar.png"; - else - return "../../shared/pics/greenStar.png"; - } - } - //![3] - - //![4] - states: [ - State { - name: "AliveState" - when: spawned == true && dying == false - PropertyChanges { target: img; opacity: 1 } - }, - - State { - name: "DeathState" - when: dying == true - StateChangeScript { script: particles.burst(50); } - PropertyChanges { target: img; opacity: 0 } - StateChangeScript { script: block.destroy(1000); } - } - ] - //![4] -} diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml deleted file mode 100644 index 248c20cf0f..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml deleted file mode 100644 index 984b3ddb6a..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -//![0] -Rectangle { - id: container -//![0] - -//![1] - property string inputText: textInput.text - signal closed - - function show(text) { - dialogText.text = text; - container.opacity = 1; - textInput.opacity = 0; - } - - function showWithInput(text) { - show(text); - textInput.opacity = 1; - textInput.focus = true; - textInput.text = "" - } - - function hide() { - textInput.focus = false; - container.opacity = 0; - container.closed(); - } -//![1] - - width: dialogText.width + textInput.width + 20 - height: dialogText.height + 20 - opacity: 0 - visible: opacity > 0 - - Text { - id: dialogText - anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: 10 } - text: "" - } - -//![2] - TextInput { - id: textInput - anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } - width: 80 - text: "" - - onAccepted: container.hide() // close dialog when Enter is pressed - } -//![2] - - MouseArea { - anchors.fill: parent - - onClicked: { - if (textInput.text == "" && textInput.opacity > 0) - textInput.openSoftwareInputPanel(); - else - hide(); - } - } - -//![3] -} -//![3] diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js deleted file mode 100755 index 7bb7243914..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js +++ /dev/null @@ -1,226 +0,0 @@ -/* This script file handles the game logic */ -.import QtQuick.LocalStorage 2.0 as Sql - -var maxColumn = 10; -var maxRow = 15; -var maxIndex = maxColumn * maxRow; -var board = new Array(maxIndex); -var component; -var scoresURL = ""; -var gameDuration; - -//Index function used instead of a 2D array -function index(column, row) { - return column + (row * maxColumn); -} - -function startNewGame() { - //Delete blocks from previous game - for (var i = 0; i < maxIndex; i++) { - if (board[i] != null) - board[i].destroy(); - } - - //Calculate board size - maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); - maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); - maxIndex = maxRow * maxColumn; - - //Close dialogs - nameInputDialog.hide(); - dialog.hide(); - - //Initialize Board - board = new Array(maxIndex); - gameCanvas.score = 0; - for (var column = 0; column < maxColumn; column++) { - for (var row = 0; row < maxRow; row++) { - board[index(column, row)] = null; - createBlock(column, row); - } - } - - gameDuration = new Date(); -} - -function createBlock(column, row) { - if (component == null) - component = Qt.createComponent("content/BoomBlock.qml"); - - // Note that if Block.qml was not a local file, component.status would be - // Loading and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and ready before calling createObject(). - if (component.status == Component.Ready) { - var dynamicObject = component.createObject(gameCanvas); - if (dynamicObject == null) { - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.type = Math.floor(Math.random() * 3); - dynamicObject.x = column * gameCanvas.blockSize; - dynamicObject.y = row * gameCanvas.blockSize; - dynamicObject.width = gameCanvas.blockSize; - dynamicObject.height = gameCanvas.blockSize; - dynamicObject.spawned = true; - board[index(column, row)] = dynamicObject; - } else { - console.log("error loading block component"); - console.log(component.errorString()); - return false; - } - return true; -} - -var fillFound; //Set after a floodFill call to the number of blocks found -var floodBoard; //Set to 1 if the floodFill reaches off that node - -function handleClick(xPos, yPos) { - var column = Math.floor(xPos / gameCanvas.blockSize); - var row = Math.floor(yPos / gameCanvas.blockSize); - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (board[index(column, row)] == null) - return; - //If it's a valid block, remove it and all connected (does nothing if it's not connected) - floodFill(column, row, -1); - if (fillFound <= 0) - return; - gameCanvas.score += (fillFound - 1) * (fillFound - 1); - shuffleDown(); - victoryCheck(); -} - -function floodFill(column, row, type) { - if (board[index(column, row)] == null) - return; - var first = false; - if (type == -1) { - first = true; - type = board[index(column, row)].type; - - //Flood fill initialization - fillFound = 0; - floodBoard = new Array(maxIndex); - } - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) - return; - floodBoard[index(column, row)] = 1; - floodFill(column + 1, row, type); - floodFill(column - 1, row, type); - floodFill(column, row + 1, type); - floodFill(column, row - 1, type); - if (first == true && fillFound == 0) - return; //Can't remove single blocks - board[index(column, row)].dying = true; - board[index(column, row)] = null; - fillFound += 1; -} - -function shuffleDown() { - //Fall down - for (var column = 0; column < maxColumn; column++) { - var fallDist = 0; - for (var row = maxRow - 1; row >= 0; row--) { - if (board[index(column, row)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - var obj = board[index(column, row)]; - obj.y = (row + fallDist) * gameCanvas.blockSize; - board[index(column, row + fallDist)] = obj; - board[index(column, row)] = null; - } - } - } - } - //Fall to the left - fallDist = 0; - for (column = 0; column < maxColumn; column++) { - if (board[index(column, maxRow - 1)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - for (row = 0; row < maxRow; row++) { - obj = board[index(column, row)]; - if (obj == null) - continue; - obj.x = (column - fallDist) * gameCanvas.blockSize; - board[index(column - fallDist, row)] = obj; - board[index(column, row)] = null; - } - } - } - } -} - -//![3] -function victoryCheck() { -//![3] - //Award bonus points if no blocks left - var deservesBonus = true; - for (var column = maxColumn - 1; column >= 0; column--) - if (board[index(column, maxRow - 1)] != null) - deservesBonus = false; - if (deservesBonus) - gameCanvas.score += 500; - -//![4] - //Check whether game has finished - if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { - gameDuration = new Date() - gameDuration; - nameInputDialog.showWithInput("You won! Please enter your name: "); - } -} -//![4] - -//only floods up and right, to see if it can find adjacent same-typed blocks -function floodMoveCheck(column, row, type) { - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return false; - if (board[index(column, row)] == null) - return false; - var myType = board[index(column, row)].type; - if (type == myType) - return true; - return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); -} - -//![2] -function saveHighScore(name) { - if (scoresURL != "") - sendHighScore(name); - - var db = Sql.openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores", 100); - var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; - var data = [name, gameCanvas.score, maxColumn + "x" + maxRow, Math.floor(gameDuration / 1000)]; - db.transaction(function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); - tx.executeSql(dataStr, data); - - var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10'); - var r = "\nHIGH SCORES for a standard sized grid\n\n" - for (var i = 0; i < rs.rows.length; i++) { - r += (i + 1) + ". " + rs.rows.item(i).name + ' got ' + rs.rows.item(i).score + ' points in ' + rs.rows.item(i).time + ' seconds.\n'; - } - dialog.show(r); - }); -} -//![2] - -//![1] -function sendHighScore(name) { - var postman = new XMLHttpRequest() - var postData = "name=" + name + "&score=" + gameCanvas.score + "&gridSize=" + maxColumn + "x" + maxRow + "&time=" + Math.floor(gameDuration / 1000); - postman.open("POST", scoresURL, true); - postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - postman.onreadystatechange = function() { - if (postman.readyState == postman.DONE) { - dialog.show("Your score has been uploaded."); - } - } - postman.send(postData); -} -//![1] diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/README b/examples/declarative/tutorials/samegame/samegame4/highscores/README deleted file mode 100644 index eaa00fae37..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/highscores/README +++ /dev/null @@ -1 +0,0 @@ -The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it. diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml b/examples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml deleted file mode 100755 index c3fd90d9cf..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/highscores/score_data.xml +++ /dev/null @@ -1,2 +0,0 @@ -1000000Alan the Tester0x00 -6213Alan12x1751 diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl b/examples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl deleted file mode 100755 index 670354c965..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/highscores/score_style.xsl +++ /dev/null @@ -1,28 +0,0 @@ - - - - - SameGame High Scores - -

          SameGame High Scores

          - - - - - - - - - - - - - - - - -
          NameScoreGrid SizeTime, s
          - - - - diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php b/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php deleted file mode 100755 index daf480e21b..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php +++ /dev/null @@ -1,31 +0,0 @@ -"; - echo "SameGame High Scores"; - if($score > 0){#Sending in a new high score - $name = $_POST["name"]; - $grid = $_POST["gridSize"]; - $time = $_POST["time"]; - if($name == "") - $name = "Anonymous"; - $file = fopen("score_data.xml", "a"); - $ret = fwrite($file, "". $score . "" - . $name . "" . $grid . "" - . $time . "\n"); - echo "Your score has been recorded. Thanks for playing!"; - if($ret == False) - echo "
          There was an error though, so don't expect to see that score again."; - }else{#Read high score list - #Now uses XSLT to display. So just print the file. With XML cruft added. - #Note that firefox at least won't apply the XSLT on a php file. So redirecting - $file = fopen("scores.xml", "w"); - $ret = fwrite($file, '' . "\n" - . '' . "\n" - . "\n" . file_get_contents("score_data.xml") . "\n"); - if($ret == False) - echo "There was an internal error. Sorry."; - else - echo ''; - } - echo ""; -?> diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/tutorials/samegame/samegame4/samegame.qml deleted file mode 100644 index c21b8de8bd..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/samegame.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" -import "content/samegame.js" as SameGame - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - - Item { - id: gameCanvas - property int score: 0 - property int blockSize: 40 - - anchors.centerIn: parent - width: parent.width - (parent.width % blockSize); - height: parent.height - (parent.height % blockSize); - - MouseArea { - anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y); - } - } - } - - Dialog { - id: dialog - anchors.centerIn: parent - z: 100 - } - - //![0] - Dialog { - id: nameInputDialog - anchors.centerIn: parent - z: 100 - - onClosed: { - if (nameInputDialog.inputText != "") - SameGame.saveHighScore(nameInputDialog.inputText); - } - } - //![0] - - Rectangle { - id: toolBar - width: parent.width; height: 30 - color: activePalette.window - anchors.bottom: screen.bottom - - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: SameGame.startNewGame() - } - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: " + gameCanvas.score - } - } -} diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame4.qmlproject b/examples/declarative/tutorials/samegame/samegame4/samegame4.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/tutorials/samegame/samegame4/samegame4.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/tutorials/samegame/shared/pics/background.jpg b/examples/declarative/tutorials/samegame/shared/pics/background.jpg deleted file mode 100644 index 903d395c8d..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/background.jpg and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/blueStar.png b/examples/declarative/tutorials/samegame/shared/pics/blueStar.png deleted file mode 100644 index ff9588f80a..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/blueStar.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/blueStone.png b/examples/declarative/tutorials/samegame/shared/pics/blueStone.png deleted file mode 100644 index 20e43c75b6..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/blueStone.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/greenStar.png b/examples/declarative/tutorials/samegame/shared/pics/greenStar.png deleted file mode 100644 index cd06854719..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/greenStar.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/greenStone.png b/examples/declarative/tutorials/samegame/shared/pics/greenStone.png deleted file mode 100644 index b568a1900c..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/greenStone.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/redStar.png b/examples/declarative/tutorials/samegame/shared/pics/redStar.png deleted file mode 100644 index 0a4dffe583..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/redStar.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/redStone.png b/examples/declarative/tutorials/samegame/shared/pics/redStone.png deleted file mode 100644 index 36b09a2686..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/redStone.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/star.png b/examples/declarative/tutorials/samegame/shared/pics/star.png deleted file mode 100644 index defbde53ca..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/star.png and /dev/null differ diff --git a/examples/declarative/tutorials/samegame/shared/pics/yellowStone.png b/examples/declarative/tutorials/samegame/shared/pics/yellowStone.png deleted file mode 100644 index b1ce76212c..0000000000 Binary files a/examples/declarative/tutorials/samegame/shared/pics/yellowStone.png and /dev/null differ diff --git a/examples/declarative/tutorials/tutorials.pro b/examples/declarative/tutorials/tutorials.pro deleted file mode 100644 index 0a82c1e704..0000000000 --- a/examples/declarative/tutorials/tutorials.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - extending - diff --git a/examples/declarative/tutorials/tutorials.qmlproject b/examples/declarative/tutorials/tutorials.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/tutorials/tutorials.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/twitter/TwitterCore/Button.qml b/examples/declarative/twitter/TwitterCore/Button.qml deleted file mode 100644 index 064fd4b277..0000000000 --- a/examples/declarative/twitter/TwitterCore/Button.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - signal clicked - - property string text - property bool keyUsing: false - - BorderImage { - id: buttonImage - source: "images/toolbutton.sci" - width: container.width; height: container.height - } - BorderImage { - id: pressed - opacity: 0 - source: "images/toolbutton.sci" - width: container.width; height: container.height - } - MouseArea { - id: mouseRegion - anchors.fill: buttonImage - onClicked: { container.clicked(); } - } - Text { - id: btnText - color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";} - anchors.centerIn: buttonImage; font.bold: true - text: container.text; style: Text.Raised; styleColor: "black" - font.pixelSize: 12 - } - states: [ - State { - name: "Pressed" - when: mouseRegion.pressed == true - PropertyChanges { target: pressed; opacity: 1 } - }, - State { - name: "Focused" - when: container.activeFocus == true - PropertyChanges { target: btnText; color: "#FFFFFF" } - } - ] - transitions: Transition { - ColorAnimation { target: btnText; } - } -} diff --git a/examples/declarative/twitter/TwitterCore/FatDelegate.qml b/examples/declarative/twitter/TwitterCore/FatDelegate.qml deleted file mode 100644 index 5fd0d1622b..0000000000 --- a/examples/declarative/twitter/TwitterCore/FatDelegate.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Component { - id: listDelegate - Item { - id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 60){txt.height+10}else{60} //50+5+5 - function handleLink(link){ - if(link.slice(0,3) == 'app'){ - screen.setUser(link.slice(7)); - }else if(link.slice(0,4) == 'http'){ - Qt.openUrlExternally(link); - } - } - function addTags(str){ - var ret = str.replace(/@[a-zA-Z0-9_]+/g, '$&');//click to jump to user? - var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '$&');//surrounds http links with html link tags - return ret2; - } - - // Strip away paranthesis - function userName(str) { - var user = str.replace(/\([\S|\s]*\)/gi, ""); - return user.trim(); - } - - Item { - id: moveMe; height: parent.height - Rectangle { - id: blackRect - color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1 - } - Item { - id: image; x: 6; width: 48; height: 48; smooth: true - anchors.verticalCenter: parent.verticalCenter - - Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready } - Image { - id: realImage; - source: userImage; x: 1; y: 1; - width:48; height:48; opacity:0 ; - onStatusChanged: { - if(status==Image.Ready) - image.state="loaded" - } - } - states: State { - name: "loaded"; - PropertyChanges { target: realImage ; opacity:1 } - } - transitions: Transition { NumberAnimation { target: realImage; property: "opacity"; duration: 200 } } - - } - Text { id:txt; y:4; x: 56 - text: '' - + ''+userName(name) + " from " +source - + "
          " + statusText + ""; - textFormat: Text.StyledText - color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap; linkColor: "#aaccaa" - anchors.left: image.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6 - onLinkActivated: wrapper.handleLink(link) - } - } - } -} diff --git a/examples/declarative/twitter/TwitterCore/Input.qml b/examples/declarative/twitter/TwitterCore/Input.qml deleted file mode 100644 index 2987b9e5d8..0000000000 --- a/examples/declarative/twitter/TwitterCore/Input.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - id:container - width: 220 - height: 28 - BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } - signal accepted - property alias text: input.text - property alias item:input - TextInput{ - id: input - width: parent.width - 12 - anchors.centerIn: parent - maximumLength:21 - font.pixelSize: 16; - font.bold: true - color: "#151515"; selectionColor: "mediumseagreen" - focus: true - onAccepted:{container.accepted()} - text: "" - selectByMouse: true - } -} diff --git a/examples/declarative/twitter/TwitterCore/Loading.qml b/examples/declarative/twitter/TwitterCore/Loading.qml deleted file mode 100644 index 8f7c868bee..0000000000 --- a/examples/declarative/twitter/TwitterCore/Loading.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: loading; source: "images/loading.png" - NumberAnimation on rotation { - from: 0; to: 360; running: loading.visible == true; loops: Animation.Infinite; duration: 900 - } -} diff --git a/examples/declarative/twitter/TwitterCore/MultiTitleBar.qml b/examples/declarative/twitter/TwitterCore/MultiTitleBar.qml deleted file mode 100644 index f52ce5be26..0000000000 --- a/examples/declarative/twitter/TwitterCore/MultiTitleBar.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - TitleBar { id: titleBar; width: parent.width; height: 60; - y: -80 - untaggedString: "Latest tweets from everyone" - taggedString: "Latest tweets from " - } - states: [ - State { - name: "search"; when: screen.state!="search" - PropertyChanges { target: titleBar; y: 0 } - } - ] - transitions: [ - Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } } - ] -} - diff --git a/examples/declarative/twitter/TwitterCore/RssModel.qml b/examples/declarative/twitter/TwitterCore/RssModel.qml deleted file mode 100644 index c4050994e6..0000000000 --- a/examples/declarative/twitter/TwitterCore/RssModel.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -Item { id: wrapper - property variant model: xmlModel - property string from : "" - property string to : "" - property string phrase : "" - - property string mode : "everyone" - property int status: xmlModel.status - function reload() { xmlModel.reload(); } - - XmlListModel { - id: xmlModel - - function encodePhrase(x) { return encodeURIComponent(x); } - - source: (from=="" && to=="" && phrase=="") ? "" : - 'http://search.twitter.com/search.atom?from='+from+"&to="+to+"&phrase="+encodePhrase(phrase) - - namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " + - "declare namespace twitter=\"http://api.twitter.com/\";"; - - query: "/feed/entry" - - XmlRole { name: "statusText"; query: "content/string()" } - XmlRole { name: "timestamp"; query: "published/string()" } - XmlRole { name: "source"; query: "twitter:source/string()" } - XmlRole { name: "name"; query: "author/name/string()" } - XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" } - - } - Binding { - property: "mode" - target: wrapper - value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}} - } -} diff --git a/examples/declarative/twitter/TwitterCore/SearchView.qml b/examples/declarative/twitter/TwitterCore/SearchView.qml deleted file mode 100644 index 82a8559889..0000000000 --- a/examples/declarative/twitter/TwitterCore/SearchView.qml +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - id: wrapper - Column { - anchors.centerIn: parent - spacing: 20 - Column{ - spacing: 4 - Text { - text: "Posted by:" - font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" - horizontalAlignment: Qt.AlignRight - } - Input{ - id: fromIn - KeyNavigation.backtab: searchbutton - KeyNavigation.tab:toIn - onAccepted:searchbutton.doSearch(); - focus: true - } - Text { - text: "In reply to:" - font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" - horizontalAlignment: Qt.AlignRight - } - Input{ - id: toIn - KeyNavigation.backtab: fromIn - KeyNavigation.tab:phraseIn - onAccepted:searchbutton.doSearch(); - } - Text { - text: "Search phrase:" - font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" - horizontalAlignment: Qt.AlignRight - } - Input{ - id: phraseIn - KeyNavigation.backtab: toIn - KeyNavigation.tab:searchbutton - onAccepted:searchbutton.doSearch(); - text: "Qt Quick" - } - } - Button { - width: 100 - height: 32 - id: searchbutton - keyUsing: true; - opacity: 1 - text: "Search" - KeyNavigation.tab: fromIn - Keys.onReturnPressed: searchbutton.doSearch(); - Keys.onEnterPressed: searchbutton.doSearch(); - Keys.onSelectPressed: searchbutton.doSearch(); - Keys.onSpacePressed: searchbutton.doSearch(); - onClicked: searchbutton.doSearch(); - - function doSearch() { - // Search ! allowed - if (wrapper.state=="invalidinput") - return; - - rssModel.from=fromIn.text; - rssModel.to= toIn.text; - rssModel.phrase = phraseIn.text; - screen.focus = true; - screen.state = "" - } - } - } - states: - State { - name: "invalidinput" - when: fromIn.text=="" && toIn.text=="" && phraseIn.text=="" - PropertyChanges { target: searchbutton ; opacity: 0.6 ; } - } - transitions: - Transition { - NumberAnimation { target: searchbutton; property: "opacity"; duration: 200 } - } -} diff --git a/examples/declarative/twitter/TwitterCore/TitleBar.qml b/examples/declarative/twitter/TwitterCore/TitleBar.qml deleted file mode 100644 index 3624048c4d..0000000000 --- a/examples/declarative/twitter/TwitterCore/TitleBar.qml +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: titleBar - property string untaggedString: "Uploads from everyone" - property string taggedString: "Recent uploads tagged " - - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - - Item { - id: container - width: (parent.width * 2) - 55 ; height: parent.height - - function accept() { - titleBar.state = "" - background.state = "" - rssModel.tags = editor.text - } - - Item { - id:imageBox - x: 6; width: 0; height: 50; smooth: true - anchors.verticalCenter: parent.verticalCenter - - UserModel { user: rssModel.from; id: userModel } - Component { - id: imgDelegate; - Item { - id:imageitem - visible:true - Loading { width:48; height:48; visible: realImage.status != Image.Ready } - Image { id: realImage; source: image; width:48; height:48; opacity:0; } - states: - State { - name: "loaded" - when: (realImage.status == Image.Ready) - PropertyChanges { target: realImage; opacity:1 } - } - transitions: Transition { - NumberAnimation { target: realImage; property: "opacity"; duration: 200 } - } - } - } - ListView { id:view; model: userModel.model; x:1; y:1; delegate: imgDelegate } - states: - State { - when: !userModel.user=="" - PropertyChanges { target: imageBox; width: 50; } - } - transitions: - Transition { - NumberAnimation { target: imageBox; property: "width"; duration: 200 } - } - } - - Image { - id: quitButton - x: 5 - anchors.verticalCenter: parent.verticalCenter - source: "images/quit.png" - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - } - - Text { - id: categoryText - anchors { - left: quitButton.right; right: parent.right; leftMargin: 10; rightMargin: 10 - verticalCenter: parent.verticalCenter - } - elide: Text.ElideLeft - text: (rssModel.from=="" ? untaggedString : taggedString + rssModel.from) - font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black" - font.pixelSize: 12 - } - } - - states: State { - name: "Tags" - PropertyChanges { target: container; x: -tagButton.x + 5 } - PropertyChanges { target: editor; focus: true } - } - - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } - } -} diff --git a/examples/declarative/twitter/TwitterCore/ToolBar.qml b/examples/declarative/twitter/TwitterCore/ToolBar.qml deleted file mode 100644 index 06d3324ee3..0000000000 --- a/examples/declarative/twitter/TwitterCore/ToolBar.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: toolbar - - property alias button1Label: button1.text - property alias button2Label: button2.text - signal button1Clicked - signal button2Clicked - focus:true - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - Button { - id: button1 - anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32 - onClicked: toolbar.button1Clicked() - focus:true - } - Button { - id: button2 - anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32 - onClicked: toolbar.button2Clicked() - } -} diff --git a/examples/declarative/twitter/TwitterCore/UserModel.qml b/examples/declarative/twitter/TwitterCore/UserModel.qml deleted file mode 100644 index f88837c344..0000000000 --- a/examples/declarative/twitter/TwitterCore/UserModel.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -//This "model" gets the user information about the searched user. Mainly for the icon. - -Item { id: wrapper - property variant model: xmlModel - property string user : "" - property int status: xmlModel.status - function reload() { xmlModel.reload(); } - XmlListModel { - id: xmlModel - - source: user!= "" ? "http://twitter.com/users/show.xml?screen_name="+user : "" - query: "/user" - - XmlRole { name: "name"; query: "name/string()" } - XmlRole { name: "screenName"; query: "screen_name/string()" } - XmlRole { name: "image"; query: "profile_image_url/string()" } - XmlRole { name: "location"; query: "location/string()" } - XmlRole { name: "description"; query: "description/string()" } - XmlRole { name: "followers"; query: "followers_count/string()" } - //TODO: Could also get the user's color scheme, timezone and a few other things - } -} diff --git a/examples/declarative/twitter/TwitterCore/images/gloss.png b/examples/declarative/twitter/TwitterCore/images/gloss.png deleted file mode 100644 index 5d370cd93d..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/gloss.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/lineedit.png b/examples/declarative/twitter/TwitterCore/images/lineedit.png deleted file mode 100644 index 2cc38dc35b..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/lineedit.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/lineedit.sci b/examples/declarative/twitter/TwitterCore/images/lineedit.sci deleted file mode 100644 index 054bff78be..0000000000 --- a/examples/declarative/twitter/TwitterCore/images/lineedit.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 10 -border.bottom: 10 -border.right: 10 -source: lineedit.png diff --git a/examples/declarative/twitter/TwitterCore/images/loading.png b/examples/declarative/twitter/TwitterCore/images/loading.png deleted file mode 100644 index 47a1589c5d..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/loading.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/quit.png b/examples/declarative/twitter/TwitterCore/images/quit.png deleted file mode 100644 index 5bda1b6e0d..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/quit.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/stripes.png b/examples/declarative/twitter/TwitterCore/images/stripes.png deleted file mode 100644 index 9f36727ea4..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/stripes.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/titlebar.png b/examples/declarative/twitter/TwitterCore/images/titlebar.png deleted file mode 100644 index 51c90082d0..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/titlebar.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/titlebar.sci b/examples/declarative/twitter/TwitterCore/images/titlebar.sci deleted file mode 100644 index 0418d94cd6..0000000000 --- a/examples/declarative/twitter/TwitterCore/images/titlebar.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 12 -border.bottom: 12 -border.right: 10 -source: titlebar.png diff --git a/examples/declarative/twitter/TwitterCore/images/toolbutton.png b/examples/declarative/twitter/TwitterCore/images/toolbutton.png deleted file mode 100644 index 11310013ee..0000000000 Binary files a/examples/declarative/twitter/TwitterCore/images/toolbutton.png and /dev/null differ diff --git a/examples/declarative/twitter/TwitterCore/images/toolbutton.sci b/examples/declarative/twitter/TwitterCore/images/toolbutton.sci deleted file mode 100644 index 9e4f965307..0000000000 --- a/examples/declarative/twitter/TwitterCore/images/toolbutton.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 15 -border.top: 4 -border.bottom: 4 -border.right: 15 -source: toolbutton.png diff --git a/examples/declarative/twitter/TwitterCore/qmldir b/examples/declarative/twitter/TwitterCore/qmldir deleted file mode 100644 index 452a648b23..0000000000 --- a/examples/declarative/twitter/TwitterCore/qmldir +++ /dev/null @@ -1,10 +0,0 @@ -SearchView 2.0 SearchView.qml -Button 2.0 Button.qml -Input 2.0 Input.qml -FatDelegate 2.0 FatDelegate.qml -Loading 2.0 Loading.qml -MultiTitleBar 2.0 MultiTitleBar.qml -TitleBar 2.0 TitleBar.qml -RssModel 2.0 RssModel.qml -UserModel 2.0 UserModel.qml -ToolBar 2.0 ToolBar.qml diff --git a/examples/declarative/twitter/twitter.qml b/examples/declarative/twitter/twitter.qml deleted file mode 100644 index 26e4a7079b..0000000000 --- a/examples/declarative/twitter/twitter.qml +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 -import "TwitterCore" 2.0 as Twitter - -Item { - id: screen; width: 320; height: 480 - property bool userView : false - property variant tmpStr - function setUser(str){hack.running = true; tmpStr = str} - function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""} - state:"searchquery" - //Workaround for bug 260266 - Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack } - Keys.onEscapePressed: screen.state="searchquery" - Keys.onBacktabPressed: screen.state="searchquery" - Rectangle { - id: background - anchors.fill: parent; color: "#343434"; - - state:"searchquery" - Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } - - MouseArea { - anchors.fill: parent - onClicked: screen.focus = false; - } - - Twitter.RssModel { id: rssModel } - Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'} - Text { - width: 180 - text: "Could not access twitter using this screen name and password pair."; - color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap - visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent - } - - Item { - id: views - x: 2; width: parent.width - 4 - y:60 //Below the title bars - height: parent.height - 100 - - Text { - id:title - text: "Search Twitter" - anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black" - opacity:0 - } - - Twitter.SearchView{ - id: searchView - anchors.verticalCenter: parent.verticalCenter - width: parent.width; height: parent.height-60; - x: -(screen.width * 1.5) - } - - Twitter.FatDelegate { id: fatDelegate } - ListView { - id: mainView; model: rssModel.model; delegate: fatDelegate; - width: parent.width; height: parent.height; x: 0; cacheBuffer: 100; - } - } - - Twitter.MultiTitleBar { id: titleBar; width: parent.width } - Twitter.ToolBar { id: toolBar; height: 40; - //anchors.bottom: parent.bottom; - //TODO: Use anchor changes instead of hard coding - y: screen.height - 40 - width: parent.width; opacity: 0.9 - button1Label: "New Search" - button2Label: "Update" - onButton1Clicked: - { - screen.state="searchquery" - } - onButton2Clicked: rssModel.reload(); - } - } - states: [ - State { - name: "searchquery"; - PropertyChanges { target: searchView; x: 0; focus:true} - PropertyChanges { target: mainView; x: -(parent.width * 1.5) } - PropertyChanges { target: titleBar; y: -80 } - PropertyChanges { target: toolBar; y: screen.height } - PropertyChanges { target: toolBar } - PropertyChanges { target: title; opacity:1} - } - ] - transitions: [ - Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } } - ] -} diff --git a/examples/declarative/twitter/twitter.qmlproject b/examples/declarative/twitter/twitter.qmlproject deleted file mode 100644 index b14f71fdfd..0000000000 --- a/examples/declarative/twitter/twitter.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "twitter.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/ui-components/dialcontrol/content/Dial.qml b/examples/declarative/ui-components/dialcontrol/content/Dial.qml deleted file mode 100644 index c61adee364..0000000000 --- a/examples/declarative/ui-components/dialcontrol/content/Dial.qml +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: root - property real value : 0 - - width: 210; height: 210 - - Image { source: "background.png" } - -//! [needle_shadow] - Image { - x: 96 - y: 35 - source: "needle_shadow.png" - transform: Rotation { - origin.x: 9; origin.y: 67 - angle: needleRotation.angle - } - } -//! [needle_shadow] -//! [needle] - Image { - id: needle - x: 98; y: 33 - smooth: true - source: "needle.png" - transform: Rotation { - id: needleRotation - origin.x: 5; origin.y: 65 - //! [needle angle] - angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) - Behavior on angle { - SpringAnimation { - spring: 1.4 - damping: .15 - } - } - //! [needle angle] - } - } -//! [needle] -//! [overlay] - Image { x: 21; y: 18; source: "overlay.png" } -//! [overlay] -} diff --git a/examples/declarative/ui-components/dialcontrol/content/QuitButton.qml b/examples/declarative/ui-components/dialcontrol/content/QuitButton.qml deleted file mode 100644 index 702b892d23..0000000000 --- a/examples/declarative/ui-components/dialcontrol/content/QuitButton.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -Image { - source: "quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -10 - onClicked: Qt.quit() - } -} diff --git a/examples/declarative/ui-components/dialcontrol/content/background.png b/examples/declarative/ui-components/dialcontrol/content/background.png deleted file mode 100644 index 75d555d7ab..0000000000 Binary files a/examples/declarative/ui-components/dialcontrol/content/background.png and /dev/null differ diff --git a/examples/declarative/ui-components/dialcontrol/content/needle.png b/examples/declarative/ui-components/dialcontrol/content/needle.png deleted file mode 100644 index 2d19f75039..0000000000 Binary files a/examples/declarative/ui-components/dialcontrol/content/needle.png and /dev/null differ diff --git a/examples/declarative/ui-components/dialcontrol/content/needle_shadow.png b/examples/declarative/ui-components/dialcontrol/content/needle_shadow.png deleted file mode 100644 index 8d8a928cc5..0000000000 Binary files a/examples/declarative/ui-components/dialcontrol/content/needle_shadow.png and /dev/null differ diff --git a/examples/declarative/ui-components/dialcontrol/content/overlay.png b/examples/declarative/ui-components/dialcontrol/content/overlay.png deleted file mode 100644 index 3860a7b590..0000000000 Binary files a/examples/declarative/ui-components/dialcontrol/content/overlay.png and /dev/null differ diff --git a/examples/declarative/ui-components/dialcontrol/content/quit.png b/examples/declarative/ui-components/dialcontrol/content/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/declarative/ui-components/dialcontrol/content/quit.png and /dev/null differ diff --git a/examples/declarative/ui-components/dialcontrol/dialcontrol.qml b/examples/declarative/ui-components/dialcontrol/dialcontrol.qml deleted file mode 100644 index d645b34aa4..0000000000 --- a/examples/declarative/ui-components/dialcontrol/dialcontrol.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import QtQuick 2.0 -import "content" -//! [imports] - -//! [0] -Rectangle { - color: "#545454" - width: 300; height: 300 - - // Dial with a slider to adjust it - Dial { - id: dial - anchors.centerIn: parent - value: slider.x * 100 / (container.width - 34) - } - - Rectangle { - id: container - anchors { bottom: parent.bottom; left: parent.left - right: parent.right; leftMargin: 20; rightMargin: 20 - bottomMargin: 10 - } - height: 16 - - radius: 8 - opacity: 0.7 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "gray" } - GradientStop { position: 1.0; color: "white" } - } - - Rectangle { - id: slider - x: 1; y: 1; width: 30; height: 14 - radius: 6 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#424242" } - GradientStop { position: 1.0; color: "black" } - } - - MouseArea { - anchors.fill: parent - anchors.margins: -16 // Increase mouse area a lot outside the slider - drag.target: parent; drag.axis: Drag.XAxis - drag.minimumX: 2; drag.maximumX: container.width - 32 - } - } - } - QuitButton { - anchors.right: parent.right - anchors.top: parent.top - anchors.margins: 10 - } -} -//! [0] diff --git a/examples/declarative/ui-components/flipable/content/5_heart.png b/examples/declarative/ui-components/flipable/content/5_heart.png deleted file mode 100644 index fb59d81453..0000000000 Binary files a/examples/declarative/ui-components/flipable/content/5_heart.png and /dev/null differ diff --git a/examples/declarative/ui-components/flipable/content/9_club.png b/examples/declarative/ui-components/flipable/content/9_club.png deleted file mode 100644 index 2545001904..0000000000 Binary files a/examples/declarative/ui-components/flipable/content/9_club.png and /dev/null differ diff --git a/examples/declarative/ui-components/flipable/content/Card.qml b/examples/declarative/ui-components/flipable/content/Card.qml deleted file mode 100644 index 6006ea14fc..0000000000 --- a/examples/declarative/ui-components/flipable/content/Card.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Flipable { - id: container - - property alias source: frontImage.source - property bool flipped: true - property int xAxis: 0 - property int yAxis: 0 - property int angle: 0 - - width: front.width; height: front.height - - front: Image { id: frontImage; smooth: true } - back: Image { source: "back.png"; smooth: true } - - state: "back" - - MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } - - transform: Rotation { - id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 - axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 - } - - states: State { - name: "back"; when: container.flipped - PropertyChanges { target: rotation; angle: container.angle } - } - - transitions: Transition { - ParallelAnimation { - NumberAnimation { target: rotation; properties: "angle"; duration: 600 } - SequentialAnimation { - NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } - NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } - } - } - } -} diff --git a/examples/declarative/ui-components/flipable/content/back.png b/examples/declarative/ui-components/flipable/content/back.png deleted file mode 100644 index f715d7487e..0000000000 Binary files a/examples/declarative/ui-components/flipable/content/back.png and /dev/null differ diff --git a/examples/declarative/ui-components/flipable/flipable.qml b/examples/declarative/ui-components/flipable/flipable.qml deleted file mode 100644 index 4af64afc53..0000000000 --- a/examples/declarative/ui-components/flipable/flipable.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "darkgreen" - - Row { - anchors.centerIn: parent; spacing: 30 - Card { source: "content/9_club.png"; angle: 180; yAxis: 1 } - Card { source: "content/5_heart.png"; angle: 540; xAxis: 1 } - } -} diff --git a/examples/declarative/ui-components/progressbar/content/ProgressBar.qml b/examples/declarative/ui-components/progressbar/content/ProgressBar.qml deleted file mode 100644 index c9be8d7336..0000000000 --- a/examples/declarative/ui-components/progressbar/content/ProgressBar.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: progressbar - - property int minimum: 0 - property int maximum: 100 - property int value: 0 - property alias color: gradient1.color - property alias secondColor: gradient2.color - - width: 250; height: 23 - clip: true - - BorderImage { - source: "background.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - Rectangle { - id: highlight - - property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) - - width: highlight.widthDest - Behavior on width { SmoothedAnimation { velocity: 1200 } } - - anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 } - radius: 1 - gradient: Gradient { - GradientStop { id: gradient1; position: 0.0 } - GradientStop { id: gradient2; position: 1.0 } - } - - } - Text { - anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } - color: "white" - font.bold: true - text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' - } -} diff --git a/examples/declarative/ui-components/progressbar/content/background.png b/examples/declarative/ui-components/progressbar/content/background.png deleted file mode 100644 index 9044226f85..0000000000 Binary files a/examples/declarative/ui-components/progressbar/content/background.png and /dev/null differ diff --git a/examples/declarative/ui-components/progressbar/main.qml b/examples/declarative/ui-components/progressbar/main.qml deleted file mode 100644 index 367e4c1265..0000000000 --- a/examples/declarative/ui-components/progressbar/main.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - id: main - - width: 600; height: 405 - color: "#edecec" - - Flickable { - anchors.fill: parent - contentHeight: column.height + 20 - - Column { - id: column - x: 10; y: 10 - spacing: 10 - - Repeater { - model: 25 - - ProgressBar { - property int r: Math.floor(Math.random() * 5000 + 1000) - width: main.width - 20 - - NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } - ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } - ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } - } - } - } - } -} diff --git a/examples/declarative/ui-components/scrollbar/ScrollBar.qml b/examples/declarative/ui-components/scrollbar/ScrollBar.qml deleted file mode 100644 index a3d0d3841c..0000000000 --- a/examples/declarative/ui-components/scrollbar/ScrollBar.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: scrollBar - - // The properties that define the scrollbar's state. - // position and pageSize are in the range 0.0 - 1.0. They are relative to the - // height of the page, i.e. a pageSize of 0.5 means that you can see 50% - // of the height of the view. - // orientation can be either Qt.Vertical or Qt.Horizontal - property real position - property real pageSize - property variant orientation : Qt.Vertical - - // A light, semi-transparent background - Rectangle { - id: background - anchors.fill: parent - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "white" - opacity: 0.3 - } - - // Size the bar to the required size, depending upon the orientation. - Rectangle { - x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) - y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 - width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) - height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "black" - opacity: 0.7 - } -} diff --git a/examples/declarative/ui-components/scrollbar/main.qml b/examples/declarative/ui-components/scrollbar/main.qml deleted file mode 100644 index a7d602b437..0000000000 --- a/examples/declarative/ui-components/scrollbar/main.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 640 - height: 480 - - // Create a flickable to view a large image. - Flickable { - id: view - anchors.fill: parent - contentWidth: picture.width - contentHeight: picture.height - - Image { - id: picture - source: "pics/niagara_falls.jpg" - asynchronous: true - } - - // Only show the scrollbars when the view is moving. - states: State { - name: "ShowBars" - when: view.movingVertically || view.movingHorizontally - PropertyChanges { target: verticalScrollBar; opacity: 1 } - PropertyChanges { target: horizontalScrollBar; opacity: 1 } - } - - transitions: Transition { - NumberAnimation { properties: "opacity"; duration: 400 } - } - } - - // Attach scrollbars to the right and bottom edges of the view. - ScrollBar { - id: verticalScrollBar - width: 12; height: view.height-12 - anchors.right: view.right - opacity: 0 - orientation: Qt.Vertical - position: view.visibleArea.yPosition - pageSize: view.visibleArea.heightRatio - } - - ScrollBar { - id: horizontalScrollBar - width: view.width-12; height: 12 - anchors.bottom: view.bottom - opacity: 0 - orientation: Qt.Horizontal - position: view.visibleArea.xPosition - pageSize: view.visibleArea.widthRatio - } -} diff --git a/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg b/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg deleted file mode 100644 index e625c0d3e6..0000000000 Binary files a/examples/declarative/ui-components/scrollbar/pics/niagara_falls.jpg and /dev/null differ diff --git a/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject b/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/ui-components/scrollbar/scrollbar.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/ui-components/searchbox/SearchBox.qml b/examples/declarative/ui-components/searchbox/SearchBox.qml deleted file mode 100644 index 6f6f486412..0000000000 --- a/examples/declarative/ui-components/searchbox/SearchBox.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - id: focusScope - width: 250; height: 28 - - BorderImage { - source: "images/lineedit-bg.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - BorderImage { - source: "images/lineedit-bg-focus.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - visible: parent.activeFocus ? true : false - } - - Text { - id: typeSomething - anchors.fill: parent; anchors.leftMargin: 8 - verticalAlignment: Text.AlignVCenter - text: "Type something..." - color: "gray" - font.italic: true - } - - MouseArea { - anchors.fill: parent - onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); } - } - - TextInput { - id: textInput - anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter } - focus: true - selectByMouse: true - } - - Image { - id: clear - anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter } - source: "images/clear.png" - opacity: 0 - - MouseArea { - anchors.fill: parent - onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); } - } - } - - states: State { - name: "hasText"; when: textInput.text != '' - PropertyChanges { target: typeSomething; opacity: 0 } - PropertyChanges { target: clear; opacity: 1 } - } - - transitions: [ - Transition { - from: ""; to: "hasText" - NumberAnimation { exclude: typeSomething; properties: "opacity" } - }, - Transition { - from: "hasText"; to: "" - NumberAnimation { properties: "opacity" } - } - ] -} diff --git a/examples/declarative/ui-components/searchbox/images/clear.png b/examples/declarative/ui-components/searchbox/images/clear.png deleted file mode 100644 index 91eb270695..0000000000 Binary files a/examples/declarative/ui-components/searchbox/images/clear.png and /dev/null differ diff --git a/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png deleted file mode 100644 index bbfac38d2d..0000000000 Binary files a/examples/declarative/ui-components/searchbox/images/lineedit-bg-focus.png and /dev/null differ diff --git a/examples/declarative/ui-components/searchbox/images/lineedit-bg.png b/examples/declarative/ui-components/searchbox/images/lineedit-bg.png deleted file mode 100644 index 9044226f85..0000000000 Binary files a/examples/declarative/ui-components/searchbox/images/lineedit-bg.png and /dev/null differ diff --git a/examples/declarative/ui-components/searchbox/main.qml b/examples/declarative/ui-components/searchbox/main.qml deleted file mode 100644 index 6e9731cf9c..0000000000 --- a/examples/declarative/ui-components/searchbox/main.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - width: 500; height: 250 - color: "#edecec" - - MouseArea { - anchors.fill: parent - onClicked: page.focus = false; - } - Column { - anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } - spacing: 10 - - SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } - SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } - SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } - } -} diff --git a/examples/declarative/ui-components/searchbox/searchbox.qmlproject b/examples/declarative/ui-components/searchbox/searchbox.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/ui-components/searchbox/searchbox.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/ui-components/slideswitch/content/Switch.qml b/examples/declarative/ui-components/slideswitch/content/Switch.qml deleted file mode 100644 index 981fc16673..0000000000 --- a/examples/declarative/ui-components/slideswitch/content/Switch.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Item { - id: toggleswitch - width: background.width; height: background.height - -//![1] - property bool on: false -//![1] - -//![2] - function toggle() { - if (toggleswitch.state == "on") - toggleswitch.state = "off"; - else - toggleswitch.state = "on"; - } -//![2] - -//![3] - function releaseSwitch() { - if (knob.x == 1) { - if (toggleswitch.state == "off") return; - } - if (knob.x == 78) { - if (toggleswitch.state == "on") return; - } - toggle(); - } -//![3] - -//![4] - Image { - id: background - source: "background.png" - MouseArea { anchors.fill: parent; onClicked: toggle() } - } -//![4] - -//![5] - Image { - id: knob - x: 1; y: 2 - source: "knob.png" - - MouseArea { - anchors.fill: parent - drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78 - onClicked: toggle() - onReleased: releaseSwitch() - } - } -//![5] - -//![6] - states: [ - State { - name: "on" - PropertyChanges { target: knob; x: 78 } - PropertyChanges { target: toggleswitch; on: true } - }, - State { - name: "off" - PropertyChanges { target: knob; x: 1 } - PropertyChanges { target: toggleswitch; on: false } - } - ] -//![6] - -//![7] - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 } - } -//![7] -} -//![0] diff --git a/examples/declarative/ui-components/slideswitch/content/background.png b/examples/declarative/ui-components/slideswitch/content/background.png deleted file mode 100644 index d736815870..0000000000 Binary files a/examples/declarative/ui-components/slideswitch/content/background.png and /dev/null differ diff --git a/examples/declarative/ui-components/slideswitch/content/background.svg b/examples/declarative/ui-components/slideswitch/content/background.svg deleted file mode 100644 index f920d3e47a..0000000000 --- a/examples/declarative/ui-components/slideswitch/content/background.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - -]> - - - - - - - - - - - - - - diff --git a/examples/declarative/ui-components/slideswitch/content/knob.png b/examples/declarative/ui-components/slideswitch/content/knob.png deleted file mode 100644 index ee0a436f84..0000000000 Binary files a/examples/declarative/ui-components/slideswitch/content/knob.png and /dev/null differ diff --git a/examples/declarative/ui-components/slideswitch/content/knob.svg b/examples/declarative/ui-components/slideswitch/content/knob.svg deleted file mode 100644 index fb6933718e..0000000000 --- a/examples/declarative/ui-components/slideswitch/content/knob.svg +++ /dev/null @@ -1,867 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/ui-components/slideswitch/slideswitch.qml b/examples/declarative/ui-components/slideswitch/slideswitch.qml deleted file mode 100644 index 60a331407c..0000000000 --- a/examples/declarative/ui-components/slideswitch/slideswitch.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - color: "white" - width: 400; height: 250 - -//![0] - Switch { anchors.centerIn: parent; on: false } -//![0] -} diff --git a/examples/declarative/ui-components/spinner/content/Spinner.qml b/examples/declarative/ui-components/spinner/content/Spinner.qml deleted file mode 100644 index d7bbeb33ee..0000000000 --- a/examples/declarative/ui-components/spinner/content/Spinner.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - property alias model: view.model - property alias delegate: view.delegate - property alias currentIndex: view.currentIndex - property real itemHeight: 30 - - source: "spinner-bg.png" - clip: true - - PathView { - id: view - anchors.fill: parent - - pathItemCount: height/itemHeight - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } - dragMargin: view.width/2 - - path: Path { - startX: view.width/2; startY: -itemHeight/2 - PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } - } - } - - Keys.onDownPressed: view.incrementCurrentIndex() - Keys.onUpPressed: view.decrementCurrentIndex() -} diff --git a/examples/declarative/ui-components/spinner/content/spinner-bg.png b/examples/declarative/ui-components/spinner/content/spinner-bg.png deleted file mode 100644 index b3556f1f9f..0000000000 Binary files a/examples/declarative/ui-components/spinner/content/spinner-bg.png and /dev/null differ diff --git a/examples/declarative/ui-components/spinner/content/spinner-select.png b/examples/declarative/ui-components/spinner/content/spinner-select.png deleted file mode 100644 index 95a17a1fe2..0000000000 Binary files a/examples/declarative/ui-components/spinner/content/spinner-select.png and /dev/null differ diff --git a/examples/declarative/ui-components/spinner/main.qml b/examples/declarative/ui-components/spinner/main.qml deleted file mode 100644 index 7584c98396..0000000000 --- a/examples/declarative/ui-components/spinner/main.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - width: 240; height: 320 - - Column { - y: 20; x: 20; spacing: 20 - - Spinner { - id: spinner - width: 200; height: 240 - focus: true - model: 20 - itemHeight: 30 - delegate: Text { font.pixelSize: 25; text: index; height: 30 } - } - - Text { text: "Current item index: " + spinner.currentIndex } - } -} diff --git a/examples/declarative/ui-components/spinner/spinner.qmlproject b/examples/declarative/ui-components/spinner/spinner.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/ui-components/spinner/spinner.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/ui-components/tabwidget/TabWidget.qml b/examples/declarative/ui-components/tabwidget/TabWidget.qml deleted file mode 100644 index 560ed1f58a..0000000000 --- a/examples/declarative/ui-components/tabwidget/TabWidget.qml +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: tabWidget - - // Setting the default property to stack.children means any child items - // of the TabWidget are actually added to the 'stack' item's children. - // See the "Property Binding" - // documentation for details on default properties. - default property alias content: stack.children - - property int current: 0 - - onCurrentChanged: setOpacities() - Component.onCompleted: setOpacities() - - function setOpacities() { - for (var i = 0; i < stack.children.length; ++i) { - stack.children[i].opacity = (i == current ? 1 : 0) - } - } - - Row { - id: header - - Repeater { - model: stack.children.length - delegate: Rectangle { - width: tabWidget.width / stack.children.length; height: 36 - - Rectangle { - width: parent.width; height: 1 - anchors { bottom: parent.bottom; bottomMargin: 1 } - color: "#acb2c2" - } - BorderImage { - anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } - border { left: 7; right: 7 } - source: "tab.png" - visible: tabWidget.current == index - } - Text { - horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter - anchors.fill: parent - text: stack.children[index].title - elide: Text.ElideRight - font.bold: tabWidget.current == index - } - MouseArea { - anchors.fill: parent - onClicked: tabWidget.current = index - } - } - } - } - - Item { - id: stack - width: tabWidget.width - anchors.top: header.bottom; anchors.bottom: tabWidget.bottom - } -} diff --git a/examples/declarative/ui-components/tabwidget/main.qml b/examples/declarative/ui-components/tabwidget/main.qml deleted file mode 100644 index df99c11b7d..0000000000 --- a/examples/declarative/ui-components/tabwidget/main.qml +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -TabWidget { - id: tabs - width: 640; height: 480 - - Rectangle { - property string title: "Red" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#ff7f7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Roses are red" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Green" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#7fff7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Flower stems are green" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Blue" - anchors.fill: parent; color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#7f7fff" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Violets are blue" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } -} diff --git a/examples/declarative/ui-components/tabwidget/tab.png b/examples/declarative/ui-components/tabwidget/tab.png deleted file mode 100644 index ad8021605f..0000000000 Binary files a/examples/declarative/ui-components/tabwidget/tab.png and /dev/null differ diff --git a/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject b/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/ui-components/tabwidget/tabwidget.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/window/Window.qml b/examples/declarative/window/Window.qml deleted file mode 100644 index 48478458c6..0000000000 --- a/examples/declarative/window/Window.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Window.Window { - width: 640 - height: 480 - visible: true //It's false by default - property Component self - Component.onCompleted: self = Qt.createComponent("Window.qml") - Text{ - text: "Hello World!" - anchors.centerIn: parent - } - MouseArea{ - anchors.fill: parent - onClicked: self.createObject(); - } -} diff --git a/examples/declarative/window/screen/screenInfo.qml b/examples/declarative/window/screen/screenInfo.qml deleted file mode 100644 index 54299ba4e0..0000000000 --- a/examples/declarative/window/screen/screenInfo.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Item { - id: root - width: 400 - height: 200 - Item { - id: main - state: "orientation " + Window.Screen.orientation - - property bool landscapeWindow: Window.Screen.primaryOrientation == Qt.LandscapeOrientation - property real baseWidth: landscapeWindow ? root.height : root.width - property real baseHeight: landscapeWindow ? root.width : root.height - property real rotationDelta: landscapeWindow ? -90 : 0 - - rotation: rotationDelta - width: main.baseWidth - height: main.baseHeight - anchors.centerIn: parent - - Text { - text: "Screen is " + Window.Screen.width + "x" + Window.Screen.height + " and primarily orientation " + Window.Screen.primaryOrientation - anchors.centerIn:parent - } - - - states: [ - State { - name: "orientation " + Qt.LandscapeOrientation - PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - }, - State { - name: "orientation " + Qt.InvertedPortraitOrientation - PropertyChanges { target: main; rotation: 180 + rotationDelta; } - }, - State { - name: "orientation " + Qt.InvertedLandscapeOrientation - PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } - } - ] - - transitions: Transition { - SequentialAnimation { - RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } - NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } - } - } - } -} diff --git a/examples/declarative/window/standalone.qml b/examples/declarative/window/standalone.qml deleted file mode 100644 index 335cf7b635..0000000000 --- a/examples/declarative/window/standalone.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Window 2.0 as Window - -Item { - width: 640 - height: 480 - Text { - anchors.centerIn: parent - text: "First Window" - } - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - Window.Window { - width: 640 - height: 480 - x: 640 - y: 480 - visible: true - color: "green" - Text { - anchors.centerIn: parent - text: "Second Window" - } - MouseArea{ - anchors.fill: parent - onClicked: Qt.quit() - } - } -} diff --git a/examples/declarative/window/window.cpp b/examples/declarative/window/window.cpp deleted file mode 100644 index 4854256190..0000000000 --- a/examples/declarative/window/window.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -int main(int argc, char* argv[]) -{ - QGuiApplication app(argc, argv); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.loadUrl(QUrl::fromLocalFile("Window.qml")); - if ( component.isReady() ) - component.create(); - else - qWarning() << component.errorString(); - return app.exec(); -} diff --git a/examples/declarative/window/window.pro b/examples/declarative/window/window.pro deleted file mode 100644 index 74804bd776..0000000000 --- a/examples/declarative/window/window.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = app -CONFIG += qt -QT += declarative - -SOURCES += window.cpp diff --git a/examples/declarative/xml/xmlhttprequest/data.xml b/examples/declarative/xml/xmlhttprequest/data.xml deleted file mode 100644 index 8b7f1e116d..0000000000 --- a/examples/declarative/xml/xmlhttprequest/data.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/examples/declarative/xml/xmlhttprequest/xmlhttprequest-example.qml b/examples/declarative/xml/xmlhttprequest/xmlhttprequest-example.qml deleted file mode 100644 index 28ba078160..0000000000 --- a/examples/declarative/xml/xmlhttprequest/xmlhttprequest-example.qml +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - width: 350; height: 400 - - function showRequestInfo(text) { - log.text = log.text + "\n" + text - console.log(text) - } - - Text { id: log; anchors.fill: parent; anchors.margins: 10 } - - Rectangle { - id: button - anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.margins: 10 - width: buttonText.width + 10; height: buttonText.height + 10 - border.width: mouseArea.pressed ? 2 : 1 - radius : 5; smooth: true - - Text { id: buttonText; anchors.centerIn: parent; text: "Request data.xml" } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - log.text = "" - console.log("\n") - - var doc = new XMLHttpRequest(); - doc.onreadystatechange = function() { - if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - showRequestInfo("Headers -->"); - showRequestInfo(doc.getAllResponseHeaders ()); - showRequestInfo("Last modified -->"); - showRequestInfo(doc.getResponseHeader ("Last-Modified")); - - } else if (doc.readyState == XMLHttpRequest.DONE) { - var a = doc.responseXML.documentElement; - for (var ii = 0; ii < a.childNodes.length; ++ii) { - showRequestInfo(a.childNodes[ii].nodeName); - } - showRequestInfo("Headers -->"); - showRequestInfo(doc.getAllResponseHeaders ()); - showRequestInfo("Last modified -->"); - showRequestInfo(doc.getResponseHeader ("Last-Modified")); - } - } - - doc.open("GET", "data.xml"); - doc.send(); - } - } - } -} - diff --git a/examples/demos/calculator/CalculatorCore/Button.qml b/examples/demos/calculator/CalculatorCore/Button.qml new file mode 100644 index 0000000000..872fc81174 --- /dev/null +++ b/examples/demos/calculator/CalculatorCore/Button.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +BorderImage { + id: button + + property alias operation: buttonText.text + property string color: "" + + Accessible.name: operation + Accessible.description: "This button does " + operation + Accessible.role: Accessible.Button + + signal clicked + + source: "images/button-" + color + ".png"; clip: true + border { left: 10; top: 10; right: 10; bottom: 10 } + + Rectangle { + id: shade + anchors.fill: button; radius: 10; color: "black"; opacity: 0 + } + + Text { + id: buttonText + anchors.centerIn: parent; anchors.verticalCenterOffset: -1 + font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5 + style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + window.doOp(operation) + button.clicked() + } + } + + states: State { + name: "pressed"; when: mouseArea.pressed == true + PropertyChanges { target: shade; opacity: .4 } + } +} diff --git a/examples/demos/calculator/CalculatorCore/Display.qml b/examples/demos/calculator/CalculatorCore/Display.qml new file mode 100644 index 0000000000..3333484971 --- /dev/null +++ b/examples/demos/calculator/CalculatorCore/Display.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +BorderImage { + id: image + + property alias text : displayText.text + property alias currentOperation : operationText + + source: "images/display.png" + border { left: 10; top: 10; right: 10; bottom: 10 } + + Text { + id: displayText + anchors { + right: parent.right; verticalCenter: parent.verticalCenter; verticalCenterOffset: -1 + rightMargin: 6; left: operationText.right + } + font.pixelSize: parent.height * .6; text: "0"; horizontalAlignment: Text.AlignRight; elide: Text.ElideRight + color: "#343434"; smooth: true; font.bold: true + } + Text { + id: operationText + font.bold: true; font.pixelSize: parent.height * .7 + color: "#343434"; smooth: true + anchors { left: parent.left; leftMargin: 6; verticalCenterOffset: -3; verticalCenter: parent.verticalCenter } + } +} diff --git a/examples/demos/calculator/CalculatorCore/calculator.js b/examples/demos/calculator/CalculatorCore/calculator.js new file mode 100644 index 0000000000..e2b5692cf3 --- /dev/null +++ b/examples/demos/calculator/CalculatorCore/calculator.js @@ -0,0 +1,95 @@ + +var curVal = 0 +var memory = 0 +var lastOp = "" +var timer = 0 + +function disabled(op) { + if (op == "." && display.text.toString().search(/\./) != -1) { + return true + } else if (op == squareRoot && display.text.toString().search(/-/) != -1) { + return true + } else { + return false + } +} + +function doOperation(op) { + if (op == '*')//Keyboard Aliases + op = multiplication; + if (op == '/') + op = division; + if (disabled(op)) { + return + } + + if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) { + if (display.text.toString().length >= 14) + return; // No arbitrary length numbers + if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) { + display.text = display.text + op.toString() + } else { + display.text = op + } + lastOp = op + return + } + lastOp = op + + if (display.currentOperation.text == "+") { + display.text = Number(display.text.valueOf()) + Number(curVal.valueOf()) + } else if (display.currentOperation.text == "-") { + display.text = Number(curVal) - Number(display.text.valueOf()) + } else if (display.currentOperation.text == multiplication) { + display.text = Number(curVal) * Number(display.text.valueOf()) + } else if (display.currentOperation.text == division) { + display.text = Number(Number(curVal) / Number(display.text.valueOf())).toString() + } else if (display.currentOperation.text == "=") { + } + + if (op == "+" || op == "-" || op == multiplication || op == division) { + display.currentOperation.text = op + curVal = display.text.valueOf() + return + } + + curVal = 0 + display.currentOperation.text = "" + + if (op == "1/x") { + display.text = (1 / display.text.valueOf()).toString() + } else if (op == "x^2") { + display.text = (display.text.valueOf() * display.text.valueOf()).toString() + } else if (op == "Abs") { + display.text = (Math.abs(display.text.valueOf())).toString() + } else if (op == "Int") { + display.text = (Math.floor(display.text.valueOf())).toString() + } else if (op == plusminus) { + display.text = (display.text.valueOf() * -1).toString() + } else if (op == squareRoot) { + display.text = (Math.sqrt(display.text.valueOf())).toString() + } else if (op == "mc") { + memory = 0; + } else if (op == "m+") { + memory += display.text.valueOf() + } else if (op == "mr") { + display.text = memory.toString() + } else if (op == "m-") { + memory = display.text.valueOf() + } else if (op == leftArrow) { + display.text = display.text.toString().slice(0, -1) + if (display.text.length == 0) { + display.text = "0" + } + } else if (op == "Off") { + Qt.quit(); + } else if (op == "C") { + display.text = "0" + } else if (op == "AC") { + curVal = 0 + memory = 0 + lastOp = "" + display.text ="0" + } +} + diff --git a/examples/demos/calculator/CalculatorCore/images/button-.png b/examples/demos/calculator/CalculatorCore/images/button-.png new file mode 100644 index 0000000000..544e514536 Binary files /dev/null and b/examples/demos/calculator/CalculatorCore/images/button-.png differ diff --git a/examples/demos/calculator/CalculatorCore/images/button-blue.png b/examples/demos/calculator/CalculatorCore/images/button-blue.png new file mode 100644 index 0000000000..5f92de32d0 Binary files /dev/null and b/examples/demos/calculator/CalculatorCore/images/button-blue.png differ diff --git a/examples/demos/calculator/CalculatorCore/images/button-green.png b/examples/demos/calculator/CalculatorCore/images/button-green.png new file mode 100644 index 0000000000..36c93914c7 Binary files /dev/null and b/examples/demos/calculator/CalculatorCore/images/button-green.png differ diff --git a/examples/demos/calculator/CalculatorCore/images/button-purple.png b/examples/demos/calculator/CalculatorCore/images/button-purple.png new file mode 100644 index 0000000000..347cbbea9d Binary files /dev/null and b/examples/demos/calculator/CalculatorCore/images/button-purple.png differ diff --git a/examples/demos/calculator/CalculatorCore/images/button-red.png b/examples/demos/calculator/CalculatorCore/images/button-red.png new file mode 100644 index 0000000000..3b335891ae Binary files /dev/null and b/examples/demos/calculator/CalculatorCore/images/button-red.png differ diff --git a/examples/demos/calculator/CalculatorCore/images/display.png b/examples/demos/calculator/CalculatorCore/images/display.png new file mode 100644 index 0000000000..9507f4382e Binary files /dev/null and b/examples/demos/calculator/CalculatorCore/images/display.png differ diff --git a/examples/demos/calculator/CalculatorCore/qmldir b/examples/demos/calculator/CalculatorCore/qmldir new file mode 100644 index 0000000000..a926b93fac --- /dev/null +++ b/examples/demos/calculator/CalculatorCore/qmldir @@ -0,0 +1,2 @@ +Button Button.qml +Display Display.qml diff --git a/examples/demos/calculator/calculator-desktop.qml b/examples/demos/calculator/calculator-desktop.qml new file mode 100644 index 0000000000..7e72f50beb --- /dev/null +++ b/examples/demos/calculator/calculator-desktop.qml @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import "CalculatorCore" +import "CalculatorCore/calculator.js" as CalcEngine + +Rectangle { + id: window + + width: 640; height: 480 + color: "#282828" + + property string rotateLeft: "\u2939" + property string rotateRight: "\u2935" + property string leftArrow: "\u2190" + property string division : "\u00f7" + property string multiplication : "\u00d7" + property string squareRoot : "\u221a" + property string plusminus : "\u00b1" + + function doOp(operation) { CalcEngine.doOperation(operation) } + focus: true + Keys.onPressed: doOp(event.text); + + Item { + id: main + width: 640 + height: 480 + anchors.centerIn: parent + + Column { + id: box; spacing: 8 + + anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 } + + Display { + id: display + width: box.width-3 + height: 64 + } + + Column { + id: column; spacing: 6 + + property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6) + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) + + Row { + spacing: 6 + Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" } + Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow } + Button { width: column.w; height: column.h; color: 'purple'; operation: "C" } + Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" } + } + + Row { + spacing: 6 + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) + + Button { width: column.w; height: column.h; color: 'green'; operation: "mc" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m+" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m-" } + Button { width: column.w; height: column.h; color: 'green'; operation: "mr" } + } + + Grid { + id: grid; rows: 5; columns: 5; spacing: 6 + + property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns) + + Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: division } + Button { width: grid.w; height: column.h; operation: squareRoot } + Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: multiplication } + Button { width: grid.w; height: column.h; operation: "x^2" } + Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "-" } + Button { width: grid.w; height: column.h; operation: "1/x" } + Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "." } + Button { width: grid.w; height: column.h; operation: plusminus } + Button { width: grid.w; height: column.h; operation: "+" } + Button { width: grid.w; height: column.h; operation: "="; color: 'red' } + } + } + } + + } +} diff --git a/examples/demos/calculator/calculator-mobile.qml b/examples/demos/calculator/calculator-mobile.qml new file mode 100644 index 0000000000..b4fc372b39 --- /dev/null +++ b/examples/demos/calculator/calculator-mobile.qml @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import "CalculatorCore" +import "CalculatorCore/calculator.js" as CalcEngine + +Rectangle { + id: window + + width: 320; height: 480 + color: "#282828" + + property string rotateLeft: "\u2939" + property string rotateRight: "\u2935" + property string leftArrow: "\u2190" + property string division : "\u00f7" + property string multiplication : "\u00d7" + property string squareRoot : "\u221a" + property string plusminus : "\u00b1" + + function doOp(operation) { CalcEngine.doOperation(operation) } + + Item { + id: main + state: "orientation " + Screen.orientation + + //Note: Assumes a primarily portrait device + property bool landscapeWindow: window.width > window.height + property real baseWidth: landscapeWindow ? window.height : window.width + property real baseHeight: landscapeWindow ? window.width : window.height + property real rotationDelta: landscapeWindow ? -90 : 0 + + rotation: rotationDelta + width: main.baseWidth + height: main.baseHeight + anchors.centerIn: parent + + Column { + id: box; spacing: 8 + + anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 } + + Display { + id: display + width: box.width-3 + height: 64 + } + + Column { + id: column; spacing: 6 + + property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6) + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) + + Row { + spacing: 6 + Button { width: column.w; height: column.h; color: 'purple'; operation: "Off" } + Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow } + Button { width: column.w; height: column.h; color: 'purple'; operation: "C" } + Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" } + } + + Row { + spacing: 6 + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) + + Button { width: column.w; height: column.h; color: 'green'; operation: "mc" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m+" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m-" } + Button { width: column.w; height: column.h; color: 'green'; operation: "mr" } + } + + Grid { + id: grid; rows: 5; columns: 5; spacing: 6 + + property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns) + + Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: division } + Button { width: grid.w; height: column.h; operation: squareRoot } + Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: multiplication } + Button { width: grid.w; height: column.h; operation: "x^2" } + Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "-" } + Button { width: grid.w; height: column.h; operation: "1/x" } + Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "." } + Button { width: grid.w; height: column.h; operation: plusminus } + Button { width: grid.w; height: column.h; operation: "+" } + Button { width: grid.w; height: column.h; operation: "="; color: 'red' } + } + } + } + + states: [ + State { + name: "orientation " + Qt.LandscapeOrientation + PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + }, + State { + name: "orientation " + Qt.InvertedPortraitOrientation + PropertyChanges { target: main; rotation: 180 + rotationDelta; } + }, + State { + name: "orientation " + Qt.InvertedLandscapeOrientation + PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + } + ] + + transitions: Transition { + SequentialAnimation { + RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } + NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } + } + } + } +} diff --git a/examples/demos/calculator/calculator.pro b/examples/demos/calculator/calculator.pro new file mode 100644 index 0000000000..3bf3b8ca2f --- /dev/null +++ b/examples/demos/calculator/calculator.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick declarative +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/calculator +qml.files = calculator-desktop.qml calculator-mobile.qml CalculatorCore +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/calculator +INSTALLS += target qml diff --git a/examples/demos/calculator/calculator.qdoc b/examples/demos/calculator/calculator.qdoc new file mode 100644 index 0000000000..e94bdb4cfd --- /dev/null +++ b/examples/demos/calculator/calculator.qdoc @@ -0,0 +1,37 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms +** and conditions contained in a signed written agreement between you +** and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \title QML Demo - Calculator + \example declarative/calculator + \brief This is an example calculator application written in QML. + \image qml-calculator-demo-small.png + + The Calculator demo implements a simple calculator in QML. It is written for desktop and portrait devices, + although on device it supports orientation changes. +*/ + diff --git a/examples/demos/calculator/main.cpp b/examples/demos/calculator/main.cpp new file mode 100644 index 0000000000..c7f9b29952 --- /dev/null +++ b/examples/demos/calculator/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +void usage() +{ + printf("Pass -desktop to use the Desktop UI"); + exit(0); +} + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc,argv); + QQuickView view; + QUrl launchFile = QUrl::fromLocalFile(QLatin1String("calculator-mobile.qml")); + if (app.arguments().contains(QLatin1String("-help"))) + usage(); + if (app.arguments().contains(QLatin1String("-desktop"))) + launchFile = QUrl::fromLocalFile(QLatin1String("calculator-desktop.qml")); + view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit())); + view.setSource(launchFile); + view.show(); + return app.exec(); +} + diff --git a/examples/demos/clocks/clocks.qml b/examples/demos/clocks/clocks.qml new file mode 100644 index 0000000000..288e50c9eb --- /dev/null +++ b/examples/demos/clocks/clocks.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: root + width: 640; height: 320 + color: "#646464" + + ListView { + id: clockview + anchors.fill: parent + orientation: ListView.Horizontal + cacheBuffer: 2000 + snapMode: ListView.SnapOneItem + highlightRangeMode: ListView.ApplyRange + + delegate: Clock { city: cityName; shift: timeShift } + model: ListModel { + ListElement { cityName: "New York"; timeShift: -4 } + ListElement { cityName: "London"; timeShift: 0 } + ListElement { cityName: "Oslo"; timeShift: 1 } + ListElement { cityName: "Mumbai"; timeShift: 5.5 } + ListElement { cityName: "Tokyo"; timeShift: 9 } + ListElement { cityName: "Brisbane"; timeShift: 10 } + ListElement { cityName: "Los Angeles"; timeShift: -8 } + } + } + + Image { + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.margins: 10 + source: "content/arrow.png" + rotation: -90 + opacity: clockview.atXBeginning ? 0 : 0.5 + Behavior on opacity { NumberAnimation { duration: 500 } } + } + + Image { + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.margins: 10 + source: "content/arrow.png" + rotation: 90 + opacity: clockview.atXEnd ? 0 : 0.5 + Behavior on opacity { NumberAnimation { duration: 500 } } + } +} diff --git a/examples/demos/clocks/content/Clock.qml b/examples/demos/clocks/content/Clock.qml new file mode 100644 index 0000000000..7f0e8cba83 --- /dev/null +++ b/examples/demos/clocks/content/Clock.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id : clock + width: { + if (ListView.view && ListView.view.width >= 200) + return ListView.view.width / Math.floor(ListView.view.width / 200.0); + else + return 200; + } + + height: { + if (ListView.view && ListView.view.height >= 240) + return ListView.view.height; + else + return 240; + } + + property alias city: cityLabel.text + property int hours + property int minutes + property int seconds + property real shift + property bool night: false + property bool internationalTime: true //Unset for local time + + function timeChanged() { + var date = new Date; + hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() + night = ( hours < 7 || hours > 19 ) + minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes() + seconds = date.getUTCSeconds(); + } + + Timer { + interval: 100; running: true; repeat: true; + onTriggered: clock.timeChanged() + } + + Item { + anchors.centerIn: parent + width: 200; height: 240 + + Image { id: background; source: "clock.png"; visible: clock.night == false } + Image { source: "clock-night.png"; visible: clock.night == true } + + + Image { + x: 92.5; y: 27 + source: "hour.png" + smooth: true + transform: Rotation { + id: hourRotation + origin.x: 7.5; origin.y: 73; + angle: (clock.hours * 30) + (clock.minutes * 0.5) + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + x: 93.5; y: 17 + source: "minute.png" + smooth: true + transform: Rotation { + id: minuteRotation + origin.x: 6.5; origin.y: 83; + angle: clock.minutes * 6 + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + x: 97.5; y: 20 + source: "second.png" + smooth: true + transform: Rotation { + id: secondRotation + origin.x: 2.5; origin.y: 80; + angle: clock.seconds * 6 + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + anchors.centerIn: background; source: "center.png" + } + + Text { + id: cityLabel + y: 210; anchors.horizontalCenter: parent.horizontalCenter + color: "white" + font.family: "Helvetica" + font.bold: true; font.pixelSize: 16 + style: Text.Raised; styleColor: "black" + } + } +} diff --git a/examples/demos/clocks/content/QuitButton.qml b/examples/demos/clocks/content/QuitButton.qml new file mode 100644 index 0000000000..702b892d23 --- /dev/null +++ b/examples/demos/clocks/content/QuitButton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/demos/clocks/content/arrow.png b/examples/demos/clocks/content/arrow.png new file mode 100644 index 0000000000..e437312217 Binary files /dev/null and b/examples/demos/clocks/content/arrow.png differ diff --git a/examples/demos/clocks/content/background.png b/examples/demos/clocks/content/background.png new file mode 100644 index 0000000000..a885950862 Binary files /dev/null and b/examples/demos/clocks/content/background.png differ diff --git a/examples/demos/clocks/content/center.png b/examples/demos/clocks/content/center.png new file mode 100644 index 0000000000..7fbd802a44 Binary files /dev/null and b/examples/demos/clocks/content/center.png differ diff --git a/examples/demos/clocks/content/clock-night.png b/examples/demos/clocks/content/clock-night.png new file mode 100644 index 0000000000..cc7151a397 Binary files /dev/null and b/examples/demos/clocks/content/clock-night.png differ diff --git a/examples/demos/clocks/content/clock.png b/examples/demos/clocks/content/clock.png new file mode 100644 index 0000000000..462edacc0e Binary files /dev/null and b/examples/demos/clocks/content/clock.png differ diff --git a/examples/demos/clocks/content/hour.png b/examples/demos/clocks/content/hour.png new file mode 100644 index 0000000000..f8061a1235 Binary files /dev/null and b/examples/demos/clocks/content/hour.png differ diff --git a/examples/demos/clocks/content/minute.png b/examples/demos/clocks/content/minute.png new file mode 100644 index 0000000000..1297ec7c2b Binary files /dev/null and b/examples/demos/clocks/content/minute.png differ diff --git a/examples/demos/clocks/content/quit.png b/examples/demos/clocks/content/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/demos/clocks/content/quit.png differ diff --git a/examples/demos/clocks/content/second.png b/examples/demos/clocks/content/second.png new file mode 100644 index 0000000000..4aa9fb5e8e Binary files /dev/null and b/examples/demos/clocks/content/second.png differ diff --git a/examples/demos/corkboards/content/Day.qml b/examples/demos/corkboards/content/Day.qml new file mode 100644 index 0000000000..7fe625c305 --- /dev/null +++ b/examples/demos/corkboards/content/Day.qml @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Component { + Item { + property variant stickies + + id: page + width: ListView.view.width+40; height: ListView.view.height + + + Image { + source: "cork.jpg" + width: page.ListView.view.width + height: page.ListView.view.height + fillMode: Image.PreserveAspectCrop + clip: true + } + + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } + + Text { + text: name; x: 15; y: 8; height: 40; width: 370 + font.pixelSize: 18; font.bold: true; color: "white" + style: Text.Outline; styleColor: "black" + } + + Repeater { + model: notes + Item { + id: stickyPage + + property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100 + property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50 + + x: randomX; y: randomY + + rotation: -flickable.horizontalVelocity / 100; + Behavior on rotation { + SpringAnimation { spring: 2.0; damping: 0.15 } + } + + Item { + id: sticky + scale: 0.7 + + Image { + id: stickyImage + x: 8 + -width * 0.6 / 2; y: -20 + source: "note-yellow.png" + scale: 0.6; transformOrigin: Item.TopLeft + smooth: true + } + + TextEdit { + id: myText + x: -104; y: 36; width: 215; height: 200 + smooth: true + font.pixelSize: 24 + readOnly: false + rotation: -8 + text: noteText + } + + Item { + x: stickyImage.x; y: -20 + width: stickyImage.width * stickyImage.scale + height: stickyImage.height * stickyImage.scale + + MouseArea { + id: mouse + anchors.fill: parent + drag.target: stickyPage + drag.axis: Drag.XandYAxis + drag.minimumY: 0 + drag.maximumY: page.height - 80 + drag.minimumX: 100 + drag.maximumX: page.width - 140 + onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); } + } + } + } + + Image { + x: -width / 2; y: -height * 0.5 / 2 + source: "tack.png" + scale: 0.7; transformOrigin: Item.TopLeft + } + + states: State { + name: "pressed" + when: mouse.pressed + PropertyChanges { target: sticky; rotation: 8; scale: 1 } + PropertyChanges { target: page; z: 8 } + } + + transitions: Transition { + NumberAnimation { properties: "rotation,scale"; duration: 200 } + } + } + } + } +} + + + + + + + + diff --git a/examples/demos/corkboards/content/cork.jpg b/examples/demos/corkboards/content/cork.jpg new file mode 100644 index 0000000000..160bc002bf Binary files /dev/null and b/examples/demos/corkboards/content/cork.jpg differ diff --git a/examples/demos/corkboards/content/note-yellow.png b/examples/demos/corkboards/content/note-yellow.png new file mode 100644 index 0000000000..8ddecc8b03 Binary files /dev/null and b/examples/demos/corkboards/content/note-yellow.png differ diff --git a/examples/demos/corkboards/content/tack.png b/examples/demos/corkboards/content/tack.png new file mode 100644 index 0000000000..cef2d1cd23 Binary files /dev/null and b/examples/demos/corkboards/content/tack.png differ diff --git a/examples/demos/corkboards/corkboards.qml b/examples/demos/corkboards/corkboards.qml new file mode 100644 index 0000000000..dc3aa6b378 --- /dev/null +++ b/examples/demos/corkboards/corkboards.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 800; height: 480 + color: "#464646" + + ListModel { + id: list + + ListElement { + name: "Sunday" + notes: [ + ListElement { noteText: "Lunch" }, + ListElement { noteText: "Birthday Party" } + ] + } + + ListElement { + name: "Monday" + notes: [ + ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, + ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } + ] + } + + ListElement { + name: "Tuesday" + notes: [ + ListElement { noteText: "Walk dog" }, + ListElement { noteText: "Buy newspaper" } + ] + } + + ListElement { + name: "Wednesday" + notes: [ ListElement { noteText: "Cook dinner" } ] + } + + ListElement { + name: "Thursday" + notes: [ + ListElement { noteText: "Meeting\n5.30pm" }, + ListElement { noteText: "Weed garden" } + ] + } + + ListElement { + name: "Friday" + notes: [ + ListElement { noteText: "More work" }, + ListElement { noteText: "Grocery shopping" } + ] + } + + ListElement { + name: "Saturday" + notes: [ + ListElement { noteText: "Drink" }, + ListElement { noteText: "Download Qt\nPlay with QML" } + ] + } + } + + ListView { + id: flickable + + anchors.fill: parent + focus: true + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem + model: list + delegate: Day { } + } +} diff --git a/examples/demos/demos.pro b/examples/demos/demos.pro new file mode 100644 index 0000000000..abe718b910 --- /dev/null +++ b/examples/demos/demos.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = calculator diff --git a/examples/demos/dynamicscene/content/Button.qml b/examples/demos/dynamicscene/content/Button.qml new file mode 100644 index 0000000000..014692274a --- /dev/null +++ b/examples/demos/dynamicscene/content/Button.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property variant text + signal clicked + + height: text.height + 10; width: text.width + 20 + border.width: 1 + radius: 4 + smooth: true + + gradient: Gradient { + GradientStop { + position: 0.0 + color: !mouseArea.pressed ? activePalette.light : activePalette.button + } + GradientStop { + position: 1.0 + color: !mouseArea.pressed ? activePalette.button : activePalette.dark + } + } + + SystemPalette { id: activePalette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked() + } + + Text { + id: text + anchors.centerIn:parent + font.pointSize: 10 + text: parent.text + color: activePalette.buttonText + } +} diff --git a/examples/demos/dynamicscene/content/GenericSceneItem.qml b/examples/demos/dynamicscene/content/GenericSceneItem.qml new file mode 100644 index 0000000000..0408aa87fb --- /dev/null +++ b/examples/demos/dynamicscene/content/GenericSceneItem.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + property bool created: false + property string image + + source: image + +} diff --git a/examples/demos/dynamicscene/content/PaletteItem.qml b/examples/demos/dynamicscene/content/PaletteItem.qml new file mode 100644 index 0000000000..e993f89989 --- /dev/null +++ b/examples/demos/dynamicscene/content/PaletteItem.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "itemCreation.js" as Code + +Image { + id: paletteItem + + property string componentFile + property string image + + source: image + + MouseArea { + anchors.fill: parent + + onPressed: Code.startDrag(mouse); + onPositionChanged: Code.continueDrag(mouse); + onReleased: Code.endDrag(mouse); + } +} diff --git a/examples/demos/dynamicscene/content/PerspectiveItem.qml b/examples/demos/dynamicscene/content/PerspectiveItem.qml new file mode 100644 index 0000000000..f651369452 --- /dev/null +++ b/examples/demos/dynamicscene/content/PerspectiveItem.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: rootItem + + property bool created: false + property string image + + property double scaledBottom: y + (height + height*scale) / 2 + property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset) + + source: image + opacity: onLand ? 1 : 0.25 + scale: Math.max((y + height - 250) * 0.01, 0.3) + smooth: true + + onCreatedChanged: { + if (created && !onLand) + rootItem.destroy(); + else + z = scaledBottom; + } + + onYChanged: z = scaledBottom; +} diff --git a/examples/demos/dynamicscene/content/Sun.qml b/examples/demos/dynamicscene/content/Sun.qml new file mode 100644 index 0000000000..b84516eecc --- /dev/null +++ b/examples/demos/dynamicscene/content/Sun.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: sun + + property bool created: false + property string image: "images/sun.png" + + source: image + + // once item is created, start moving offscreen + NumberAnimation on y { + to: (window.height / 2) + window.centerOffset + running: created + onRunningChanged: { + if (running) + duration = (window.height + window.centerOffset - sun.y) * 10; + else + state = "OffScreen" + } + } + + states: State { + name: "OffScreen" + StateChangeScript { + script: { sun.created = false; sun.destroy() } + } + } + + onCreatedChanged: { + if (created) { + sun.z = 1; // above the sky but below the ground layer + window.activeSuns++; + } else { + window.activeSuns--; + } + } +} diff --git a/examples/demos/dynamicscene/content/images/NOTE b/examples/demos/dynamicscene/content/images/NOTE new file mode 100644 index 0000000000..fcd87f9132 --- /dev/null +++ b/examples/demos/dynamicscene/content/images/NOTE @@ -0,0 +1 @@ +Images (except star.png) are from the KDE project. diff --git a/examples/demos/dynamicscene/content/images/face-smile.png b/examples/demos/dynamicscene/content/images/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/demos/dynamicscene/content/images/face-smile.png differ diff --git a/examples/demos/dynamicscene/content/images/moon.png b/examples/demos/dynamicscene/content/images/moon.png new file mode 100644 index 0000000000..1c0d6066a8 Binary files /dev/null and b/examples/demos/dynamicscene/content/images/moon.png differ diff --git a/examples/demos/dynamicscene/content/images/rabbit_brown.png b/examples/demos/dynamicscene/content/images/rabbit_brown.png new file mode 100644 index 0000000000..ebfdeed332 Binary files /dev/null and b/examples/demos/dynamicscene/content/images/rabbit_brown.png differ diff --git a/examples/demos/dynamicscene/content/images/rabbit_bw.png b/examples/demos/dynamicscene/content/images/rabbit_bw.png new file mode 100644 index 0000000000..7bff9b92ca Binary files /dev/null and b/examples/demos/dynamicscene/content/images/rabbit_bw.png differ diff --git a/examples/demos/dynamicscene/content/images/star.png b/examples/demos/dynamicscene/content/images/star.png new file mode 100644 index 0000000000..27ef924267 Binary files /dev/null and b/examples/demos/dynamicscene/content/images/star.png differ diff --git a/examples/demos/dynamicscene/content/images/sun.png b/examples/demos/dynamicscene/content/images/sun.png new file mode 100644 index 0000000000..7713ca5ce7 Binary files /dev/null and b/examples/demos/dynamicscene/content/images/sun.png differ diff --git a/examples/demos/dynamicscene/content/images/tree_s.png b/examples/demos/dynamicscene/content/images/tree_s.png new file mode 100644 index 0000000000..6eac35a729 Binary files /dev/null and b/examples/demos/dynamicscene/content/images/tree_s.png differ diff --git a/examples/demos/dynamicscene/content/itemCreation.js b/examples/demos/dynamicscene/content/itemCreation.js new file mode 100644 index 0000000000..40f5415f9f --- /dev/null +++ b/examples/demos/dynamicscene/content/itemCreation.js @@ -0,0 +1,62 @@ +var itemComponent = null; +var draggedItem = null; +var startingMouse; +var posnInWindow; + +function startDrag(mouse) +{ + posnInWindow = paletteItem.mapToItem(window, 0, 0); + startingMouse = { x: mouse.x, y: mouse.y } + loadComponent(); +} + +//Creation is split into two functions due to an asynchronous wait while +//possible external files are loaded. + +function loadComponent() { + if (itemComponent != null) { // component has been previously loaded + createItem(); + return; + } + + itemComponent = Qt.createComponent(paletteItem.componentFile); + if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately + component.statusChanged.connect(createItem); + else + createItem(); +} + +function createItem() { + if (itemComponent.status == Component.Ready && draggedItem == null) { + draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); + // make sure created item is above the ground layer + } else if (itemComponent.status == Component.Error) { + draggedItem = null; + console.log("error creating component"); + console.log(itemComponent.errorString()); + } +} + +function continueDrag(mouse) +{ + if (draggedItem == null) + return; + + draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; + draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; +} + +function endDrag(mouse) +{ + if (draggedItem == null) + return; + + if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox + draggedItem.destroy(); + draggedItem = null; + } else { + draggedItem.created = true; + draggedItem = null; + } +} + diff --git a/examples/demos/dynamicscene/dynamicscene.qml b/examples/demos/dynamicscene/dynamicscene.qml new file mode 100644 index 0000000000..c64df5cfc0 --- /dev/null +++ b/examples/demos/dynamicscene/dynamicscene.qml @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Item { + id: window + + property int activeSuns: 0 + property int centerOffset: 72 + + height: 480; width: 320 + + + MouseArea { + anchors.fill: parent + onClicked: window.focus = false; + } + + //This is the message box that pops up when there's an error + Rectangle { + id: dialog + + opacity: 0 + anchors.centerIn: parent + width: dialogText.width + 6; height: dialogText.height + 6 + border.color: 'black' + color: 'lightsteelblue' + z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. + + function show(str){ + dialogText.text = str; + dialogAnim.start(); + } + + Text { + id: dialogText + x: 3; y: 3 + font.pixelSize: 14 + } + + SequentialAnimation { + id: dialogAnim + NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } + PauseAnimation { duration: 5000 } + NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } + } + } + + Item { + id: scene + anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right} + z: 10 + } + + // sky + Rectangle { + id: sky + anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } + GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } + } + } + + // stars (when there's no sun) + ParticleSystem { + id: particlesystem + anchors.fill: sky + + ImageParticle { + id: stars + source: "content/images/star.png" + groups: ["stars"] + opacity: .5 + } + + Emitter { + id: starsemitter + anchors.fill: parent + emitRate: parent.width / 50 + lifeSpan: 5000 + group: "stars" + } + } + + // ground + Rectangle { + id: ground + z: 2 // just above the sun so that the sun can set behind it + anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + SystemPalette { id: activePalette } + + // right-hand panel + Rectangle { + id: toolbox + + height: centerOffset * 2 + color: activePalette.window + anchors { right: parent.right; top: parent.top; left: parent.left} + + Column { + anchors.centerIn: parent + spacing: 8 + + Text { text: "Drag an item into the scene." } + + Rectangle { + width: palette.width + 10; height: palette.height + 10 + border.color: "black" + + Row { + id: palette + anchors.centerIn: parent + spacing: 8 + + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "Sun.qml" + source: "content/images/sun.png" + image: "images/sun.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "GenericSceneItem.qml" + source: "content/images/moon.png" + image: "images/moon.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/tree_s.png" + image: "images/tree_s.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/rabbit_brown.png" + image: "images/rabbit_brown.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/rabbit_bw.png" + image: "images/rabbit_bw.png" + } + } + } + + Text { text: "Active Suns: " + activeSuns } + } + } + + //Popup toolbox down the bottom + Rectangle { + id: popupToolbox + z: 1000 + width: parent.width + height: popupColumn.height + 16 + color: activePalette.window + + property bool poppedUp: false + property int downY: window.height - (createButton.height + 16) + property int upY: window.height - (popupColumn.height + 16) + y: poppedUp ? upY : downY + Behavior on y { NumberAnimation {}} + + Column { + id: popupColumn + y: 8 + anchors.centerIn: parent + spacing: 8 + + Row { + height: createButton.height + spacing: 8 + Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } + Button { + id: popupButton + text: popupToolbox.poppedUp ? "Hide" : "Show" + onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp + } + Button { + id: createButton + text: "Create" + onClicked: { + try { + Qt.createQmlObject(qmlText.text, scene, 'CustomObject'); + } catch(err) { + dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); + } + } + } + + } + + Rectangle { + width: 360; height: 240 + + TextEdit { + id: qmlText + anchors.fill: parent; anchors.margins: 5 + readOnly: false + font.pixelSize: 14 + selectByMouse: true + wrapMode: TextEdit.WordWrap + + text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" + } + } + } + } + + //Day state, for when a sun is added to the scene + states: State { + name: "Day" + when: window.activeSuns > 0 + + PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } + PropertyChanges { target: gradientStopB; color: "SkyBlue" } + PropertyChanges { target: stars; opacity: 0 } + } + + //! [top-level transitions] + transitions: Transition { + PropertyAnimation { duration: 3000 } + ColorAnimation { duration: 3000 } + } + //! [top-level transitions] +} diff --git a/examples/demos/flickr/content/Button.qml b/examples/demos/flickr/content/Button.qml new file mode 100644 index 0000000000..d6a8d3e001 --- /dev/null +++ b/examples/demos/flickr/content/Button.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + signal clicked + + property string text + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + BorderImage { + id: pressed + opacity: 0 + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + MouseArea { + id: mouseRegion + anchors.fill: buttonImage + onClicked: { container.clicked(); } + } + Text { + color: "white" + anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 15 + text: container.text; style: Text.Raised; styleColor: "black" + } + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed == true + PropertyChanges { target: pressed; opacity: 1 } + } + ] +} diff --git a/examples/demos/flickr/content/GridDelegate.qml b/examples/demos/flickr/content/GridDelegate.qml new file mode 100644 index 0000000000..794d768c74 --- /dev/null +++ b/examples/demos/flickr/content/GridDelegate.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: wrapper; width: GridView.view.cellWidth; height: GridView.view.cellHeight + + function photoClicked() { + imageDetails.photoTitle = title; + imageDetails.photoTags = tags; + imageDetails.photoWidth = photoWidth; + imageDetails.photoHeight = photoHeight; + imageDetails.photoType = photoType; + imageDetails.photoAuthor = photoAuthor; + imageDetails.photoDate = photoDate; + imageDetails.photoUrl = url; + imageDetails.rating = 0; + scaleMe.state = "Details"; + } + + Item { + anchors.centerIn: parent + scale: 0.0 + Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} } + id: scaleMe + + Item { + width: 77; height: 77; anchors.centerIn: parent + Rectangle { + id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true + Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true } + Image { source: "images/gloss.png" } + } + } + + Connections { + target: toolBar + onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' + } + + states: [ + State { + name: "Show"; when: thumb.status == Image.Ready + PropertyChanges { target: scaleMe; scale: 1 } + }, + State { + name: "Details" + PropertyChanges { target: scaleMe; scale: 1 } + ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer } + PropertyChanges { target: background; state: "DetailedView" } + } + ] + transitions: [ + Transition { + from: "Show"; to: "Details" + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + }, + Transition { + from: "Details"; to: "Show" + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + } + ] + } + MouseArea { anchors.fill: wrapper; onClicked: photoClicked() } +} + diff --git a/examples/demos/flickr/content/ImageDetails.qml b/examples/demos/flickr/content/ImageDetails.qml new file mode 100644 index 0000000000..83f2537d65 --- /dev/null +++ b/examples/demos/flickr/content/ImageDetails.qml @@ -0,0 +1,323 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Flipable { + id: container + + property alias frontContainer: containerFront + property string photoTitle: "" + property string photoTags: "" + property int photoWidth + property int photoHeight + property string photoType + property string photoAuthor + property string photoDate + property string photoUrl + property int rating: 2 + property variant prevScale: 1.0 + + property int flipDuration: 1600 + + signal closed + + transform: Rotation { + id: itemRotation + origin.x: container.width / 2; + axis.y: 1; axis.z: 0 + } + + front: Item { + id: containerFront; anchors.fill: container + + Rectangle { + anchors.fill: parent + color: "black"; opacity: 0.4 + } + + Column { + spacing: 10 + anchors { + left: parent.left; leftMargin: 10 + right: parent.right; rightMargin: 10 + top: parent.top; topMargin: 120 + } + Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Size: " + container.photoWidth + 'x' + container.photoHeight; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Type: " + container.photoType; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Author: " + container.photoAuthor; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: "Published: " + container.photoDate; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "Tags: "; width: parent.width } + Text { color: "white"; elide: Text.ElideRight; text: container.photoTags; width: parent.width } + } + } + + back: Item { + anchors.fill: container + + Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 } + + Progress { + anchors.centerIn: parent; width: 200; height: 22 + progress: bigImage.progress; visible: bigImage.status != Image.Ready + } + + Flickable { + id: flickable; anchors.fill: parent; clip: true + contentWidth: imageContainer.width; contentHeight: imageContainer.height + + function updateMinimumScale() { + if (bigImage.status == Image.Ready && bigImage.width != 0) { + slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height); + if (bigImage.width * slider.value > flickable.width) { + var xoff = (flickable.width/2 + flickable.contentX) * slider.value / prevScale; + flickable.contentX = xoff - flickable.width/2; + } + if (bigImage.height * slider.value > flickable.height) { + var yoff = (flickable.height/2 + flickable.contentY) * slider.value / prevScale; + flickable.contentY = yoff - flickable.height/2; + } + prevScale = slider.value; + } + } + + onWidthChanged: updateMinimumScale() + onHeightChanged: updateMinimumScale() + + Item { + id: imageContainer + width: Math.max(bigImage.width * bigImage.scale, flickable.width); + height: Math.max(bigImage.height * bigImage.scale, flickable.height); + Image { + id: bigImage; source: container.photoUrl; scale: slider.value + anchors.centerIn: parent; smooth: !flickable.movingVertically + onStatusChanged : { + // Default scale shows the entire image. + if (bigImage.status == Image.Ready && bigImage.width != 0) { + slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height); + prevScale = Math.min(slider.minimum, 1); + slider.value = prevScale; + } + if (inBackState && bigImage.status == Image.Ready) + effectBox.imageInAnim(); + } + property bool inBackState: false + onInBackStateChanged:{ + if(inBackState && bigImage.status == Image.Ready) + effectBox.imageInAnim(); + else if (!inBackState && bigImage.status == Image.Ready) + effectBox.imageOutAnim(); + } + } + ShaderEffectSource{ + id: pictureSource + sourceItem: bigImage + smooth: true + //Workaround: Doesn't work below lines + width: bigImage.width + height: bigImage.width + visible: false + } + Turbulence{//only fill visible rect + id: turbulence + system: imageSystem + anchors.fill: parent + strength: 240 + enabled: false + } + + Item{ + id: effectBox + width: bigImage.width * bigImage.scale + height: bigImage.height * bigImage.scale + anchors.centerIn: parent + function imageInAnim(){ + bigImage.visible = false; + noiseIn.visible = true; + endEffectTimer.start(); + } + function imageOutAnim(){ + bigImage.visible = false; + noiseIn.visible = false; + turbulence.enabled = true; + endEffectTimer.start(); + pixelEmitter.burst(2048); + } + Timer{ + id: endEffectTimer + interval: flipDuration + repeat: false + running: false + onTriggered:{ + turbulence.enabled = false; + noiseIn.visible = false; + bigImage.visible = true; + } + } + ShaderEffect{ + id: noiseIn + anchors.fill: parent + property real t: 0 + visible: false + onVisibleChanged: tAnim.start() + NumberAnimation{ + id: tAnim + target: noiseIn + property: "t" + from: 0.0 + to: 1.0 + duration: flipDuration + } + property variant source: pictureSource + property variant noise: ShaderEffectSource{ + sourceItem:Image{ + source: "images/noise.png" + } + hideSource: true + smooth: false + } + fragmentShader:" + uniform sampler2D noise; + uniform sampler2D source; + uniform highp float t; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main(){ + //Want to use noise2, but it always returns (0,0)? + if(texture2D(noise, qt_TexCoord0).w <= t) + gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity; + else + gl_FragColor = vec4(0.,0.,0.,0.); + } + " + } + ParticleSystem{ + id: imageSystem + } + Emitter{ + id: pixelEmitter + system: imageSystem + //anchors.fill: parent + width: Math.min(bigImage.width * bigImage.scale, flickable.width); + height: Math.min(bigImage.height * bigImage.scale, flickable.height); + anchors.centerIn: parent + size: 4 + lifeSpan: flipDuration + emitRate: 2048 + enabled: false + } + CustomParticle{ + id: blowOut + system: imageSystem + property real maxWidth: effectBox.width + property real maxHeight: effectBox.height + vertexShader:" + uniform highp float maxWidth; + uniform highp float maxHeight; + + varying highp vec2 fTex2; + + void main() { + defaultMain(); + fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight); + } + " + property variant pictureTexture: pictureSource + fragmentShader: " + uniform lowp float qt_Opacity; + uniform sampler2D pictureTexture; + varying highp vec2 fTex2; + void main() { + gl_FragColor = texture2D(pictureTexture, fTex2) * qt_Opacity; + }" + } + + + + } + } + } + + Text { + text: "Image Unavailable" + visible: bigImage.status == Image.Error + anchors.centerIn: parent; color: "white"; font.bold: true + } + + Slider { + id: slider; visible: { bigImage.status == Image.Ready && maximum > minimum } + anchors { + bottom: parent.bottom; bottomMargin: 65 + left: parent.left; leftMargin: 25 + right: parent.right; rightMargin: 25 + } + onValueChanged: { + if (bigImage.width * value > flickable.width) { + var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale; + flickable.contentX = xoff - flickable.width/2; + } + if (bigImage.height * value > flickable.height) { + var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale; + flickable.contentY = yoff - flickable.height/2; + } + prevScale = value; + } + } + } + + states: State { + name: "Back" + PropertyChanges { target: itemRotation; angle: 180 } + PropertyChanges { target: toolBar; button2Visible: false } + PropertyChanges { target: toolBar; button1Label: "Back" } + PropertyChanges { target: bigImage; inBackState: true } + } + + transitions: Transition { + SequentialAnimation { + PropertyAction { target: bigImage; property: "smooth"; value: false } + NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: flipDuration } + PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically } + } + } +} diff --git a/examples/demos/flickr/content/ListDelegate.qml b/examples/demos/flickr/content/ListDelegate.qml new file mode 100644 index 0000000000..9c239151f1 --- /dev/null +++ b/examples/demos/flickr/content/ListDelegate.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Component { + Item { + id: wrapper; width: wrapper.ListView.view.width; height: 86 + Item { + id: moveMe + Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 } + Rectangle { + x: 6; y: 4; width: 77; height: 77; color: "white"; smooth: true + + Image { source: imagePath; x: 1; y: 1 } + Image { source: "images/gloss.png" } + } + Column { + x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2 + Text { text: title; color: "white"; width: parent.width; font.pixelSize: 14; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" } + Text { text: photoAuthor; width: parent.width; font.pixelSize: 14; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" } + Text { text: photoDate; width: parent.width; font.pixelSize: 14; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" } + } + } + } +} diff --git a/examples/demos/flickr/content/Progress.qml b/examples/demos/flickr/content/Progress.qml new file mode 100644 index 0000000000..81f1e79ed6 --- /dev/null +++ b/examples/demos/flickr/content/Progress.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item{ + id: container + property variant progress: 0 + + Rectangle { + anchors.fill: parent; smooth: true + border.color: "white"; border.width: 0; radius: height/2 - 2 + gradient: Gradient { + GradientStop { position: 0; color: "#66343434" } + GradientStop { position: 1.0; color: "#66000000" } + } + } + + ParticleSystem{ + running: container.visible + id: barSys + } + ImageParticle{ + color: "lightsteelblue" + alpha: 0.1 + colorVariation: 0.05 + source: "images/particle.png" + system: barSys + } + Emitter{ + y: 2; height: parent.height-4; + x: 2; width: Math.max(parent.width * progress - 4, 0); + speed: AngleDirection{ angleVariation: 180; magnitudeVariation: 12 } + system: barSys + emitRate: width; + lifeSpan: 1000 + size: 20 + sizeVariation: 4 + endSize: 12 + maximumEmitted: parent.width; + } + + Text { + text: Math.round(progress * 100) + "%" + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + color: Qt.rgba(1.0, 1.0 - progress, 1.0 - progress,0.9); font.bold: true; font.pixelSize: 15 + } +} diff --git a/examples/demos/flickr/content/RssModel.qml b/examples/demos/flickr/content/RssModel.qml new file mode 100644 index 0000000000..f28a23d502 --- /dev/null +++ b/examples/demos/flickr/content/RssModel.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + property string tags : "" + + function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } + + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")+"format=rss2" + query: "/rss/channel/item" + namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "tags"; query: "media:category/string()" } + XmlRole { name: "photoWidth"; query: "media:content/@width/string()" } + XmlRole { name: "photoHeight"; query: "media:content/@height/string()" } + XmlRole { name: "photoType"; query: "media:content/@type/string()" } + XmlRole { name: "photoAuthor"; query: "author/string()" } + XmlRole { name: "photoDate"; query: "pubDate/string()" } +} diff --git a/examples/demos/flickr/content/ScrollBar.qml b/examples/demos/flickr/content/ScrollBar.qml new file mode 100644 index 0000000000..388e43dc2d --- /dev/null +++ b/examples/demos/flickr/content/ScrollBar.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property variant flickableArea + + Rectangle { + radius: 5 + color: "black" + opacity: 0.3 + border.color: "white" + border.width: 2 + x: 0 + y: flickableArea.visibleArea.yPosition * container.height + width: parent.width + height: flickableArea.visibleArea.heightRatio * container.height + } + states: [ + State { + name: "show" + when: flickableArea.movingVertically + PropertyChanges { + target: container + opacity: 1 + } + } + ] + transitions: [ + Transition { + from: "*" + to: "*" + NumberAnimation { + target: container + properties: "opacity" + duration: 400 + } + } + ] +} diff --git a/examples/demos/flickr/content/Slider.qml b/examples/demos/flickr/content/Slider.qml new file mode 100644 index 0000000000..0f9e8b20f2 --- /dev/null +++ b/examples/demos/flickr/content/Slider.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: slider; width: 400; height: 16 + + // value is read/write. + property real value: 1 + onValueChanged: updatePos(); + property real maximum: 1 + property real minimum: 1 + property int xMax: width - handle.width - 4 + onXMaxChanged: updatePos(); + onMinimumChanged: updatePos(); + + function updatePos() { + if (maximum > minimum) { + var pos = 2 + (value - minimum) * slider.xMax / (maximum - minimum); + pos = Math.min(pos, width - handle.width - 2); + pos = Math.max(pos, 2); + handle.x = pos; + } else { + handle.x = 2; + } + } + + Rectangle { + anchors.fill: parent + border.color: "white"; border.width: 0; radius: 8 + gradient: Gradient { + GradientStop { position: 0.0; color: "#66343434" } + GradientStop { position: 1.0; color: "#66000000" } + } + } + + Rectangle { + id: handle; smooth: true + y: 2; width: 30; height: slider.height-4; radius: 6 + gradient: Gradient { + GradientStop { position: 0.0; color: "lightgray" } + GradientStop { position: 1.0; color: "gray" } + } + + MouseArea { + id: mouse + anchors.fill: parent; drag.target: parent + drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: slider.xMax+2 + onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; } + } + } +} diff --git a/examples/demos/flickr/content/TitleBar.qml b/examples/demos/flickr/content/TitleBar.qml new file mode 100644 index 0000000000..3dab005a11 --- /dev/null +++ b/examples/demos/flickr/content/TitleBar.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: titleBar + property string untaggedString: "Uploads from everyone" + property string taggedString: "Recent uploads tagged " + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Item { + id: container + width: (parent.width * 2) - 55 ; height: parent.height + + function accept() { + imageDetails.closed() + titleBar.state = "" + background.state = "" + rssModel.tags = editor.text + } + + Image { + id: quitButton + anchors.left: parent.left//; anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: "images/quit.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + + Text { + id: categoryText + anchors { + left: quitButton.right; right: tagButton.left; leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + elide: Text.ElideLeft + text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags) + font.bold: true; font.pixelSize: 15; color: "White"; style: Text.Raised; styleColor: "Black" + } + + Button { + id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..." + onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags" + anchors.verticalCenter: parent.verticalCenter + } + + Item { + id: lineEdit + y: 4; height: parent.height - 9 + anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 } + + BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } + + TextInput { + id: editor + anchors { + left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + cursorVisible: true; font.bold: true + color: "#151515"; selectionColor: "Green" + } + + Keys.forwardTo: [ (returnKey), (editor)] + + Item { + id: returnKey + Keys.onReturnPressed: container.accept() + Keys.onEnterPressed: container.accept() + Keys.onEscapePressed: titleBar.state = "" + } + } + } + + states: State { + name: "Tags" + PropertyChanges { target: container; x: -tagButton.x + 5 } + PropertyChanges { target: tagButton; text: "OK" } + PropertyChanges { target: editor; focus: true } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } + } +} diff --git a/examples/demos/flickr/content/ToolBar.qml b/examples/demos/flickr/content/ToolBar.qml new file mode 100644 index 0000000000..e82be63e7e --- /dev/null +++ b/examples/demos/flickr/content/ToolBar.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: toolbar + + property alias button1Label: button1.text + property alias button2Label: button2.text + property alias button2Visible: button2.visible + + signal button1Clicked + signal button2Clicked + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Row { + anchors.right: parent.right; anchors.rightMargin: 5; y: 3; height: 32; spacing: 30 + Button { + id: button1 + width: 140; height: 32 + onClicked: toolbar.button1Clicked() + } + + Button { + id: button2; width: 140; height: 32 + onClicked: toolbar.button2Clicked() + } + } +} diff --git a/examples/demos/flickr/content/UnifiedDelegate.qml b/examples/demos/flickr/content/UnifiedDelegate.qml new file mode 100644 index 0000000000..00a777b0a1 --- /dev/null +++ b/examples/demos/flickr/content/UnifiedDelegate.qml @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Package { + function photoClicked() { + imageDetails.photoTitle = title; + imageDetails.photoTags = tags; + imageDetails.photoWidth = photoWidth; + imageDetails.photoHeight = photoHeight; + imageDetails.photoType = photoType; + imageDetails.photoAuthor = photoAuthor; + imageDetails.photoDate = photoDate; + imageDetails.photoUrl = url; + imageDetails.rating = 0; + scaleMe.state = "Details"; + } + + Item { + id: gridwrapper; + width: GridView.view.cellWidth; height: GridView.view.cellHeight + Package.name: "grid" + } + Item { + id: streamwrapper; + width: 80; height: 80 + Package.name: "stream" + } + Item { + //anchors.centerIn: parent//Doesn't animate :( + width: 80; height: 80 + scale: 0.0 + Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} } + id: scaleMe + + Item { + id: whiteRectContainer + width: 77; height: 77; anchors.centerIn: parent + Rectangle { + id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true + x:0; y:0 + Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true } + Image { source: "images/gloss.png" } + MouseArea { anchors.fill: parent; onClicked: photoClicked() } + } + } + + Connections { + target: toolBar + onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show' + } + + state: 'inStream' + states: [ + State { + name: "Show"; when: thumb.status == Image.Ready + PropertyChanges { target: scaleMe; scale: 1; } + }, + State { + name: "Details" + PropertyChanges { target: scaleMe; scale: 1 } + ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer } + PropertyChanges { target: background; state: "DetailedView" } + } + ] + transitions: [ + Transition { + from: "Show"; to: "Details" + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + }, + Transition { + from: "Details"; to: "Show" + SequentialAnimation{ + ParentAnimation { + via: foreground + NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } + } + } + } + ] + Item{ + id: stateContainer + states: [ + State { + name: 'inStream' + when: screen.inGridView == false + ParentChange { + target: scaleMe; parent: streamwrapper + x: 0; y: 0; + } + }, + State { + name: 'inGrid' + when: screen.inGridView == true + ParentChange { + target: scaleMe; parent: gridwrapper + x: 0; y: 0; + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { target: scaleMe; properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } + } +} diff --git a/examples/demos/flickr/content/images/gloss.png b/examples/demos/flickr/content/images/gloss.png new file mode 100644 index 0000000000..5d370cd93d Binary files /dev/null and b/examples/demos/flickr/content/images/gloss.png differ diff --git a/examples/demos/flickr/content/images/lineedit.png b/examples/demos/flickr/content/images/lineedit.png new file mode 100644 index 0000000000..2cc38dc35b Binary files /dev/null and b/examples/demos/flickr/content/images/lineedit.png differ diff --git a/examples/demos/flickr/content/images/lineedit.sci b/examples/demos/flickr/content/images/lineedit.sci new file mode 100644 index 0000000000..054bff78be --- /dev/null +++ b/examples/demos/flickr/content/images/lineedit.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 10 +border.bottom: 10 +border.right: 10 +source: lineedit.png diff --git a/examples/demos/flickr/content/images/noise.png b/examples/demos/flickr/content/images/noise.png new file mode 100644 index 0000000000..c5a5ba0053 Binary files /dev/null and b/examples/demos/flickr/content/images/noise.png differ diff --git a/examples/demos/flickr/content/images/particle.png b/examples/demos/flickr/content/images/particle.png new file mode 100644 index 0000000000..dbc39cb16e Binary files /dev/null and b/examples/demos/flickr/content/images/particle.png differ diff --git a/examples/demos/flickr/content/images/quit.png b/examples/demos/flickr/content/images/quit.png new file mode 100644 index 0000000000..5bda1b6e0d Binary files /dev/null and b/examples/demos/flickr/content/images/quit.png differ diff --git a/examples/demos/flickr/content/images/squareParticle.png b/examples/demos/flickr/content/images/squareParticle.png new file mode 100644 index 0000000000..faf85c24e0 Binary files /dev/null and b/examples/demos/flickr/content/images/squareParticle.png differ diff --git a/examples/demos/flickr/content/images/stripes.png b/examples/demos/flickr/content/images/stripes.png new file mode 100644 index 0000000000..9f36727ea4 Binary files /dev/null and b/examples/demos/flickr/content/images/stripes.png differ diff --git a/examples/demos/flickr/content/images/titlebar.png b/examples/demos/flickr/content/images/titlebar.png new file mode 100644 index 0000000000..51c90082d0 Binary files /dev/null and b/examples/demos/flickr/content/images/titlebar.png differ diff --git a/examples/demos/flickr/content/images/titlebar.sci b/examples/demos/flickr/content/images/titlebar.sci new file mode 100644 index 0000000000..0418d94cd6 --- /dev/null +++ b/examples/demos/flickr/content/images/titlebar.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/examples/demos/flickr/content/images/toolbutton.png b/examples/demos/flickr/content/images/toolbutton.png new file mode 100644 index 0000000000..11310013ee Binary files /dev/null and b/examples/demos/flickr/content/images/toolbutton.png differ diff --git a/examples/demos/flickr/content/images/toolbutton.sci b/examples/demos/flickr/content/images/toolbutton.sci new file mode 100644 index 0000000000..9e4f965307 --- /dev/null +++ b/examples/demos/flickr/content/images/toolbutton.sci @@ -0,0 +1,5 @@ +border.left: 15 +border.top: 4 +border.bottom: 4 +border.right: 15 +source: toolbutton.png diff --git a/examples/demos/flickr/content/qmldir b/examples/demos/flickr/content/qmldir new file mode 100644 index 0000000000..adc2479b9f --- /dev/null +++ b/examples/demos/flickr/content/qmldir @@ -0,0 +1,10 @@ +ImageDetails ImageDetails.qml +LikeOMeter LikeOMeter.qml +Loading Loading.qml +MediaButton MediaButton.qml +MediaLineEdit MediaLineEdit.qml +Progress Progress.qml +RssModel RssModel.qml +ScrollBar ScrollBar.qml +Slider Slider.qml +Star Star.qml diff --git a/examples/demos/flickr/flickr-90.qml b/examples/demos/flickr/flickr-90.qml new file mode 100644 index 0000000000..ae06957649 --- /dev/null +++ b/examples/demos/flickr/flickr-90.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + width: 480; height: 320 + + Loader { + y: 320; rotation: -90 + transformOrigin: Item.TopLeft + source: "flickr.qml" + } +} diff --git a/examples/demos/flickr/flickr.qml b/examples/demos/flickr/flickr.qml new file mode 100644 index 0000000000..74c41f185b --- /dev/null +++ b/examples/demos/flickr/flickr.qml @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Item { + id: screen; width: 320; height: 480 + property bool inGridView : true + + Rectangle { + id: background + anchors.fill: parent; color: "#343434"; + + Image { source: "content/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } + ParticleSystem { + id: bgParticles + anchors.fill: parent + ImageParticle { + groups: ["trail"] + source: "content/images/particle.png" + color: "#1A1A6F" + alpha: 0.1 + colorVariation: 0.01 + blueVariation: 0.8 + } + Emitter { + group: "drops" + width: parent.width + emitRate: 0.5 + lifeSpan: 20000 + startTime: 16000 + speed: PointDirection{ + y: {screen.height/18} + } + } + TrailEmitter { + follow: "drops" + group: "trail" + emitRatePerParticle: 18 + size: 32 + endSize: 0 + sizeVariation: 4 + lifeSpan: 1200 + anchors.fill: parent + emitWidth: 16 + emitHeight: 16 + emitShape: EllipseShape{} + } + } + + VisualDataModel{ + id: vdm + delegate: UnifiedDelegate{} + model: RssModel { id: rssModel } + } + + Item { + id: views + width: parent.width + anchors.top: titleBar.bottom; anchors.bottom: toolBar.top + + GridView { + id: photoGridView; model: vdm.parts.grid + cacheBuffer: 1000 + cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height + } + + states: State { + name: "GridView"; when: state.inGridView == true + } + + transitions: Transition { + NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } + } + + ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height } + + Item { id: foreground; anchors.fill: parent } + } + + TitleBar { id: titleBar; width: parent.width; height: 40; opacity: 0.9 } + + ToolBar { + id: toolBar + height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9 + button1Label: "Update"; button2Label: "View mode" + onButton1Clicked: rssModel.reload() + onButton2Clicked: if (screen.inGridView == true) screen.inGridView = false; else screen.inGridView = true + } + + Connections { + target: imageDetails + onClosed: { + if (background.state == "DetailedView") { + background.state = ''; + imageDetails.photoUrl = ""; + } + } + } + + states: State { + name: "DetailedView" + PropertyChanges { target: views; x: -parent.width } + PropertyChanges { target: toolBar; button1Label: "View..." } + PropertyChanges { + target: toolBar + onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state='' + } + PropertyChanges { target: toolBar; button2Label: "Back" } + PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() } + } + + transitions: Transition { + NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad } + } + + } +} diff --git a/examples/demos/flickr/flickr.qmlproject b/examples/demos/flickr/flickr.qmlproject new file mode 100644 index 0000000000..af5179d84b --- /dev/null +++ b/examples/demos/flickr/flickr.qmlproject @@ -0,0 +1,17 @@ +import QmlProject 1.1 + +Project { + mainFile: "flickr.qml" + //mainFile: "flickr-90.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/demos/minehunt/MinehuntCore/Explosion.qml b/examples/demos/minehunt/MinehuntCore/Explosion.qml new file mode 100644 index 0000000000..0983b68db4 --- /dev/null +++ b/examples/demos/minehunt/MinehuntCore/Explosion.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + property bool explode : false + ParticleSystem { + width: 40 + height: 40 + ImageParticle { + groups: ["star"] + source: "file:MinehuntCore/pics/star.png" // TODO: Use qrc path once QTBUG-21129 is fixed + } + Emitter { + id: particles + enabled: false + anchors.centerIn: parent + group: "star" + speed: AngleDirection { angleVariation: 360; magnitude: 150; magnitudeVariation: 50 } + emitRate: 200 + z: 100 + lifeSpan: 1000 + } + } + states: State { name: "exploding"; when: explode + StateChangeScript { script: particles.burst(200); } + } + +} diff --git a/examples/demos/minehunt/MinehuntCore/Tile.qml b/examples/demos/minehunt/MinehuntCore/Tile.qml new file mode 100644 index 0000000000..14c1f51f9e --- /dev/null +++ b/examples/demos/minehunt/MinehuntCore/Tile.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Flipable { + id: flipable + property int angle: 0 + + width: 40; height: 40 + transform: Rotation { origin.x: 20; origin.y: 20; axis.x: 1; axis.z: 0; angle: flipable.angle } + + front: Image { + source: "pics/front.png"; width: 40; height: 40 + + Image { + anchors.centerIn: parent + source: "pics/flag.png"; opacity: modelData.hasFlag + + Behavior on opacity { NumberAnimation {} } + } + } + + back: Image { + source: "pics/back.png" + width: 40; height: 40 + + Text { + anchors.centerIn: parent + text: modelData.hint; color: "white"; font.bold: true + opacity: !modelData.hasMine && modelData.hint > 0 + } + + Image { + anchors.centerIn: parent + source: "pics/bomb.png"; opacity: modelData.hasMine + } + + Explosion { id: expl } + } + + states: State { + name: "back"; when: modelData.flipped + PropertyChanges { target: flipable; angle: 180 } + } + + property real pauseDur: 250 + transitions: Transition { + SequentialAnimation { + ScriptAction { + script: { + var ret = Math.abs(flipable.x - field.clickx) + + Math.abs(flipable.y - field.clicky); + if (modelData.hasMine && modelData.flipped) + pauseDur = ret * 3 + else + pauseDur = ret + } + } + PauseAnimation { + duration: pauseDur + } + RotationAnimation { easing.type: Easing.InOutQuad } + ScriptAction { script: if (modelData.hasMine && modelData.flipped) { expl.explode = true } } + } + } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + field.clickx = flipable.x + field.clicky = flipable.y + var row = Math.floor(index / 9) + var col = index - (Math.floor(index / 9) * 9) + if (mouse.button == undefined || mouse.button == Qt.RightButton) { + flag(row, col) + } else { + flip(row, col) + } + } + onPressAndHold: { + field.clickx = flipable.x + field.clicky = flipable.y + var row = Math.floor(index / 9) + var col = index - (Math.floor(index / 9) * 9) + flag(row, col) + } + } +} diff --git a/examples/demos/minehunt/MinehuntCore/pics/back.png b/examples/demos/minehunt/MinehuntCore/pics/back.png new file mode 100644 index 0000000000..f6b3f0b4d7 Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/back.png differ diff --git a/examples/demos/minehunt/MinehuntCore/pics/background.png b/examples/demos/minehunt/MinehuntCore/pics/background.png new file mode 100644 index 0000000000..3734a27744 Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/background.png differ diff --git a/examples/demos/minehunt/MinehuntCore/pics/bomb-color.png b/examples/demos/minehunt/MinehuntCore/pics/bomb-color.png new file mode 100644 index 0000000000..61ad0a928f Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/bomb-color.png differ diff --git a/examples/demos/minehunt/MinehuntCore/pics/bomb.png b/examples/demos/minehunt/MinehuntCore/pics/bomb.png new file mode 100644 index 0000000000..a992575518 Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/bomb.png differ diff --git a/examples/demos/minehunt/MinehuntCore/pics/face-sad.png b/examples/demos/minehunt/MinehuntCore/pics/face-sad.png new file mode 100644 index 0000000000..cf00aafe1f Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/face-sad.png differ diff --git a/examples/demos/minehunt/MinehuntCore/pics/face-smile-big.png b/examples/demos/minehunt/MinehuntCore/pics/face-smile-big.png new file mode 100644 index 0000000000..f9c2335df5 Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/face-smile-big.png differ diff --git a/examples/demos/minehunt/MinehuntCore/pics/face-smile.png b/examples/demos/minehunt/MinehuntCore/pics/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/face-smile.png differ diff --git a/examples/demos/minehunt/MinehuntCore/pics/flag-color.png b/examples/demos/minehunt/MinehuntCore/pics/flag-color.png new file mode 100644 index 0000000000..aadad0f11a Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/flag-color.png differ diff --git a/examples/demos/minehunt/MinehuntCore/pics/flag.png b/examples/demos/minehunt/MinehuntCore/pics/flag.png new file mode 100644 index 0000000000..39cde4df82 Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/flag.png differ diff --git a/examples/demos/minehunt/MinehuntCore/pics/front.png b/examples/demos/minehunt/MinehuntCore/pics/front.png new file mode 100644 index 0000000000..834331bd49 Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/front.png differ diff --git a/examples/demos/minehunt/MinehuntCore/pics/quit.png b/examples/demos/minehunt/MinehuntCore/pics/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/quit.png differ diff --git a/examples/demos/minehunt/MinehuntCore/pics/star.png b/examples/demos/minehunt/MinehuntCore/pics/star.png new file mode 100644 index 0000000000..3772359188 Binary files /dev/null and b/examples/demos/minehunt/MinehuntCore/pics/star.png differ diff --git a/examples/demos/minehunt/MinehuntCore/qmldir b/examples/demos/minehunt/MinehuntCore/qmldir new file mode 100644 index 0000000000..a0213a19c4 --- /dev/null +++ b/examples/demos/minehunt/MinehuntCore/qmldir @@ -0,0 +1,2 @@ +Explosion 2.0 Explosion.qml +Tile 2.0 Tile.qml diff --git a/examples/demos/minehunt/README b/examples/demos/minehunt/README new file mode 100644 index 0000000000..3849ca5fbf --- /dev/null +++ b/examples/demos/minehunt/README @@ -0,0 +1,6 @@ +Minehunt has to be compiled to run. + +To compile the C++ part, do 'qmake && make'. +To run, simply run the executable. +To deploy on a device, do 'make sis'. + diff --git a/examples/demos/minehunt/main.cpp b/examples/demos/minehunt/main.cpp new file mode 100644 index 0000000000..47c0436969 --- /dev/null +++ b/examples/demos/minehunt/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "minehunt.h" + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QQuickView canvas; + + qmlRegisterType(); + MinehuntGame* game = new MinehuntGame(); + + canvas.setResizeMode(QQuickView::SizeRootObjectToView); + canvas.engine()->rootContext()->setContextObject(game); + canvas.setSource(QString("qrc:///minehunt.qml")); + QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit())); + + canvas.show(); + return app.exec(); +} diff --git a/examples/demos/minehunt/minehunt.cpp b/examples/demos/minehunt/minehunt.cpp new file mode 100644 index 0000000000..facbec375a --- /dev/null +++ b/examples/demos/minehunt/minehunt.cpp @@ -0,0 +1,221 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include "minehunt.h" + +void tilesPropAppend(QDeclarativeListProperty* prop, TileData* value) +{ + Q_UNUSED(prop); + Q_UNUSED(value); + return; //Append not supported +} + +int tilesPropCount(QDeclarativeListProperty* prop) +{ + return static_cast*>(prop->data)->count(); +} + +TileData* tilesPropAt(QDeclarativeListProperty* prop, int index) +{ + return static_cast*>(prop->data)->at(index); +} + +QDeclarativeListProperty MinehuntGame::tiles(){ + return QDeclarativeListProperty(this, &_tiles, &tilesPropAppend, + &tilesPropCount, &tilesPropAt, 0); +} + +MinehuntGame::MinehuntGame() +: numCols(9), numRows(9), playing(true), won(false) +{ + setObjectName("mainObject"); + srand(QTime(0,0,0).secsTo(QTime::currentTime())); + + //initialize array + for(int ii = 0; ii < numRows * numCols; ++ii) { + _tiles << new TileData; + } + reset(); + +} + +void MinehuntGame::setBoard() +{ + foreach(TileData* t, _tiles){ + t->setHasMine(false); + t->setHint(-1); + } + //place mines + int mines = nMines; + remaining = numRows*numCols-mines; + while ( mines ) { + int col = int((double(rand()) / double(RAND_MAX)) * numCols); + int row = int((double(rand()) / double(RAND_MAX)) * numRows); + + TileData* t = tile( row, col ); + + if (t && !t->hasMine()) { + t->setHasMine( true ); + mines--; + } + } + + //set hints + for (int r = 0; r < numRows; r++) + for (int c = 0; c < numCols; c++) { + TileData* t = tile(r, c); + if (t && !t->hasMine()) { + int hint = getHint(r,c); + t->setHint(hint); + } + } + + setPlaying(true); +} + +void MinehuntGame::reset() +{ + foreach(TileData* t, _tiles){ + t->unflip(); + t->setHasFlag(false); + } + nMines = 12; + nFlags = 0; + emit numMinesChanged(); + emit numFlagsChanged(); + setPlaying(false); + QTimer::singleShot(600,this, SLOT(setBoard())); +} + +int MinehuntGame::getHint(int row, int col) +{ + int hint = 0; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData* t = tile(r, c); + if (t && t->hasMine()) + hint++; + } + return hint; +} + +bool MinehuntGame::flip(int row, int col) +{ + if(!playing) + return false; + + TileData *t = tile(row, col); + if (!t || t->hasFlag()) + return false; + + if(t->flipped()){ + int flags = 0; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData *nearT = tile(r, c); + if(!nearT || nearT == t) + continue; + if(nearT->hasFlag()) + flags++; + } + if(!t->hint() || t->hint() != flags) + return false; + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData *nearT = tile(r, c); + if (nearT && !nearT->flipped() && !nearT->hasFlag()) { + flip( r, c ); + } + } + return true; + } + + t->flip(); + + if (t->hint() == 0) { + for (int c = col-1; c <= col+1; c++) + for (int r = row-1; r <= row+1; r++) { + TileData* t = tile(r, c); + if (t && !t->flipped()) { + flip( r, c ); + } + } + } + + if(t->hasMine()){ + for (int r = 0; r < numRows; r++)//Flip all other mines + for (int c = 0; c < numCols; c++) { + TileData* t = tile(r, c); + if (t && t->hasMine()) { + flip(r, c); + } + } + won = false; + hasWonChanged(); + setPlaying(false); + return true; + } + + remaining--; + if(!remaining){ + won = true; + hasWonChanged(); + setPlaying(false); + return true; + } + return true; +} + +bool MinehuntGame::flag(int row, int col) +{ + TileData *t = tile(row, col); + if(!t || !playing || t->flipped()) + return false; + + t->setHasFlag(!t->hasFlag()); + nFlags += (t->hasFlag()?1:-1); + emit numFlagsChanged(); + return true; +} diff --git a/examples/demos/minehunt/minehunt.h b/examples/demos/minehunt/minehunt.h new file mode 100644 index 0000000000..a0ae23fa8a --- /dev/null +++ b/examples/demos/minehunt/minehunt.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +class TileData : public QObject +{ + Q_OBJECT +public: + TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {} + + Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged) + bool hasFlag() const { return _hasFlag; } + + Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged) + bool hasMine() const { return _hasMine; } + + Q_PROPERTY(int hint READ hint NOTIFY hintChanged) + int hint() const { return _hint; } + + Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged()) + bool flipped() const { return _flipped; } + + void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();} + void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();} + void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); } + void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); } + void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); } + +signals: + void flippedChanged(); + void hasFlagChanged(); + void hintChanged(); + void hasMineChanged(); + +private: + bool _hasFlag; + bool _hasMine; + int _hint; + bool _flipped; +}; + +class MinehuntGame : public QObject +{ + Q_OBJECT +public: + MinehuntGame(); + + Q_PROPERTY(QDeclarativeListProperty tiles READ tiles CONSTANT) + QDeclarativeListProperty tiles(); + + Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged) + bool isPlaying() {return playing;} + + Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged) + bool hasWon() {return won;} + + Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged) + int numMines() const{return nMines;} + + Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged) + int numFlags() const{return nFlags;} + +public slots: + Q_INVOKABLE bool flip(int row, int col); + Q_INVOKABLE bool flag(int row, int col); + void setBoard(); + void reset(); + +signals: + void isPlayingChanged(); + void hasWonChanged(); + void numMinesChanged(); + void numFlagsChanged(); + +private: + bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; } + TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; } + int getHint(int row, int col); + void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();} + + QList _tiles; + int numCols; + int numRows; + bool playing; + bool won; + int remaining; + int nMines; + int nFlags; +}; diff --git a/examples/demos/minehunt/minehunt.pro b/examples/demos/minehunt/minehunt.pro new file mode 100644 index 0000000000..81b6b80486 --- /dev/null +++ b/examples/demos/minehunt/minehunt.pro @@ -0,0 +1,5 @@ +QT += declarative quick + +HEADERS += minehunt.h +SOURCES += main.cpp minehunt.cpp +RESOURCES = minehunt.qrc diff --git a/examples/demos/minehunt/minehunt.qml b/examples/demos/minehunt/minehunt.qml new file mode 100644 index 0000000000..7c4948a3bb --- /dev/null +++ b/examples/demos/minehunt/minehunt.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "MinehuntCore" 2.0 + +Item { + id: field + property int clickx: 0 + property int clicky: 0 + + width: 450; height: 450 + + Image { source: "MinehuntCore/pics/background.png"; anchors.fill: parent; fillMode: Image.Tile } + + Grid { + anchors.horizontalCenter: parent.horizontalCenter + columns: 9; spacing: 1 + + Repeater { + id: repeater + model: tiles + delegate: Tile {} + } + } + + Row { + id: gamedata + x: 20; spacing: 20 + anchors.bottom: field.bottom; anchors.bottomMargin: 15 + + Image { + source: "MinehuntCore/pics/quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + y: 10 + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -20 + onClicked: Qt.quit() + } + } + Column { + spacing: 2 + Image { source: "MinehuntCore/pics/bomb-color.png" } + Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numMines } + } + + Column { + spacing: 2 + Image { source: "MinehuntCore/pics/flag-color.png" } + Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numFlags } + } + } + + Image { + anchors.bottom: field.bottom; anchors.bottomMargin: 15 + anchors.right: field.right; anchors.rightMargin: 20 + source: isPlaying ? 'MinehuntCore/pics/face-smile.png' : + hasWon ? 'MinehuntCore/pics/face-smile-big.png': 'MinehuntCore/pics/face-sad.png' + + MouseArea { anchors.fill: parent; onPressed: reset() } + } + Text { + anchors.centerIn: parent; width: parent.width - 20 + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + text: "Minehunt demo has to be compiled to run.\n\nPlease see README." + color: "white"; font.bold: true; font.pixelSize: 14 + visible: tiles == undefined + } + +} diff --git a/examples/demos/minehunt/minehunt.qmlproject b/examples/demos/minehunt/minehunt.qmlproject new file mode 100644 index 0000000000..5aeb78f1ea --- /dev/null +++ b/examples/demos/minehunt/minehunt.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "minehunt.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/demos/minehunt/minehunt.qrc b/examples/demos/minehunt/minehunt.qrc new file mode 100644 index 0000000000..fa8e27d383 --- /dev/null +++ b/examples/demos/minehunt/minehunt.qrc @@ -0,0 +1,20 @@ + + + minehunt.qml + MinehuntCore/Explosion.qml + MinehuntCore/Tile.qml + MinehuntCore/qmldir + MinehuntCore/pics/background.png + MinehuntCore/pics/back.png + MinehuntCore/pics/bomb-color.png + MinehuntCore/pics/bomb.png + MinehuntCore/pics/face-sad.png + MinehuntCore/pics/face-smile-big.png + MinehuntCore/pics/face-smile.png + MinehuntCore/pics/flag-color.png + MinehuntCore/pics/flag.png + MinehuntCore/pics/front.png + MinehuntCore/pics/quit.png + MinehuntCore/pics/star.png + + diff --git a/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml new file mode 100644 index 0000000000..f183c4b2a0 --- /dev/null +++ b/examples/demos/photoviewer/PhotoViewerCore/AlbumDelegate.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +Component { + id: albumDelegate + Package { + + Item { + Package.name: 'browser' + GridView { + id: photosGridView; model: visualModel.parts.grid; width: mainWindow.width; height: mainWindow.height - 21 + x: 0; y: 21; cellWidth: 160; cellHeight: 153; interactive: false + onCurrentIndexChanged: photosListView.positionViewAtIndex(currentIndex, ListView.Contain) + } + } + + Item { + Package.name: 'fullscreen' + ListView { + id: photosListView; model: visualModel.parts.list; orientation: Qt.Horizontal + width: mainWindow.width; height: mainWindow.height; interactive: false + onCurrentIndexChanged: photosGridView.positionViewAtIndex(currentIndex, GridView.Contain) + highlightRangeMode: ListView.StrictlyEnforceRange; snapMode: ListView.SnapOneItem + } + } + + Item { + Package.name: 'album' + id: albumWrapper; width: 210; height: 220 + + VisualDataModel { + id: visualModel; delegate: PhotoDelegate { } + model: RssModel { id: rssModel; tags: tag } + } + + BusyIndicator { + id: busyIndicator + anchors { centerIn: parent; verticalCenterOffset: -20 } + on: rssModel.status != XmlListModel.Ready + } + + PathView { + id: photosPathView; model: visualModel.parts.stack; pathItemCount: 5 + visible: !busyIndicator.visible + anchors.centerIn: parent; anchors.verticalCenterOffset: -30 + path: Path { + PathAttribute { name: 'z'; value: 9999.0 } + PathLine { x: 1; y: 1 } + PathAttribute { name: 'z'; value: 0.0 } + } + } + + MouseArea { + anchors.fill: parent + onClicked: mainWindow.editMode ? photosModel.remove(index) : albumWrapper.state = 'inGrid' + } + + Tag { + anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 10 } + frontLabel: tag; backLabel: qsTr("Remove"); flipped: mainWindow.editMode + onTagChanged: rssModel.tags = tag + onBackClicked: if (mainWindow.editMode) photosModel.remove(index); + } + + states: [ + State { + name: 'inGrid' + PropertyChanges { target: photosGridView; interactive: true } + PropertyChanges { target: albumsShade; opacity: 1 } + PropertyChanges { target: backButton; onClicked: albumWrapper.state = ''; y: 6 } + }, + State { + name: 'fullscreen'; extend: 'inGrid' + PropertyChanges { target: photosGridView; interactive: false } + PropertyChanges { target: photosListView; interactive: true } + PropertyChanges { target: photosShade; opacity: 1 } + PropertyChanges { target: backButton; y: -backButton.height - 8 } + } + ] + + GridView.onAdd: NumberAnimation { + target: albumWrapper; properties: "scale"; from: 0.0; to: 1.0; easing.type: Easing.OutQuad + } + GridView.onRemove: SequentialAnimation { + PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: true } + NumberAnimation { target: albumWrapper; property: "scale"; from: 1.0; to: 0.0; easing.type: Easing.OutQuad } + PropertyAction { target: albumWrapper; property: "GridView.delayRemove"; value: false } + } + + transitions: [ + Transition { + from: '*'; to: 'inGrid' + SequentialAnimation { + NumberAnimation { properties: 'opacity'; duration: 250 } + PauseAnimation { duration: 350 } + NumberAnimation { target: backButton; properties: "y"; duration: 200; easing.type: Easing.OutQuad } + } + }, + Transition { + from: 'inGrid'; to: '*' + NumberAnimation { properties: "y,opacity"; easing.type: Easing.OutQuad; duration: 300 } + } + ] + } + } +} diff --git a/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml b/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml new file mode 100644 index 0000000000..2b1a75f369 --- /dev/null +++ b/examples/demos/photoviewer/PhotoViewerCore/BusyIndicator.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: container + property bool on: false + + source: "images/busy.png"; visible: container.on + NumberAnimation on rotation { running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 } +} diff --git a/examples/demos/photoviewer/PhotoViewerCore/Button.qml b/examples/demos/photoviewer/PhotoViewerCore/Button.qml new file mode 100644 index 0000000000..fcce969fbd --- /dev/null +++ b/examples/demos/photoviewer/PhotoViewerCore/Button.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property alias label: labelText.text + property color tint: "transparent" + signal clicked + + width: labelText.width + 70 ; height: labelText.height + 18 + + BorderImage { + anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } + source: 'images/box-shadow.png'; smooth: true + border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 + } + + Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true } + + Rectangle { + anchors.fill: container; color: container.tint; visible: container.tint != "" + opacity: 0.25; smooth: true + } + + Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent; smooth: true } + + MouseArea { + anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } + onClicked: container.clicked() + } +} diff --git a/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml b/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml new file mode 100644 index 0000000000..5d845938c7 --- /dev/null +++ b/examples/demos/photoviewer/PhotoViewerCore/EditableButton.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property string label + signal clicked + signal labelChanged(string label) + + width: textInput.width + 70 ; height: textInput.height + 18 + + BorderImage { + anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } + source: 'images/box-shadow.png'; smooth: true + border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 + } + + Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true } + + TextInput { + id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true + Keys.onReturnPressed: { + container.labelChanged(textInput.text) + container.focus = true + } + Keys.onEnterPressed: { + container.labelChanged(textInput.text) + container.focus = true + } + Keys.onEscapePressed: { + textInput.text = container.label + container.focus = true + } + } + + Rectangle { + anchors.fill: container; border.color: "steelblue"; border.width: 4 + color: "transparent"; visible: textInput.focus; smooth: true + } + + MouseArea { + anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } + onClicked: { textInput.forceActiveFocus(); textInput.openSoftwareInputPanel(); } + } +} diff --git a/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml b/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml new file mode 100644 index 0000000000..b972c938eb --- /dev/null +++ b/examples/demos/photoviewer/PhotoViewerCore/PhotoDelegate.qml @@ -0,0 +1,188 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "script/script.js" as Script + +Package { + Item { id: stackItem; Package.name: 'stack'; width: 160; height: 153; z: stackItem.PathView.z } + Item { id: listItem; Package.name: 'list'; width: mainWindow.width + 40; height: 153 } + Item { id: gridItem; Package.name: 'grid'; width: 160; height: 153 } + + Item { + width: 160; height: 153 + + Item { + id: photoWrapper + + property double randomAngle: Math.random() * (2 * 6 + 1) - 6 + property double randomAngle2: Math.random() * (2 * 6 + 1) - 6 + + x: 0; y: 0; width: 140; height: 133 + z: stackItem.PathView.z; rotation: photoWrapper.randomAngle + + BorderImage { + anchors { + fill: originalImage.status == Image.Ready ? border : placeHolder + leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 + } + source: 'images/box-shadow.png'; smooth: true + border.left: 10; border.top: 10; border.right: 10; border.bottom: 10 + } + Rectangle { + id: placeHolder + + property int w: Script.getWidth(content) + property int h: Script.getHeight(content) + property double s: Script.calculateScale(w, h, photoWrapper.width) + + color: 'white'; anchors.centerIn: parent; smooth: true + width: w * s; height: h * s; visible: originalImage.status != Image.Ready + Rectangle { + color: "#878787"; smooth: true + anchors { fill: parent; topMargin: 3; bottomMargin: 3; leftMargin: 3; rightMargin: 3 } + } + } + Rectangle { + id: border; color: 'white'; anchors.centerIn: parent; smooth: true + width: originalImage.paintedWidth + 6; height: originalImage.paintedHeight + 6 + visible: !placeHolder.visible + } + BusyIndicator { anchors.centerIn: parent; on: originalImage.status != Image.Ready } + Image { + id: originalImage; smooth: true; source: "http://" + Script.getImagePath(content); cache: false + fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height + } + Image { + id: hqImage; smooth: true; source: ""; visible: false; cache: false + fillMode: Image.PreserveAspectFit; width: photoWrapper.width; height: photoWrapper.height + } + Binding { + target: mainWindow; property: "downloadProgress"; value: hqImage.progress + when: listItem.ListView.isCurrentItem + } + Binding { + target: mainWindow; property: "imageLoading" + value: (hqImage.status == Image.Loading) ? 1 : 0; when: listItem.ListView.isCurrentItem + } + MouseArea { + width: originalImage.paintedWidth; height: originalImage.paintedHeight; anchors.centerIn: originalImage + onClicked: { + if (albumWrapper.state == 'inGrid') { + gridItem.GridView.view.currentIndex = index; + albumWrapper.state = 'fullscreen' + } else { + gridItem.GridView.view.currentIndex = index; + albumWrapper.state = 'inGrid' + } + } + } + + states: [ + State { + name: 'stacked'; when: albumWrapper.state == '' + ParentChange { target: photoWrapper; parent: stackItem; x: 10; y: 10 } + PropertyChanges { target: photoWrapper; opacity: stackItem.PathView.onPath ? 1.0 : 0.0 } + }, + State { + name: 'inGrid'; when: albumWrapper.state == 'inGrid' + ParentChange { target: photoWrapper; parent: gridItem; x: 10; y: 10; rotation: photoWrapper.randomAngle2 } + }, + State { + name: 'fullscreen'; when: albumWrapper.state == 'fullscreen' + ParentChange { + target: photoWrapper; parent: listItem; x: 0; y: 0; rotation: 0 + width: mainWindow.width; height: mainWindow.height + } + PropertyChanges { target: border; opacity: 0 } + PropertyChanges { target: hqImage; source: listItem.ListView.isCurrentItem ? hq : ""; visible: true } + } + ] + + transitions: [ + Transition { + from: 'stacked'; to: 'inGrid' + SequentialAnimation { + PauseAnimation { duration: 10 * index } + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { + target: photoWrapper; properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' + } + } + } + }, + Transition { + from: 'inGrid'; to: 'stacked' + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { properties: 'x,y,rotation,opacity'; duration: 600; easing.type: 'OutQuart' } + } + }, + Transition { + from: 'inGrid'; to: 'fullscreen' + SequentialAnimation { + PauseAnimation { duration: gridItem.GridView.isCurrentItem ? 0 : 600 } + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { + targets: [ photoWrapper, border ] + properties: 'x,y,width,height,opacity,rotation' + duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart' + } + } + } + }, + Transition { + from: 'fullscreen'; to: 'inGrid' + ParentAnimation { + target: photoWrapper; via: foreground + NumberAnimation { + targets: [ photoWrapper, border ] + properties: 'x,y,width,height,rotation,opacity' + duration: gridItem.GridView.isCurrentItem ? 600 : 1; easing.type: 'OutQuart' + } + } + } + ] + } + } +} diff --git a/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml b/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml new file mode 100644 index 0000000000..43c936e342 --- /dev/null +++ b/examples/demos/photoviewer/PhotoViewerCore/ProgressBar.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property real progress: 0 + + Behavior on opacity { NumberAnimation { duration: 600 } } + + Rectangle { anchors.fill: parent; color: "black"; opacity: 0.5 } + + Rectangle { + id: fill; color: "white"; height: container.height + width: container.width * container.progress + } +} diff --git a/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml b/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml new file mode 100644 index 0000000000..ab818924ac --- /dev/null +++ b/examples/demos/photoviewer/PhotoViewerCore/RssModel.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + property string tags : "" + + function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } + + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "") + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "content"; query: "content/string()" } + XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } +} diff --git a/examples/demos/photoviewer/PhotoViewerCore/Tag.qml b/examples/demos/photoviewer/PhotoViewerCore/Tag.qml new file mode 100644 index 0000000000..2b546a3ac6 --- /dev/null +++ b/examples/demos/photoviewer/PhotoViewerCore/Tag.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Flipable { + id: flipable + + property alias frontLabel: frontButton.label + property alias backLabel: backButton.label + + property int angle: 0 + property int randomAngle: Math.random() * (2 * 6 + 1) - 6 + property bool flipped: false + + signal frontClicked + signal backClicked + signal tagChanged(string tag) + + front: EditableButton { + id: frontButton; rotation: flipable.randomAngle + anchors { centerIn: parent; verticalCenterOffset: -20 } + onClicked: flipable.frontClicked() + onLabelChanged: flipable.tagChanged(label) + } + + back: Button { + id: backButton; tint: "red"; rotation: flipable.randomAngle + anchors { centerIn: parent; verticalCenterOffset: -20 } + onClicked: flipable.backClicked() + } + + transform: Rotation { + origin.x: flipable.width / 2; origin.y: flipable.height / 2 + axis.x: 0; axis.y: 1; axis.z: 0 + angle: flipable.angle + } + + states: State { + name: "back"; when: flipable.flipped + PropertyChanges { target: flipable; angle: 180 } + } + + transitions: Transition { + ParallelAnimation { + NumberAnimation { properties: "angle"; duration: 400 } + SequentialAnimation { + NumberAnimation { target: flipable; property: "scale"; to: 0.8; duration: 200 } + NumberAnimation { target: flipable; property: "scale"; to: 1.0; duration: 200 } + } + } + } +} diff --git a/examples/demos/photoviewer/PhotoViewerCore/images/box-shadow.png b/examples/demos/photoviewer/PhotoViewerCore/images/box-shadow.png new file mode 100644 index 0000000000..431af8545d Binary files /dev/null and b/examples/demos/photoviewer/PhotoViewerCore/images/box-shadow.png differ diff --git a/examples/demos/photoviewer/PhotoViewerCore/images/busy.png b/examples/demos/photoviewer/PhotoViewerCore/images/busy.png new file mode 100644 index 0000000000..664c2b1491 Binary files /dev/null and b/examples/demos/photoviewer/PhotoViewerCore/images/busy.png differ diff --git a/examples/demos/photoviewer/PhotoViewerCore/images/cardboard.png b/examples/demos/photoviewer/PhotoViewerCore/images/cardboard.png new file mode 100644 index 0000000000..1847ab528d Binary files /dev/null and b/examples/demos/photoviewer/PhotoViewerCore/images/cardboard.png differ diff --git a/examples/demos/photoviewer/PhotoViewerCore/qmldir b/examples/demos/photoviewer/PhotoViewerCore/qmldir new file mode 100644 index 0000000000..d3c247f21a --- /dev/null +++ b/examples/demos/photoviewer/PhotoViewerCore/qmldir @@ -0,0 +1,8 @@ +AlbumDelegate AlbumDelegate.qml +PhotoDelegate PhotoDelegate.qml +ProgressBar ProgressBar.qml +RssModel RssModel.qml +BusyIndicator BusyIndicator.qml +EditableButton EditableButton.qml +Button Button.qml +Tag Tag.qml diff --git a/examples/demos/photoviewer/PhotoViewerCore/script/script.js b/examples/demos/photoviewer/PhotoViewerCore/script/script.js new file mode 100644 index 0000000000..e8ef93a847 --- /dev/null +++ b/examples/demos/photoviewer/PhotoViewerCore/script/script.js @@ -0,0 +1,27 @@ +.pragma library + +function getWidth(string) { + return (string.match(/width=\"([0-9]+)\"/))[1] +} + +function getHeight(string) { + return (string.match(/height=\"([0-9]+)\"/))[1] +} + +function getImagePath(string) { + var pattern = /src=\"http:\/\/(\S+)\"/ + return (string.match(pattern))[1] +} + +function calculateScale(width, height, cellSize) { + var widthScale = (cellSize * 1.0) / width + var heightScale = (cellSize * 1.0) / height + var scale = 0 + + if (widthScale <= heightScale) { + scale = widthScale; + } else if (heightScale < widthScale) { + scale = heightScale; + } + return scale; +} diff --git a/examples/demos/photoviewer/i18n/base.ts b/examples/demos/photoviewer/i18n/base.ts new file mode 100644 index 0000000000..1accfd2f90 --- /dev/null +++ b/examples/demos/photoviewer/i18n/base.ts @@ -0,0 +1,30 @@ + + + + + AlbumDelegate + + + Remove + + + + + photoviewer + + + Add + + + + + Edit + + + + + Back + + + + diff --git a/examples/demos/photoviewer/i18n/qml_fr.qm b/examples/demos/photoviewer/i18n/qml_fr.qm new file mode 100644 index 0000000000..c24fcbc46c Binary files /dev/null and b/examples/demos/photoviewer/i18n/qml_fr.qm differ diff --git a/examples/demos/photoviewer/i18n/qml_fr.ts b/examples/demos/photoviewer/i18n/qml_fr.ts new file mode 100644 index 0000000000..9f892db616 --- /dev/null +++ b/examples/demos/photoviewer/i18n/qml_fr.ts @@ -0,0 +1,30 @@ + + + + + AlbumDelegate + + + Remove + Supprimer + + + + photoviewer + + + Add + Ajouter + + + + Edit + Éditer + + + + Back + Retour + + + diff --git a/examples/demos/photoviewer/photoviewer.qml b/examples/demos/photoviewer/photoviewer.qml new file mode 100644 index 0000000000..918438832b --- /dev/null +++ b/examples/demos/photoviewer/photoviewer.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "PhotoViewerCore" + +Rectangle { + id: mainWindow + + property real downloadProgress: 0 + property bool imageLoading: false + property bool editMode: false + + width: 800; height: 480; color: "#d5d6d8" + + ListModel { + id: photosModel + ListElement { tag: "Flowers" } + ListElement { tag: "Wildlife" } + ListElement { tag: "Prague" } + } + + VisualDataModel { id: albumVisualModel; model: photosModel; delegate: AlbumDelegate {} } + + GridView { + id: albumView; width: parent.width; height: parent.height; cellWidth: 210; cellHeight: 220 + model: albumVisualModel.parts.album; visible: albumsShade.opacity != 1.0 + } + + Column { + spacing: 20; anchors { bottom: parent.bottom; right: parent.right; rightMargin: 20; bottomMargin: 20 } + Button { + id: newButton; label: qsTr("Add"); rotation: 3 + anchors.horizontalCenter: parent.horizontalCenter + onClicked: { + mainWindow.editMode = false + photosModel.append( { tag: "" } ) + albumView.positionViewAtIndex(albumView.count - 1, GridView.Contain) + } + } + Button { + id: deleteButton; label: qsTr("Edit"); rotation: -2; + onClicked: mainWindow.editMode = !mainWindow.editMode + anchors.horizontalCenter: parent.horizontalCenter + } + Button { + id: quitButton; label: qsTr("Quit"); rotation: -2; + onClicked: Qt.quit() + anchors.horizontalCenter: parent.horizontalCenter + } + } + + Rectangle { + id: albumsShade; color: mainWindow.color + width: parent.width; height: parent.height; opacity: 0.0 + } + + ListView { anchors.fill: parent; model: albumVisualModel.parts.browser; interactive: false } + + Button { id: backButton; label: qsTr("Back"); rotation: 3; x: parent.width - backButton.width - 6; y: -backButton.height - 8 } + + Rectangle { id: photosShade; color: 'black'; width: parent.width; height: parent.height; opacity: 0; visible: opacity != 0.0 } + + ListView { anchors.fill: parent; model: albumVisualModel.parts.fullscreen; interactive: false } + + Item { id: foreground; anchors.fill: parent } + + ProgressBar { + progress: mainWindow.downloadProgress; width: parent.width; height: 4 + anchors.bottom: parent.bottom; opacity: mainWindow.imageLoading; visible: opacity != 0.0 + } +} diff --git a/examples/demos/photoviewer/photoviewer.qmlproject b/examples/demos/photoviewer/photoviewer.qmlproject new file mode 100644 index 0000000000..600bdb10f4 --- /dev/null +++ b/examples/demos/photoviewer/photoviewer.qmlproject @@ -0,0 +1,20 @@ +import QmlProject 1.1 + +Project { + mainFile: "photoviewer.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + Files { + filter: "*.ts" + directory: "i18n" + } +} diff --git a/examples/demos/plasmapatrol/PlasmaPatrol.qmlproject b/examples/demos/plasmapatrol/PlasmaPatrol.qmlproject new file mode 100644 index 0000000000..548295243d --- /dev/null +++ b/examples/demos/plasmapatrol/PlasmaPatrol.qmlproject @@ -0,0 +1,19 @@ +import QmlProject 1.1 + +Project { + mainFile: "plasmapatrol.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + Files { + paths: ["TODO"] + } +} diff --git a/examples/demos/plasmapatrol/TODO b/examples/demos/plasmapatrol/TODO new file mode 100644 index 0000000000..ef9d21a73d --- /dev/null +++ b/examples/demos/plasmapatrol/TODO @@ -0,0 +1,10 @@ +Realistic Tasks: +Particle explosions on ship death. +Better help text (both content and styled a little nicer). +Hardpoint help showing them firing across the screen. +Endless Demo Mode + +Nice-but-i-doubt-it-will-get-done Tasks: +Particle Text for the winner. +Particle-based buttons. +Single player mode that is challenges (known opponents) to master the game with and earn achievements (in addition to 'skirmish'). diff --git a/examples/demos/plasmapatrol/content/BlasterHardpoint.qml b/examples/demos/plasmapatrol/content/BlasterHardpoint.qml new file mode 100644 index 0000000000..4ac30d0202 --- /dev/null +++ b/examples/demos/plasmapatrol/content/BlasterHardpoint.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property variant target: {"y": -90, "x":12} + property Item targetObj: container + property Item hardpoint: container + property ParticleSystem system + property int blasts: 16 + property int bonusBlasts: 12 + property bool show: true + + width: 24 + height: 24 + Emitter { + id: visualization + group: "blaster" + system: container.system + enabled: show + anchors.fill: parent + shape: EllipseShape {} + speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true} + lifeSpan: 1000 + emitRate: 64 + + size: 24 + sizeVariation: 24 + endSize: 0 + } + + property int blastsLeft: 0 + function fireAt(targetArg, container) { + target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2); + targetObj = targetArg; + hardpoint = container; + blastsLeft = blasts; + rofTimer.repeat = true; + rofTimer.start(); + } + Timer { + id: rofTimer + interval: 30;//Has to be greater than 1 frame or they stack up + running: false + repeat: false + onTriggered: { + if (targetObj.hp <= 0) + return; + //TODO: calculate hit and damage at target, which must be a Ship + var hit; + if (blastsLeft >= bonusBlasts) + hit = Math.random() > targetObj.dodge; + else + hit = false; //purely aesthetic shots, because the damage isn't that fine grained + if (hit == true) { + switch (targetObj.shipType) { + case 1: hardpoint.damageDealt += 4; break; + case 2: hardpoint.damageDealt += 5; break; + case 3: hardpoint.damageDealt += 1; break; + default: hardpoint.damageDealt += 100; + } + } + blastVector.targetX = target.x; + blastVector.targetY = target.y; + if (!hit) {//TODO: Actual targetVariation + blastVector.targetX += (128 * Math.random() - 64); + blastVector.targetY += (128 * Math.random() - 64); + } + emitter.burst(1); + blastsLeft--; + if (!blastsLeft) + rofTimer.repeat = false; + } + } + Emitter { + id: emitter + group: "blaster" + enabled: false + system: container.system + anchors.centerIn: parent + + lifeSpan: 1000 + emitRate: 16 + maximumEmitted: blasts + size: 24 + endSize:16 + sizeVariation: 8 + speed: TargetDirection { + id: blastVector + targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true + } + } +} diff --git a/examples/demos/plasmapatrol/content/Button.qml b/examples/demos/plasmapatrol/content/Button.qml new file mode 100644 index 0000000000..405b99304f --- /dev/null +++ b/examples/demos/plasmapatrol/content/Button.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//TODO: Add particles to this component too +Rectangle { + id: container + property alias text: txt.text + signal clicked + //color: "lightsteelblue" + gradient: Gradient { + GradientStop { position: 0.0; color: "lightsteelblue" } + GradientStop { position: 1.0; color: "steelblue" } + } + height: 64 + radius: 16 + width: 128 + Text { + id: txt + anchors.centerIn: parent + font.pixelSize: 24 + color: "white" + } + MouseArea { + anchors.fill: parent + onClicked: container.clicked() + } +} diff --git a/examples/demos/plasmapatrol/content/CannonHardpoint.qml b/examples/demos/plasmapatrol/content/CannonHardpoint.qml new file mode 100644 index 0000000000..c4aa412760 --- /dev/null +++ b/examples/demos/plasmapatrol/content/CannonHardpoint.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property variant target: {"y": -90, "x":12} + property ParticleSystem system + property bool show: true + + width: 24 + height: 24 + Emitter { + id: visualization + group: "cannon" + enabled: container.show + system: container.system + anchors.centerIn: parent + lifeSpan: 2000 + emitRate: 1 + + size: 4 + endSize: 0 + } + + function fireAt(targetArg, hardpoint) { + target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2); + if (container.hp <= 0 || targetArg.hp <= 0) + return; + //TODO: calculate hit and damage at target, which must be a Ship + var hit = Math.random() > targetArg.dodge + if (hit) { + switch (targetArg.shipType) { + case 1: hardpoint.damageDealt += 8; break; + case 2: hardpoint.damageDealt += 10; break; + case 3: hardpoint.damageDealt += 16; break; + default: hardpoint.damageDealt += 1000; + } + } + emitter.burst(1); + } + Emitter { + id: emitter + group: "cannon" + enabled: false + system: container.system + anchors.centerIn: parent + + lifeSpan: 1000 + emitRate: 1 + size: 8 + endSize: 4 + speed: TargetDirection { + id: blastVector + targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true + } + } +} diff --git a/examples/demos/plasmapatrol/content/ChoiceBox.qml b/examples/demos/plasmapatrol/content/ChoiceBox.qml new file mode 100644 index 0000000000..a678bc9dd4 --- /dev/null +++ b/examples/demos/plasmapatrol/content/ChoiceBox.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + width: 360 + height: 160 + property ParticleSystem system + Ship { + id: nully + system: system + } + property Item target: nully + /* + Component.onCompleted: { + container.target.shipType = 1 + container.target.gunType = 1 + } + */ + Row { + anchors.horizontalCenter: parent.horizontalCenter + height: parent.height + spacing: 8 + Button { + width: 80 + height: 80 + anchors.verticalCenter: parent.verticalCenter + text: "Cycle\nShip" + onClicked: { + var nextVal = container.target.shipType; + if(nextVal == 3) + nextVal = 1; + else + nextVal++; + container.target.shipType = nextVal; + } + } + Item { + width: 128 + height: 128 + anchors.verticalCenter: parent.verticalCenter + Ship { + hp: 20 + anchors.centerIn: parent + shipType: container.target.shipType + gunType: container.target.gunType + system: container.system + } + } + Button { + width: 80 + height: 80 + anchors.verticalCenter: parent.verticalCenter + text: "Cycle\nGun" + onClicked: { + var nextVal = container.target.gunType; + if(nextVal == 3) + nextVal = 1; + else + nextVal++; + container.target.gunType = nextVal; + } + } + } +} diff --git a/examples/demos/plasmapatrol/content/Cruiser.qml b/examples/demos/plasmapatrol/content/Cruiser.qml new file mode 100644 index 0000000000..c689879dce --- /dev/null +++ b/examples/demos/plasmapatrol/content/Cruiser.qml @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property int maxHP: 100 + property int hp: maxHP + property real initialDodge: 0.01 + property real dodge: initialDodge + onHpChanged: if(hp <= 0) target = container; + property ParticleSystem system//TODO: Ship abstraction + property Item target: container + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + width: 128 + height: 128 + Emitter { + //TODO: Cooler would be an 'orbiting' affector + //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles + system: container.system + group: container.shipParticle + anchors.centerIn: parent + width: 64 + height: 64 + shape: EllipseShape {} + + emitRate: hp > 0 ? hp * 1 + 20 : 0 + lifeSpan: 2400 + maximumEmitted: (maxHP * 1 + 20)*2.4 + + size: 48 + sizeVariation: 16 + endSize: 16 + + speed: AngleDirection {angleVariation:360; magnitudeVariation: 32} + } + Emitter { + system: container.system + group: "cruiserArmor" + anchors.fill: parent + shape: EllipseShape { fill: false } + enabled: hp>0 + + emitRate: 16 + lifeSpan: 2000 + + size: 48 + sizeVariation: 24 + + SpriteGoal { + id: destructor + system: container.system + enabled: container.hp <=0 + anchors.fill: parent + groups: ["cruiserArmor"] + goalState: "death" +// jump: true + once: true + } + } + + Timer { + id: fireControl + property int next: Math.floor(Math.random() * 3) + 1 + interval: 800 + running: root.readySetGo + repeat: true + onTriggered: { + if (next == 1) { + gun1.fireAt(container.target); + next = Math.floor(Math.random() * 3) + 1; + } else if (next == 2) { + gun2.fireAt(container.target); + next = Math.floor(Math.random() * 3) + 1; + } else if (next == 3) { + gun3.fireAt(container.target); + next = Math.floor(Math.random() * 3) + 1; + } + } + } + + Hardpoint {//TODO: Hardpoint abstraction + x: 112 - 12 - 8*2 + y: 128 - 12 - 12*2 + id: gun1 + system: container.system + show: hp > 0 + hardpointType: gunType + } + Hardpoint { + x: 64 - 12 + y: 0 - 12 + 12*2 + id: gun2 + system: container.system + show: hp > 0 + hardpointType: gunType + } + Hardpoint { + x: 16 - 12 + 8*2 + y: 128 - 12 - 12*2 + id: gun3 + system: container.system + show: hp > 0 + hardpointType: gunType + } +} diff --git a/examples/demos/plasmapatrol/content/Frigate.qml b/examples/demos/plasmapatrol/content/Frigate.qml new file mode 100644 index 0000000000..de099bed72 --- /dev/null +++ b/examples/demos/plasmapatrol/content/Frigate.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property int maxHP: 100 + property int hp: maxHP + property real initialDodge: 0.2 + property real dodge: initialDodge + onHpChanged: if(hp <= 0) target = container; + property ParticleSystem system//TODO: Ship abstraction + property Item target: container + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + width: 128 + height: 128 + Emitter { + system: container.system + group: "frigateShield" + anchors.centerIn: parent + size: 92 + emitRate: 1 + lifeSpan: 4800 + enabled: hp > 0 + } + Emitter { + system: container.system + group: container.shipParticle + anchors.centerIn: parent + width: 64 + height: 16 + shape: EllipseShape {} + + size: 16 + sizeVariation: 8 + endSize: 8 + emitRate: hp > 0 ? hp * 1 + 20 : 0 + lifeSpan: 1200 + maximumEmitted: (maxHP * 1 + 20)*2 + } + Timer { + id: fireControl + property int next: Math.floor(Math.random() * 2) + 1 + interval: 800 + running: root.readySetGo + repeat: true + onTriggered: { + if (next == 1) { + gun1.fireAt(container.target); + next = Math.floor(Math.random() * 2) + 1; + } else if (next == 2) { + gun2.fireAt(container.target); + next = Math.floor(Math.random() * 2) + 1; + } + } + } + + Hardpoint { + x: 128 - 32 - 12 + y: 64 - 12 + id: gun1 + system: container.system + show: hp > 0 + hardpointType: gunType + } + Hardpoint { + x: 0 + 32 - 12 + y: 64 - 12 + id: gun2 + system: container.system + show: hp > 0 + hardpointType: gunType + } +} diff --git a/examples/demos/plasmapatrol/content/Hardpoint.qml b/examples/demos/plasmapatrol/content/Hardpoint.qml new file mode 100644 index 0000000000..5c7fb5521b --- /dev/null +++ b/examples/demos/plasmapatrol/content/Hardpoint.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + //ReflectiveProperties + //TransferredProperties + property variant target: {"y": -90, "x":12} + property ParticleSystem system + property bool show: true + property int hardpointType: 0 //default is pea shooter - always bad. + + property Item targetObj: null + property int damageDealt: 0 + onDamageDealtChanged: dealDamageTimer.start(); + Timer { + id: dealDamageTimer + interval: 16 + running: false + repeat: false + onTriggered: {targetObj.hp -= damageDealt; damageDealt = 0;} + } + width: 24 + height: 24 + function fireAt(targetArg) {//Each implement own + if (targetArg != null) { + hardpointLoader.item.fireAt(targetArg, container); + targetObj = targetArg; + } + } + Loader { + id: hardpointLoader + sourceComponent: { + switch (hardpointType) { + case 1: laserComponent; break; + case 2: blasterComponent; break; + case 3: cannonComponent; break; + default: emptyComponent; + } + } + } + Component { + id: laserComponent + LaserHardpoint { + target: container.target + system: container.system + show: container.show + } + } + Component { + id: blasterComponent + BlasterHardpoint { + target: container.target + system: container.system + show: container.show + } + } + Component { + id: cannonComponent + CannonHardpoint { + target: container.target + system: container.system + show: container.show + } + } + Component { + id: emptyComponent + Item { + function fireAt(obj) { + console.log("Firing null weapon. It hurts."); + } + } + } +} diff --git a/examples/demos/plasmapatrol/content/HelpScreens.qml b/examples/demos/plasmapatrol/content/HelpScreens.qml new file mode 100644 index 0000000000..9297f86f31 --- /dev/null +++ b/examples/demos/plasmapatrol/content/HelpScreens.qml @@ -0,0 +1,268 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +SequentialLoader { + id: hLdr + signal exitDesired + Component.onCompleted: advance(); + ParticleSystem { id: helpSystem } + PlasmaPatrolParticles { sys: helpSystem } + pages: [ + Component {Item { + id: story + Text { + color: "white" + text: "Story" + font.pixelSize: 48 + } + /* + Flickable { + y: 60 + width: 360 + height: 500 + contentHeight: txt1.height + contentWidth: 360//TODO: Less magic numbers? + */ + Text { + id: txt1 + color: "white" + y: 60 + font.pixelSize: 18 + text: " +In a remote nebula, a race of energy beings formed and lived prosperous lives for millenia. Until the schism - when they became constantly at each other's energy-throats. War soon followed, crippling both sides, until a truce was formed. But while governments knew the desparate need for peace, the soldiers in the ion-field were still filled with rampant bloodlust. On the border, patrols are constantly engaging in minor skirmishes whenever they cross paths. + +You must select one such patrol unit for the border, heading into an inevitable skirmish, in Plasma Patrol: the game of energy being spaceship combat! + " + width: 360 + wrapMode: Text.WordWrap + } + // } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Next" + onClicked: hLdr.advance(); + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }}, + Component {Item { + id: ships + Text { + color: "white" + text: "Vessels" + font.pixelSize: 48 + } + Column { + spacing: 16 + y: 60 + Row { + height: 128 + Sloop { + system: helpSystem + } + Text { + text: "The nimble sloop" + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + Frigate { + system: helpSystem + } + Text { + text: "The versitile shield frigate" + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + Cruiser { + system: helpSystem + } + Text { + text: "The armored cruiser" + color: "white" + font.pixelSize: 18 + } + } + } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Next" + onClicked: hLdr.advance(); + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }}, + Component {Item { + id: guns + Text { + color: "white" + text: "Hardpoints" + font.pixelSize: 48 + } + Column { + spacing: 16 + y: 60 + Row { + height: 128 + LaserHardpoint { + system: helpSystem + } + Text { + text: "The laser hardpoint almost always hits the target, even the nimble sloop, but loses much of its potency against the frigate's shields" + width: 332 + wrapMode: Text.WordWrap + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + BlasterHardpoint { + system: helpSystem + } + Text { + text: "The blaster passes right through the frigate's shields but loses much of its impact against the armor of the cruiser" + width: 332 + wrapMode: Text.WordWrap + color: "white" + font.pixelSize: 18 + } + } + Row { + height: 128 + CannonHardpoint { + system: helpSystem + } + Text { + text: "The cannon has poor accuracy, often missing the nimble sloop, but can punch right through the armor of the cruiser" + width: 332 + wrapMode: Text.WordWrap + color: "white" + font.pixelSize: 18 + } + } + } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Next" + onClicked: hLdr.advance(); + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }}, + Component {Item { + id: strategy + Text { + color: "white" + text: "Strategy" + font.pixelSize: 48 + } + Flickable { + y: 60 + width: 360 + height: 500 + contentHeight: txt1.height + contentWidth: 360//TODO: Less magic numbers? + Text { + id: txt1 + color: "white" + font.pixelSize: 18 + text: " +Basic Strategy: Good luck, have fun - don't die. +More to come after thorough playtesting. + " + width: 360 + wrapMode: Text.WordWrap + } + } + Button { + x: 20 + y: 560 + height: 40 + width: 120 + text: "Story" + onClicked: {hLdr.at=0; hLdr.advance();} + } + Button { + x: 220 + y: 560 + height: 40 + width: 120 + text: "Menu" + onClicked: hLdr.exitDesired(); + } + }} + ] +} diff --git a/examples/demos/plasmapatrol/content/LaserHardpoint.qml b/examples/demos/plasmapatrol/content/LaserHardpoint.qml new file mode 100644 index 0000000000..87ac3e9e62 --- /dev/null +++ b/examples/demos/plasmapatrol/content/LaserHardpoint.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property variant target: {"y": -90, "x":12} + property ParticleSystem system + property bool show: true + + width: 24 + height: 24 + Emitter { + id: visualization + group: "laser" + system: container.system + anchors.fill: parent + enabled: container.show + shape: EllipseShape {} + speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true } + lifeSpan: 1000 + emitRate: 64 + + size: 24 + sizeVariation: 8 + endSize: 8 + } + + function fireAt(targetArg, hardpoint) { + if (targetArg.hp <= 0) + return; + //TODO: calculate hit and damage at target, which must be a Ship + var offset = 0; + if (Math.random() < 0.99) { + switch (targetArg.shipType) { + case 1: hardpoint.damageDealt += 16; break; + case 2: hardpoint.damageDealt += 4; break; + case 3: hardpoint.damageDealt += 8; break; + default: hardpoint.damageDealt += 500; //Really effective against unregistered vessels + } + } else {//Misses with Lasers are really rare + offset = Math.random() * 100; + } + target = container.mapFromItem(targetArg, offset + targetArg.width/2, offset + targetArg.height/2); + emitter.pulse(100); + // console.log("Fire box: " + Math.min(container.width/2, target.x) + "," + Math.min(container.height/2, target.y) + " " + (Math.max(container.width/2, target.x) - Math.min(container.width/2, target.x)) + "," + (Math.max(container.height/2, target.y) - Math.min(container.height/2, target.y))); + } + Emitter { + id: emitter + group: "laser" + enabled: false + system: container.system + x: Math.min(container.width/2, target.x); + width: Math.max(container.width/2, target.x) - x; + y: Math.min(container.height/2, target.y); + height: Math.max(container.height/2, target.y) - y; + shape: LineShape { + mirrored: (emitter.y < 0 || emitter.x < 0) && !(emitter.y < 0 && emitter.x < 0 )//I just want XOR + } + + lifeSpan: 1000 + emitRate: 8000 + maximumEmitted: 800 + size: 16 + endSize: 0 + + speed: PointDirection {xVariation: 4; yVariation: 4} + } +} diff --git a/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml new file mode 100644 index 0000000000..95d4bcd2b9 --- /dev/null +++ b/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + property ParticleSystem sys + ImageParticle { + system: sys + groups: ["default"] + source: "pics/blur-circle3.png" + color: "#003A3A3A" + colorVariation: 0.1 + z: 0 + } + ImageParticle { + system: sys + groups: ["redTeam"] + source: "pics/blur-circle3.png" + color: "#0028060A" + colorVariation: 0.1 + z: 0 + } + ImageParticle { + system: sys + groups: ["greenTeam"] + source: "pics/blur-circle3.png" + color: "#0006280A" + colorVariation: 0.1 + z: 0 + } + ImageParticle { + system: sys + groups: ["blaster"] + source: "pics/star2.png" + //color: "#0F282406" + color: "#0F484416" + colorVariation: 0.2 + z: 2 + } + ImageParticle { + system: sys + groups: ["laser"] + source: "pics/star3.png" + //color: "#00123F68" + color: "#00428FF8" + colorVariation: 0.2 + z: 2 + } + ImageParticle { + system: sys + groups: ["cannon"] + source: "pics/particle.png" + color: "#80FFAAFF" + colorVariation: 0.1 + z: 2 + } + ImageParticle { + system: sys + groups: ["cannonCore"] + source: "pics/particle.png" + color: "#00666666" + colorVariation: 0.8 + z: 1 + } + ImageParticle { + system: sys + groups: ["cannonWake"] + source: "pics/star.png" + color: "#00CCCCCC" + colorVariation: 0.2 + z: 1 + } + ImageParticle { + system: sys + groups: ["frigateShield"] + source: "pics/blur-circle2.png" + color: "#00000000" + colorVariation: 0.05 + blueVariation: 0.5 + greenVariation: 0.1 + z: 3 + } + ImageParticle { + system: sys + groups: ["cruiserArmor"] + z: 1 + sprites:[Sprite { + id: spinState + name: "spinning" + source: "pics/meteor.png" + frames: 35 + frameDuration: 40 + to: {"death":0, "spinning":1} + },Sprite { + name: "death" + source: "pics/meteor_explo.png" + frames: 22 + frameDuration: 40 + to: {"null":1} + }, Sprite { + name: "null" + source: "pics/nullRock.png" + frames: 1 + frameDuration: 1000 + } + ] + } + TrailEmitter { + system: sys + group: "cannonWake" + follow: "cannon" + emitRatePerParticle: 64 + lifeSpan: 600 + speed: AngleDirection { angleVariation: 360; magnitude: 48} + size: 16 + endSize: 8 + sizeVariation: 2 + enabled: true + width: 1000//XXX: Terrible hack + height: 1000 + } + TrailEmitter { + system: sys + group: "cannonCore" + follow: "cannon" + emitRatePerParticle: 256 + lifeSpan: 128 + size: 24 + endSize: 8 + enabled: true + width: 1000//XXX: Terrible hack + height: 1000 + } +} diff --git a/examples/demos/plasmapatrol/content/SequentialLoader.qml b/examples/demos/plasmapatrol/content/SequentialLoader.qml new file mode 100644 index 0000000000..eaef87fe57 --- /dev/null +++ b/examples/demos/plasmapatrol/content/SequentialLoader.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + id: container + //TODO: Somehow get particles into this? + property list pages + property Item cur: null + property int at: 0 + function advance() { + if(cur != null) + cur.destroy(); + cur = pages[at++].createObject(container); + } +} diff --git a/examples/demos/plasmapatrol/content/Ship.qml b/examples/demos/plasmapatrol/content/Ship.qml new file mode 100644 index 0000000000..a928cd2a2e --- /dev/null +++ b/examples/demos/plasmapatrol/content/Ship.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: me + //Reflective Properties + width: shipLoader.width + height: shipLoader.height + //Transfered Properties + property int hp: 100//shipLoader.item.maxHP + property real dodge: shipLoader.item.initialDodge + property ParticleSystem system + property int targetIdx: 0 + property Item target: targets[targetIdx] == undefined?null:targets[targetIdx] + Connections { + target: me.target + onHpChanged: if (me.target.hp<=0) me.targetIdx++; + } + property list targets + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + property int shipType: 0 + Component { + id: sloopComp + Sloop { + system: me.system + target: me.target + shipParticle: me.shipParticle + gunType: me.gunType + hp: me.hp + dodge: me.dodge + } + } + Component { + id: frigateComp + Frigate { + system: me.system + target: me.target + shipParticle: me.shipParticle + gunType: me.gunType + hp: me.hp + dodge: me.dodge + } + } + Component { + id: cruiserComp + Cruiser { + system: me.system + target: me.target + shipParticle: me.shipParticle + gunType: me.gunType + hp: me.hp + dodge: me.dodge + } + } + Component { + id: dumbComp + Item { + property int maxHP: 0 + property int initialDodge: 0 + } + } + Loader { + id: shipLoader + sourceComponent: { + switch (shipType) { + case 1: sloopComp; break; + case 2: frigateComp; break; + case 3: cruiserComp; break; + default: dumbComp; + } + } + } +} diff --git a/examples/demos/plasmapatrol/content/Sloop.qml b/examples/demos/plasmapatrol/content/Sloop.qml new file mode 100644 index 0000000000..c6b1183162 --- /dev/null +++ b/examples/demos/plasmapatrol/content/Sloop.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: container + property int maxHP: 100 + property int hp: maxHP + property real initialDodge: 0.5 + property real dodge: initialDodge + property int blinkInterval: 800 + onHpChanged: if(hp <= 0) target = container; + property ParticleSystem system//TODO: Ship abstraction + property Item target: container + property string shipParticle: "default"//Per team colors? + property int gunType: 0 + width: 128 + height: 128 + Emitter { + id: emitter + //TODO: Cooler would be an 'orbiting' affector + //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles + system: container.system + group: container.shipParticle + shape: EllipseShape {} + + emitRate: hp > 0 ? hp + 20 : 0 + lifeSpan: blinkInterval + maximumEmitted: (maxHP + 20) + + acceleration: AngleDirection {angleVariation: 360; magnitude: 8} + + size: 24 + endSize: 4 + sizeVariation: 8 + width: 16 + height: 16 + x: 64 + y: 64 + Behavior on x {NumberAnimation {duration:blinkInterval}} + Behavior on y {NumberAnimation {duration:blinkInterval}} + Timer { + interval: blinkInterval + running: true + repeat: true + onTriggered: { + emitter.x = Math.random() * 48 + 32 + emitter.y = Math.random() * 48 + 32 + } + } + } + Hardpoint { + anchors.centerIn: parent + id: gun2 + system: container.system + show: container.hp > 0 + hardpointType: gunType + } + Timer { + id: fireControl + interval: 800 + running: root.readySetGo + repeat: true + onTriggered: { + gun2.fireAt(container.target); + } + } + +} diff --git a/examples/demos/plasmapatrol/content/pics/TitleText.png b/examples/demos/plasmapatrol/content/pics/TitleText.png new file mode 100644 index 0000000000..dc3acebe39 Binary files /dev/null and b/examples/demos/plasmapatrol/content/pics/TitleText.png differ diff --git a/examples/demos/plasmapatrol/content/pics/blur-circle2.png b/examples/demos/plasmapatrol/content/pics/blur-circle2.png new file mode 100644 index 0000000000..f7c9f3e98e Binary files /dev/null and b/examples/demos/plasmapatrol/content/pics/blur-circle2.png differ diff --git a/examples/demos/plasmapatrol/content/pics/blur-circle3.png b/examples/demos/plasmapatrol/content/pics/blur-circle3.png new file mode 100644 index 0000000000..dbc39cb16e Binary files /dev/null and b/examples/demos/plasmapatrol/content/pics/blur-circle3.png differ diff --git a/examples/demos/plasmapatrol/content/pics/finalfrontier.png b/examples/demos/plasmapatrol/content/pics/finalfrontier.png new file mode 100644 index 0000000000..2ba1815230 Binary files /dev/null and b/examples/demos/plasmapatrol/content/pics/finalfrontier.png differ diff --git a/examples/demos/plasmapatrol/content/pics/meteor.png b/examples/demos/plasmapatrol/content/pics/meteor.png new file mode 100644 index 0000000000..e8c368aea7 Binary files /dev/null and b/examples/demos/plasmapatrol/content/pics/meteor.png differ diff --git a/examples/demos/plasmapatrol/content/pics/meteor_explo.png b/examples/demos/plasmapatrol/content/pics/meteor_explo.png new file mode 100644 index 0000000000..4297245d49 Binary files /dev/null and b/examples/demos/plasmapatrol/content/pics/meteor_explo.png differ diff --git a/examples/demos/plasmapatrol/content/pics/nullRock.png b/examples/demos/plasmapatrol/content/pics/nullRock.png new file mode 100644 index 0000000000..4076327a1a Binary files /dev/null and b/examples/demos/plasmapatrol/content/pics/nullRock.png differ diff --git a/examples/demos/plasmapatrol/content/pics/particle.png b/examples/demos/plasmapatrol/content/pics/particle.png new file mode 100644 index 0000000000..5c83896d22 Binary files /dev/null and b/examples/demos/plasmapatrol/content/pics/particle.png differ diff --git a/examples/demos/plasmapatrol/content/pics/star.png b/examples/demos/plasmapatrol/content/pics/star.png new file mode 100644 index 0000000000..0d592cfa87 Binary files /dev/null and b/examples/demos/plasmapatrol/content/pics/star.png differ diff --git a/examples/demos/plasmapatrol/content/pics/star2.png b/examples/demos/plasmapatrol/content/pics/star2.png new file mode 100644 index 0000000000..bb55c44788 Binary files /dev/null and b/examples/demos/plasmapatrol/content/pics/star2.png differ diff --git a/examples/demos/plasmapatrol/content/pics/star3.png b/examples/demos/plasmapatrol/content/pics/star3.png new file mode 100644 index 0000000000..636a25f480 Binary files /dev/null and b/examples/demos/plasmapatrol/content/pics/star3.png differ diff --git a/examples/demos/plasmapatrol/plasmapatrol.qml b/examples/demos/plasmapatrol/plasmapatrol.qml new file mode 100644 index 0000000000..45f81c7222 --- /dev/null +++ b/examples/demos/plasmapatrol/plasmapatrol.qml @@ -0,0 +1,386 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Rectangle { + id: root + property bool readySetGo: false + //Debugging + property int hits: 0 + property int misses: 0 + property real ratio: hits/(misses?misses:1) + //Move to JS file? + property Ship redVar1: Ship {shipType: 1; gunType: 1} + property Ship redVar2: Ship {shipType: 1; gunType: 2} + property Ship redVar3: Ship {shipType: 1; gunType: 3} + property Ship greenVar1: Ship {shipType: 3; gunType: 1} + property Ship greenVar2: Ship {shipType: 2; gunType: 2} + property Ship greenVar3: Ship {shipType: 1; gunType: 3} + property string winner: "0" + property int players: 0 + function aiSet(ship) { + ship.gunType = Math.floor(Math.random() * 3) + 1 + ship.shipType = Math.floor(Math.random() * 3) + 1 + } + + width: 360 + height: 600 + color: "black" + SequentialLoader { + anchors.fill: parent + //General Children + Image { + anchors.centerIn: parent + source: "../images/finalfrontier.png" + } + ParticleSystem { + id: particles + } + PlasmaPatrolParticles { sys: particles; z: 100 }//Renders all particles on the one plane + //Component parts + id: pageControl + Component.onCompleted: advance(); + pages:[ + Component {Item { + id: menu + width: root.width + height: root.height + Column { + anchors.verticalCenter: parent.verticalCenter + width: parent.width + spacing: 8 + Item { + id: title + width: root.width + height: 240 + Emitter { + anchors.fill: parent + system: particles + enabled: true + group: "default" + emitRate: 1200 + lifeSpan: 1200 + shape: MaskShape {source:"content/pics/TitleText.png"} + size: 16 + endSize: 0 + sizeVariation: 8 + speed: AngleDirection {angleVariation:360; magnitudeVariation: 6} + } + } + Button { + text: "1P" + onClicked: {root.players = 1; pageControl.advance();} + anchors.horizontalCenter: parent.horizontalCenter + } + Button { + text: "2P" + onClicked: {root.players = 2; pageControl.advance();} + anchors.horizontalCenter: parent.horizontalCenter + } + Button { + text: "Demo" + anchors.horizontalCenter: parent.horizontalCenter + onClicked: {root.players = 0; + aiSet(redVar1); + aiSet(redVar2); + aiSet(redVar3); + aiSet(greenVar1); + aiSet(greenVar2); + aiSet(greenVar3); + pageControl.at = 5;//TODO: Not a magic number + pageControl.advance();} + } + Button { + text: "Help" + anchors.horizontalCenter: parent.horizontalCenter + onClicked: { + pageControl.at = 7;//TODO: Not a magic number + pageControl.advance(); + } + } + Button { + text: "Quit" + anchors.horizontalCenter: parent.horizontalCenter + onClicked: Qt.quit(); + } + } + }}, + Component {Item { + id: p1Screen + z: 101 + width: root.width + height: root.height + Rectangle { + anchors.fill: parent + color: "red" + } + Text { + anchors.centerIn: parent + color: "white" + font.pixelSize: 64 + font.bold: true + text: "Player\n 1" + horizontalAlignment: Text.AlignHCenter + } + MouseArea { + anchors.fill: parent + onClicked: pageControl.advance() + } + }}, + Component {Item { + id: p1Choices + z: 3 + width: root.width + height: root.height + Rectangle { + color: "black" + anchors.fill: parent + } + Column { + spacing: 16 + width: root.width + anchors.horizontalCenter: parent.horizontalCenter + ChoiceBox { + target: redVar1 + system: particles + } + ChoiceBox { + target: redVar2 + system: particles + } + ChoiceBox { + target: redVar3 + system: particles + } + Button { + anchors.horizontalCenter: parent.horizontalCenter + text: "Next" + onClicked: { + if (root.players < 2) { + aiSet(greenVar1); + aiSet(greenVar2); + aiSet(greenVar3); + pageControl.at = 5;//TODO: Not a magic number + } + pageControl.advance(); + } + } + } + }}, + Component {Item { + id: p2Screen + z: 101 + width: root.width + height: root.height + Rectangle { + anchors.fill: parent + color: "green" + } + Text { + anchors.centerIn: parent + color: "white" + font.pixelSize: 64 + font.bold: true + text: "Player\n 2" + horizontalAlignment: Text.AlignHCenter + } + MouseArea { + anchors.fill: parent + onClicked: pageControl.advance() + } + }}, + Component {Item { + id: p2Choices + z: 1 + width: root.width + height: root.height + Rectangle { + color: "black" + anchors.fill: parent + } + Column { + spacing: 16 + width: root.width + anchors.horizontalCenter: parent.horizontalCenter + ChoiceBox { + target: greenVar1 + system: particles + } + ChoiceBox { + target: greenVar2 + system: particles + } + ChoiceBox { + target: greenVar3 + system: particles + } + Button { + anchors.horizontalCenter: parent.horizontalCenter + text: "Next" + onClicked: pageControl.advance() + } + } + }}, + Component {Item { + id: arena + width: root.width + height: root.height + z: 0 + Component.onCompleted: root.readySetGo = true + Component.onDestruction: root.readySetGo = false + property bool victory: redShip3.hp <= 0 || greenShip3.hp <=0 + onVictoryChanged: { + if (redShip3.hp <= 0) { + if (greenShip3.hp <= 0) { + root.winner = "1&2" + }else { + root.winner = "2" + } + } else { + root.winner = "1" + } + winTimer.start() + } + Timer { + id: winTimer + interval: 1200 + repeat: false + running: false + onTriggered: pageControl.advance(); + } + Ship { + id: redShip1 + shipParticle: "redTeam" + system: particles + x: 180-64 + y: 128 + shipType: redVar1.shipType + gunType: redVar1.gunType + targets: [greenShip1, greenShip2, greenShip3] + } + Ship { + id: redShip2 + shipParticle: "redTeam" + system: particles + x: 0 + y: 0 + shipType: redVar2.shipType + gunType: redVar2.gunType + targets: [greenShip1, greenShip2, greenShip3] + } + Ship { + id: redShip3 + shipParticle: "redTeam" + system: particles + x: 360-128 + y: 0 + shipType: redVar3.shipType + gunType: redVar3.gunType + targets: [greenShip1, greenShip2, greenShip3] + } + + Ship { + id: greenShip1 + shipParticle: "greenTeam" + system: particles + x: 180-64 + y: 600 - 128 - 128 + shipType: greenVar1.shipType + gunType: greenVar1.gunType + targets: [redShip1, redShip2, redShip3] + } + Ship { + id: greenShip2 + shipParticle: "greenTeam" + system: particles + x: 0 + y: 600-128 + shipType: greenVar2.shipType + gunType: greenVar2.gunType + targets: [redShip1, redShip2, redShip3] + } + Ship { + id: greenShip3 + shipParticle: "greenTeam" + system: particles + x: 360 - 128 + y: 600 - 128 + shipType: greenVar3.shipType + gunType: greenVar3.gunType + targets: [redShip1, redShip2, redShip3] + } + }}, + Component {Item { + id: winScreen + z: 101 + width: root.width + height: root.height + /* + Rectangle { + anchors.fill: parent + color: "black" + } + */ + Text {//TODO: Particle Text? + anchors.fill: parent + color: "white" + font.pixelSize: 64 + font.bold: true + text: "Player " + root.winner + " wins!" + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + MouseArea { + anchors.fill: parent + onClicked: {pageControl.at = 0; pageControl.advance();} + } + }}, + Component { + HelpScreens { + onExitDesired: {pageControl.at = 0; pageControl.advance();} + } + } + ] + } +} diff --git a/examples/demos/rssnews/content/BusyIndicator.qml b/examples/demos/rssnews/content/BusyIndicator.qml new file mode 100644 index 0000000000..b6264ead92 --- /dev/null +++ b/examples/demos/rssnews/content/BusyIndicator.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: container + property bool on: false + + source: "images/busy.png"; visible: container.on + + NumberAnimation on rotation { + running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200 + } +} diff --git a/examples/demos/rssnews/content/CategoryDelegate.qml b/examples/demos/rssnews/content/CategoryDelegate.qml new file mode 100644 index 0000000000..1a56184489 --- /dev/null +++ b/examples/demos/rssnews/content/CategoryDelegate.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: delegate + + width: delegate.ListView.view.width; height: 60 + + Text { + text: name + color: delegate.ListView.isCurrentItem ? "white" : "black" + font { family: "Helvetica"; pixelSize: 16; bold: true } + anchors { + left: parent.left; leftMargin: 15 + verticalCenter: parent.verticalCenter + } + } + + BusyIndicator { + scale: 0.6 + on: delegate.ListView.isCurrentItem && window.loading + anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter } + } + + Rectangle { + width: delegate.width; height: 1; color: "#cccccc" + anchors.bottom: delegate.bottom + visible: delegate.ListView.isCurrentItem ? false : true + } + Rectangle { + width: delegate.width; height: 1; color: "white" + visible: delegate.ListView.isCurrentItem ? false : true + } + + MouseArea { + anchors.fill: delegate + onClicked: { + delegate.ListView.view.currentIndex = index + window.currentFeed = feed + } + } +} diff --git a/examples/demos/rssnews/content/NewsDelegate.qml b/examples/demos/rssnews/content/NewsDelegate.qml new file mode 100644 index 0000000000..84019a9179 --- /dev/null +++ b/examples/demos/rssnews/content/NewsDelegate.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: delegate + height: column.height + 40 + width: delegate.ListView.view.width + + Column { + id: column + x: 20; y: 20 + width: parent.width - 40 + + Text { + id: titleText + text: title; width: parent.width; wrapMode: Text.WordWrap + font { bold: true; family: "Helvetica"; pointSize: 16 } + } + + Text { + id: descriptionText + width: parent.width; text: description + wrapMode: Text.WordWrap; font.family: "Helvetica" + } + } + + Rectangle { + width: parent.width; height: 1; color: "#cccccc" + anchors.bottom: parent.bottom + } +} diff --git a/examples/demos/rssnews/content/RssFeeds.qml b/examples/demos/rssnews/content/RssFeeds.qml new file mode 100644 index 0000000000..278f05752c --- /dev/null +++ b/examples/demos/rssnews/content/RssFeeds.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + id: rssFeeds + + ListElement { name: "Top Stories"; feed: "rss.news.yahoo.com/rss/topstories" } + ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" } + ListElement { name: "Europe"; feed: "rss.news.yahoo.com/rss/europe" } + ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" } + ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" } + ListElement { name: "Politics"; feed: "rss.news.yahoo.com/rss/politics" } + ListElement { name: "Business"; feed: "rss.news.yahoo.com/rss/business" } + ListElement { name: "Technology"; feed: "rss.news.yahoo.com/rss/tech" } + ListElement { name: "Entertainment"; feed: "rss.news.yahoo.com/rss/entertainment" } + ListElement { name: "Health"; feed: "rss.news.yahoo.com/rss/health" } + ListElement { name: "Science"; feed: "rss.news.yahoo.com/rss/science" } + ListElement { name: "Sports"; feed: "rss.news.yahoo.com/rss/sports" } +} diff --git a/examples/demos/rssnews/content/ScrollBar.qml b/examples/demos/rssnews/content/ScrollBar.qml new file mode 100644 index 0000000000..4ca4132c6b --- /dev/null +++ b/examples/demos/rssnews/content/ScrollBar.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + property variant scrollArea + property variant orientation: Qt.Vertical + + opacity: 0 + + function position() + { + var ny = 0; + if (container.orientation == Qt.Vertical) + ny = scrollArea.visibleArea.yPosition * container.height; + else + ny = scrollArea.visibleArea.xPosition * container.width; + if (ny > 2) return ny; else return 2; + } + + function size() + { + var nh, ny; + + if (container.orientation == Qt.Vertical) + nh = scrollArea.visibleArea.heightRatio * container.height; + else + nh = scrollArea.visibleArea.widthRatio * container.width; + + if (container.orientation == Qt.Vertical) + ny = scrollArea.visibleArea.yPosition * container.height; + else + ny = scrollArea.visibleArea.xPosition * container.width; + + if (ny > 3) { + var t; + if (container.orientation == Qt.Vertical) + t = Math.ceil(container.height - 3 - ny); + else + t = Math.ceil(container.width - 3 - ny); + if (nh > t) return t; else return nh; + } else return nh + ny; + } + + Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 } + + BorderImage { + source: "images/scrollbar.png" + border { left: 1; right: 1; top: 1; bottom: 1 } + x: container.orientation == Qt.Vertical ? 2 : position() + width: container.orientation == Qt.Vertical ? container.width - 4 : size() + y: container.orientation == Qt.Vertical ? position() : 2 + height: container.orientation == Qt.Vertical ? size() : container.height - 4 + } + + states: State { + name: "visible" + when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally + PropertyChanges { target: container; opacity: 1.0 } + } + + transitions: Transition { + from: "visible"; to: "" + NumberAnimation { properties: "opacity"; duration: 600 } + } +} diff --git a/examples/demos/rssnews/content/images/busy.png b/examples/demos/rssnews/content/images/busy.png new file mode 100644 index 0000000000..664c2b1491 Binary files /dev/null and b/examples/demos/rssnews/content/images/busy.png differ diff --git a/examples/demos/rssnews/content/images/scrollbar.png b/examples/demos/rssnews/content/images/scrollbar.png new file mode 100644 index 0000000000..0228dcf9eb Binary files /dev/null and b/examples/demos/rssnews/content/images/scrollbar.png differ diff --git a/examples/demos/rssnews/rssnews.qml b/examples/demos/rssnews/rssnews.qml new file mode 100644 index 0000000000..491cefda07 --- /dev/null +++ b/examples/demos/rssnews/rssnews.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 +import "content" + +Rectangle { + id: window + width: 800; height: 480 + + property string currentFeed: "rss.news.yahoo.com/rss/topstories" + property bool loading: feedModel.status == XmlListModel.Loading + + RssFeeds { id: rssFeeds } + + XmlListModel { + id: feedModel + source: "http://" + window.currentFeed + query: "/rss/channel/item" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "link"; query: "link/string()" } + XmlRole { name: "description"; query: "description/string()" } + } + + Row { + Rectangle { + width: 220; height: window.height + color: "#efefef" + + ListView { + focus: true + id: categories + anchors.fill: parent + model: rssFeeds + footer: quitButtonDelegate + delegate: CategoryDelegate {} + highlight: Rectangle { color: "steelblue" } + highlightMoveSpeed: 9999999 + } + ScrollBar { + scrollArea: categories; height: categories.height; width: 8 + anchors.right: categories.right + } + } + ListView { + id: list + width: window.width - 220; height: window.height + model: feedModel + delegate: NewsDelegate {} + } + } + Component { + id: quitButtonDelegate + Item { + width: categories.width; height: 60 + Text { + text: "Quit" + font { family: "Helvetica"; pixelSize: 16; bold: true } + anchors { + left: parent.left; leftMargin: 15 + verticalCenter: parent.verticalCenter + } + } + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + } + ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right } + Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" } +} diff --git a/examples/demos/rssnews/rssnews.qmlproject b/examples/demos/rssnews/rssnews.qmlproject new file mode 100644 index 0000000000..5becbdaed0 --- /dev/null +++ b/examples/demos/rssnews/rssnews.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "rssnews.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/demos/samegame/content/BoomBlock.qml b/examples/demos/samegame/content/BoomBlock.qml new file mode 100644 index 0000000000..47f86bd81b --- /dev/null +++ b/examples/demos/samegame/content/BoomBlock.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: block + property bool dying: false + property bool spawned: false + property int type: 0 + property ParticleSystem particleSystem + + Behavior on x { + enabled: spawned; + SpringAnimation{ spring: 2; damping: 0.2 } + } + Behavior on y { + SpringAnimation{ spring: 2; damping: 0.2 } + } + + Image { + id: img + source: { + if(type == 0){ + "pics/redStone.png"; + } else if(type == 1) { + "pics/blueStone.png"; + } else { + "pics/greenStone.png"; + } + } + opacity: 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + anchors.fill: parent + } + Emitter { + id: particles + system: particleSystem + group: { + if(type == 0){ + "red"; + } else if (type == 1) { + "blue"; + } else { + "green"; + } + } + anchors.fill: parent + + speed: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -60; magnitudeVariation: 60} + shape: EllipseShape{fill:true} + enabled: false; + lifeSpan: 700; lifeSpanVariation: 100 + emitRate: 1000 + maximumEmitted: 100 //only fires 0.1s bursts (still 2x old number) + size: 28 + endSize: 14 + } + + states: [ + State { + name: "AliveState"; when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + + State { + name: "DeathState"; when: dying == true + StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100);} } + PropertyChanges { target: img; opacity: 0 } + StateChangeScript { script: block.destroy(1000); } + } + ] +} diff --git a/examples/demos/samegame/content/Button.qml b/examples/demos/samegame/content/Button.qml new file mode 100644 index 0000000000..b305455c92 --- /dev/null +++ b/examples/demos/samegame/content/Button.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 20 + smooth: true + border { width: 1; color: Qt.darker(activePalette.button) } + radius: 8 + color: activePalette.button + + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } + + Text { + id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText; font.pixelSize: 24 + } +} diff --git a/examples/demos/samegame/content/Dialog.qml b/examples/demos/samegame/content/Dialog.qml new file mode 100644 index 0000000000..80e5984bfe --- /dev/null +++ b/examples/demos/samegame/content/Dialog.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + anchors.centerIn: parent + + property Item text: dialogText + property bool open: false + + signal closed + signal opened + function forceClose() { + if(!open) + return; //already closed + page.open = false; + page.closed(); + page.opacity = 0; + } + + function show(txt) { + page.open = true; + page.opened(); + dialogText.text = txt; + page.opacity = 1; + } + + width: dialogText.width + 20; height: dialogText.height + 20 + color: "white" + border.width: 1 + opacity: 0 + visible: opacity > 0 + Behavior on opacity { + NumberAnimation { duration: 1000 } + } + + Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" } + + MouseArea { anchors.fill: parent; onClicked: forceClose(); } +} + diff --git a/examples/demos/samegame/content/GameArea.qml b/examples/demos/samegame/content/GameArea.qml new file mode 100644 index 0000000000..a43d55117a --- /dev/null +++ b/examples/demos/samegame/content/GameArea.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "samegame.js" as Logic + +Item { + id: gameCanvas + property int score: 0 + property int blockSize: 40 + property ParticleSystem ps: particleSystem + Image { + id: background + anchors.fill: parent + z: -1 + source: "pics/background.png" + fillMode: Image.PreserveAspectCrop + } + + width: 480 + height: 800 + MouseArea { + anchors.fill: parent; onClicked: Logic.handleClick(mouse.x,mouse.y); + } + ParticleSystem{ + id: particleSystem; + onEmptyChanged: if (empty) paused = true; + z:2 + ImageParticle { + groups: ["red"] + color: Qt.darker("red");//Actually want desaturated... + source: "pics/particle.png" + colorVariation: 0.4 + alpha: 0.1 + } + ImageParticle { + groups: ["green"] + color: Qt.darker("green");//Actually want desaturated... + source: "pics/particle.png" + colorVariation: 0.4 + alpha: 0.1 + } + ImageParticle { + groups: ["blue"] + color: Qt.darker("blue");//Actually want desaturated... + source: "pics/particle.png" + colorVariation: 0.4 + alpha: 0.1 + } + anchors.fill: parent + } +} + diff --git a/examples/demos/samegame/content/NameInputDialog.qml b/examples/demos/samegame/content/NameInputDialog.qml new file mode 100644 index 0000000000..602e69789a --- /dev/null +++ b/examples/demos/samegame/content/NameInputDialog.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Dialog { + id: nameInputDialog + + property int initialWidth: 0 + property alias name: nameInputText.text + + anchors.centerIn: parent + z: 22; + + Behavior on width { + NumberAnimation {} + enabled: nameInputDialog.initialWidth != 0 + } + + signal accepted(string name) + onClosed: { + if (nameInputText.text != "") + accepted(name); + } + Text { + id: dialogText + anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter } + text: "You won! Please enter your name: " + } + MouseArea { + anchors.fill: parent + onClicked: { + if (nameInputText.text == "") + nameInputText.openSoftwareInputPanel(); + else + nameInputDialog.forceClose(); + } + } + + TextInput { + id: nameInputText + anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } + focus: visible + autoScroll: false + maximumLength: 24 + onTextChanged: { + var newWidth = nameInputText.width + dialogText.width + 40; + if ( (newWidth > nameInputDialog.width && newWidth < screen.width) + || (nameInputDialog.width > nameInputDialog.initialWidth) ) + nameInputDialog.width = newWidth; + } + onAccepted: { + nameInputDialog.forceClose(); + } + } +} diff --git a/examples/demos/samegame/content/pics/background.png b/examples/demos/samegame/content/pics/background.png new file mode 100644 index 0000000000..3734a27744 Binary files /dev/null and b/examples/demos/samegame/content/pics/background.png differ diff --git a/examples/demos/samegame/content/pics/blueStone.png b/examples/demos/samegame/content/pics/blueStone.png new file mode 100644 index 0000000000..20e43c75b6 Binary files /dev/null and b/examples/demos/samegame/content/pics/blueStone.png differ diff --git a/examples/demos/samegame/content/pics/greenStone.png b/examples/demos/samegame/content/pics/greenStone.png new file mode 100644 index 0000000000..b568a1900c Binary files /dev/null and b/examples/demos/samegame/content/pics/greenStone.png differ diff --git a/examples/demos/samegame/content/pics/particle.png b/examples/demos/samegame/content/pics/particle.png new file mode 100644 index 0000000000..5c83896d22 Binary files /dev/null and b/examples/demos/samegame/content/pics/particle.png differ diff --git a/examples/demos/samegame/content/pics/redStone.png b/examples/demos/samegame/content/pics/redStone.png new file mode 100644 index 0000000000..36b09a2686 Binary files /dev/null and b/examples/demos/samegame/content/pics/redStone.png differ diff --git a/examples/demos/samegame/content/pics/yellowStone.png b/examples/demos/samegame/content/pics/yellowStone.png new file mode 100644 index 0000000000..b1ce76212c Binary files /dev/null and b/examples/demos/samegame/content/pics/yellowStone.png differ diff --git a/examples/demos/samegame/content/samegame.js b/examples/demos/samegame/content/samegame.js new file mode 100755 index 0000000000..611767584b --- /dev/null +++ b/examples/demos/samegame/content/samegame.js @@ -0,0 +1,290 @@ +/* This script file handles the game logic */ +.pragma library +.import QtQuick.LocalStorage 2.0 as Sql + +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn*maxRow; +var board = new Array(maxIndex); +var blockSrc = "BoomBlock.qml"; +var scoresURL = ""; +var gameDuration; +var component = Qt.createComponent(blockSrc); +var highScoreBar = -1; +var gameCanvas; +var nameInputDialog = null; +var dialog = null; + +// Index function used instead of a 2D array +function index(column, row) +{ + return column + row * maxColumn; +} + +function timeStr(msecs) +{ + var secs = Math.floor(msecs/1000); + var m = Math.floor(secs/60); + var ret = "" + m + "m " + (secs%60) + "s"; + return ret; +} + +function startNewGame(gc) +{ + gameCanvas = gc; + // Delete blocks from previous game + for (var i = 0; i < maxIndex; i++) { + if (board[i] != null) + board[i].destroy(); + } + + // Calculate board size + maxColumn = Math.floor(gameCanvas.width/gameCanvas.blockSize); + maxRow = Math.floor(gameCanvas.height/gameCanvas.blockSize); + maxIndex = maxRow * maxColumn; + + // Close dialogs + if(nameInputDialog != null) + nameInputDialog.forceClose(); + if(dialog != null) + dialog.forceClose(); + + // Initialize Board + board = new Array(maxIndex); + gameCanvas.score = 0; + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } + gameDuration = new Date(); +} + +var fillFound; // Set after a floodFill call to the number of blocks found +var floodBoard; // Set to 1 if the floodFill reaches off that node + +// NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope +function handleClick(x,y) +{ + if(gameCanvas == undefined){ + console.log("But the game hasn't started yet!"); + return; + } + var column = Math.floor(x/gameCanvas.blockSize); + var row = Math.floor(y/gameCanvas.blockSize); + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (board[index(column, row)] == null) + return; + // If it's a valid block, remove it and all connected (does nothing if it's not connected) + floodFill(column,row, -1); + if (fillFound <= 0) + return; + gameCanvas.score += (fillFound - 1) * (fillFound - 1); + shuffleDown(); + victoryCheck(); +} + +function floodFill(column,row,type) +{ + if (board[index(column, row)] == null) + return; + var first = false; + if (type == -1) { + first = true; + type = board[index(column,row)].type; + + // Flood fill initialization + fillFound = 0; + floodBoard = new Array(maxIndex); + } + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) + return; + floodBoard[index(column, row)] = 1; + floodFill(column + 1, row, type); + floodFill(column - 1, row, type); + floodFill(column, row + 1, type); + floodFill(column, row - 1, type); + if (first == true && fillFound == 0) + return; // Can't remove single blocks + board[index(column, row)].dying = true; + board[index(column, row)] = null; + fillFound += 1; +} + +function shuffleDown() +{ + // Fall down + for (var column = 0; column < maxColumn; column++) { + var fallDist = 0; + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column,row)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.y = (row + fallDist) * gameCanvas.blockSize; + board[index(column, row + fallDist)] = obj; + board[index(column, row)] = null; + } + } + } + } + // Fall to the left + fallDist = 0; + for (column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + for (row = 0; row < maxRow; row++) { + obj = board[index(column, row)]; + if (obj == null) + continue; + obj.x = (column - fallDist) * gameCanvas.blockSize; + board[index(column - fallDist,row)] = obj; + board[index(column, row)] = null; + } + } + } + } +} + +function victoryCheck() +{ + // Awards bonuses for no blocks left + var deservesBonus = true; + for (var column = maxColumn - 1; column >= 0; column--) + if (board[index(column, maxRow - 1)] != null) + deservesBonus = false; + if (deservesBonus) + gameCanvas.score += 500; + // Checks for game over + if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { + gameDuration = new Date() - gameDuration; + if(nameInputDialog == null){ + nameInputDialog = Qt.createQmlObject('import "."; import "samegame.js" as Logic; NameInputDialog{onAccepted: Logic.saveHighScore(name)}', gameCanvas, "highscoredialog.qml"); + } + if(dialog == null){ + dialog = Qt.createComponent("Dialog.qml").createObject(gameCanvas); + } + initHighScoreBar(); + if(gameCanvas.score > highScoreBar){ + nameInputDialog.show("You won! Please enter your name: "); + nameInputDialog.initialWidth = nameInputDialog.text.width + 20; + if (nameInputDialog.name == "") + nameInputDialog.width = nameInputDialog.initialWidth; + nameInputDialog.text.opacity = 0; // Just a spacer + }else{ + dialog.show("You won!"); + } + } +} + +// Only floods up and right, to see if it can find adjacent same-typed blocks +function floodMoveCheck(column, row, type) +{ + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return false; + if (board[index(column, row)] == null) + return false; + var myType = board[index(column, row)].type; + if (type == myType) + return true; + return floodMoveCheck(column + 1, row, myType) || + floodMoveCheck(column, row - 1, board[index(column, row)].type); +} + +function createBlock(column,row) +{ + // Note that we don't wait for the component to become ready. This will + // only work if the block QML is a local file. Otherwise the component will + // not be ready immediately. There is a statusChanged signal on the + // component you could use if you want to wait to load remote files. + if(component.status == 1){ + var dynamicObject = component.createObject(gameCanvas, + {"type": Math.floor(Math.random() * 3), + "x": column*gameCanvas.blockSize, + "width": gameCanvas.blockSize, + "height": gameCanvas.blockSize, + "particleSystem": gameCanvas.ps}); + if(dynamicObject == null){ + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.y = row*gameCanvas.blockSize; + dynamicObject.spawned = true; + + board[index(column,row)] = dynamicObject; + }else{ + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} + +function initHighScoreBar() +{ + var db = Sql.openDatabaseSync( + "SameGameScores", + "1.0", + "Local SameGame High Scores", + 100 + ); + db.transaction( + function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); + // Only show results for the current grid size + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "' + + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10'); + if(rs.rows.length < 10) + highScoreBar = 0; + else + highScoreBar = rs.rows.item(rs.rows.length - 1).score; + } + ); +} + +function saveHighScore(name) +{ + if (scoresURL != "") + sendHighScore(name); + // Offline storage + var db = Sql.openDatabaseSync( + "SameGameScores", + "1.0", + "Local SameGame High Scores", + 100 + ); + var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; + var data = [ + name, + gameCanvas.score, + maxColumn + "x" + maxRow, + Math.floor(gameDuration / 1000) + ]; + db.transaction( + function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); + tx.executeSql(dataStr, data); + + // Only show results for the current grid size + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "' + + maxColumn + "x" + maxRow + '" ORDER BY score desc LIMIT 10'); + var r = "\nHIGH SCORES for this grid size\n\n" + for (var i = 0; i < rs.rows.length; i++) { + r += (i+1) + ". " + rs.rows.item(i).name + ' got ' + + rs.rows.item(i).score + ' points in ' + + rs.rows.item(i).time + ' seconds.\n'; + } + if(rs.rows.length == 10) + highScoreBar = rs.rows.item(9).score; + dialog.show(r); + } + ); +} diff --git a/examples/demos/samegame/samegame.qml b/examples/demos/samegame/samegame.qml new file mode 100644 index 0000000000..201f826a29 --- /dev/null +++ b/examples/demos/samegame/samegame.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" +import "content/samegame.js" as Logic + +Rectangle { + id: screen + width: 480; height: 640 + + SystemPalette { id: activePalette } + + GameArea { + id: gameCanvas + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + } + + Rectangle { + id: toolBar + width: parent.width; height: 80 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + id: newGameButton + anchors { left: parent.left; leftMargin: 12; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: Logic.startNewGame(gameCanvas) + } + + Button { + text: "Quit" + anchors { left: newGameButton.right; leftMargin: 12; verticalCenter: parent.verticalCenter } + onClicked: Qt.quit(); + } + + Text { + id: score + anchors { right: parent.right; rightMargin: 12; verticalCenter: parent.verticalCenter } + text: "Score: " + gameCanvas.score + font.bold: true + font.pixelSize: 24 + color: activePalette.windowText + } + } +} diff --git a/examples/demos/samegame/samegame.qmlproject b/examples/demos/samegame/samegame.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/demos/samegame/samegame.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/demos/snake/content/Button.qml b/examples/demos/snake/content/Button.qml new file mode 100644 index 0000000000..dfac45049a --- /dev/null +++ b/examples/demos/snake/content/Button.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + signal clicked + property string text: "Button" + + color: activePalette.button; smooth: true + width: txtItem.width + 20; height: txtItem.height + 6 + border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8; + + gradient: Gradient { + GradientStop { + id: topGrad; position: 0.0 + color: if (mr.pressed) { activePalette.dark } else { activePalette.light } } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() } + + Text { + id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText + } +} diff --git a/examples/demos/snake/content/Cookie.qml b/examples/demos/snake/content/Cookie.qml new file mode 100644 index 0000000000..cae53af525 --- /dev/null +++ b/examples/demos/snake/content/Cookie.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: root + property bool dying: false + property int row; + property int column; + x: margin + column * gridSize + y: margin + row * gridSize + + width: gridSize + height: gridSize + property int value : 1; + + Image { + id: img + anchors.fill: parent + source: "pics/cookie.png" + opacity: 0 + Text { + font.bold: true + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + text: value + } + } + + + ParticleSystem { + width:1; height:1; anchors.centerIn: parent; + ImageParticle { + groups: ["star"] + source: "pics/yellowStar.png" + } + Emitter { + id: particles + anchors.fill: parent + group: "star" + emitRate: 50 + enabled: false + lifeSpan: 700 + acceleration: AngleDirection { angleVariation: 360; magnitude: 200 } + } + } + + states: [ + State{ name: "AliveState"; when: dying == false + PropertyChanges { target: img; opacity: 1 } + }, + State{ name: "DeathState"; when: dying == true + StateChangeScript { script: particles.burst(50); } + PropertyChanges { target: img; opacity: 0 } + } + ] + transitions: [ + Transition { + NumberAnimation { target: img; property: "opacity"; duration: 100 } + } + ] +} diff --git a/examples/demos/snake/content/HighScoreModel.qml b/examples/demos/snake/content/HighScoreModel.qml new file mode 100644 index 0000000000..af66b99ede --- /dev/null +++ b/examples/demos/snake/content/HighScoreModel.qml @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.LocalStorage 2.0 as Sql + +// Models a high score table. +// +// Use this component like this: +// +// HighScoreModel { +// id: highScores +// game: "MyCoolGame" +// } +// +// Then use either use the top-score properties: +// +// Text { text: "HI: " + highScores.topScore } +// +// or, use the model in a view: +// +// ListView { +// model: highScore +// delegate: Component { +// ... player ... score ... +// } +// } +// +// Add new scores via: +// +// saveScore(newScore) +// +// or: +// +// savePlayerScore(playerName,newScore) +// +// The best maxScore scores added by this method will be retained in an SQL database, +// and presented in the model and in the topScore/topPlayer properties. +// + +ListModel { + id: model + property string game: "" + property int topScore: 0 + property string topPlayer: "" + property int maxScores: 10 + + function __db() + { + return Sql.openDatabaseSync("HighScoreModel", "1.0", "Generic High Score Functionality for QML", 1000000); + } + function __ensureTables(tx) + { + tx.executeSql('CREATE TABLE IF NOT EXISTS HighScores(game TEXT, score INT, player TEXT)', []); + } + + function fillModel() { + __db().transaction( + function(tx) { + __ensureTables(tx); + var rs = tx.executeSql("SELECT score,player FROM HighScores WHERE game=? ORDER BY score DESC", [game]); + model.clear(); + if (rs.rows.length > 0) { + topScore = rs.rows.item(0).score + topPlayer = rs.rows.item(0).player + for (var i=0; i maxScores) + tx.executeSql("DELETE FROM HighScores WHERE game=? AND score <= ?", + [game, rs.rows.item(maxScores).score]); + } + } + ) + } + + function savePlayerScore(player,score) { + __db().transaction( + function(tx) { + __ensureTables(tx); + tx.executeSql("INSERT INTO HighScores VALUES(?,?,?)", [game,score,player]); + fillModel(); + } + ) + } + + function saveScore(score) { + savePlayerScore("player",score); + } + + function clearScores() { + __db().transaction( + function(tx) { + tx.executeSql("DELETE FROM HighScores WHERE game=?", [game]); + fillModel(); + } + ) + } + + Component.onCompleted: { fillModel() } +} diff --git a/examples/demos/snake/content/Link.qml b/examples/demos/snake/content/Link.qml new file mode 100644 index 0000000000..891adafe5e --- /dev/null +++ b/examples/demos/snake/content/Link.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { id:link + property bool dying: false + property bool spawned: false + property int type: 0 + property int row: 0 + property int column: 0 + property int rotation; + + width: 40; + height: 40 + + x: margin - 3 + gridSize * column + y: margin - 3 + gridSize * row + Behavior on x { NumberAnimation { duration: spawned ? heartbeatInterval : 0} } + Behavior on y { NumberAnimation { duration: spawned ? heartbeatInterval : 0 } } + + + Item { + id: img + anchors.fill: parent + Image { + source: { + if(type == 1) { + "pics/blueStone.png"; + } else if (type == 2) { + "pics/head.png"; + } else { + "pics/redStone.png"; + } + } + + transform: Rotation { + id: actualImageRotation + origin.x: width/2; origin.y: height/2; + angle: rotation * 90 + Behavior on angle { + RotationAnimation{ + direction: RotationAnimation.Shortest + duration: spawned ? 200 : 0 + } + } + } + } + + Image { + source: "pics/stoneShadow.png" + } + + opacity: 0 + } + + ParticleSystem { + width:1; height:1; anchors.centerIn: parent; + ImageParticle { + groups: ["star"] + source: type == 1 ? "pics/blueStar.png" : "pics/redStar.png" + } + Emitter { + id: particles + anchors.fill: parent + group: "star" + emitRate: 50 + enabled: false + lifeSpan: 700 + acceleration: AngleDirection { angleVariation: 360; magnitude: 200 } + } + } + + states: [ + State{ name: "AliveState"; when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + State{ name: "DeathState"; when: dying == true + StateChangeScript { script: particles.burst(50); } + PropertyChanges { target: img; opacity: 0 } + } + ] + + transitions: [ + Transition { + NumberAnimation { target: img; property: "opacity"; duration: 200 } + } + ] + +} diff --git a/examples/demos/snake/content/Skull.qml b/examples/demos/snake/content/Skull.qml new file mode 100644 index 0000000000..9026790a5d --- /dev/null +++ b/examples/demos/snake/content/Skull.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + property bool spawned: false + property int row; + property int column; + property int verticalMovement; + property int horizontalMovement; + + x: screen.margin + column * screen.gridSize + 2 + y: screen.margin + row * screen.gridSize - 3 + Behavior on x { NumberAnimation { duration: spawned ? screen.halfbeatInterval : 0} } + Behavior on y { NumberAnimation { duration: spawned ? screen.halfbeatInterval : 0 } } + + opacity: spawned ? 1 : 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + + source: "pics/skull.png" + width: 24 + height: 40 +} diff --git a/examples/demos/snake/content/pics/README b/examples/demos/snake/content/pics/README new file mode 100644 index 0000000000..0215132caa --- /dev/null +++ b/examples/demos/snake/content/pics/README @@ -0,0 +1 @@ +snake.jpg: This image is based on the picture "Eastern Green Mamba.jpg" from the free media databse Wikimedia Commons and is published under the terms of the GNU Free Documentation License. The original picture was taken by Danleo. diff --git a/examples/demos/snake/content/pics/background.png b/examples/demos/snake/content/pics/background.png new file mode 100644 index 0000000000..72dffaa843 Binary files /dev/null and b/examples/demos/snake/content/pics/background.png differ diff --git a/examples/demos/snake/content/pics/blueStar.png b/examples/demos/snake/content/pics/blueStar.png new file mode 100644 index 0000000000..ba7acabd26 Binary files /dev/null and b/examples/demos/snake/content/pics/blueStar.png differ diff --git a/examples/demos/snake/content/pics/blueStone.png b/examples/demos/snake/content/pics/blueStone.png new file mode 100644 index 0000000000..356affdd95 Binary files /dev/null and b/examples/demos/snake/content/pics/blueStone.png differ diff --git a/examples/demos/snake/content/pics/cookie.png b/examples/demos/snake/content/pics/cookie.png new file mode 100644 index 0000000000..aec2957f34 Binary files /dev/null and b/examples/demos/snake/content/pics/cookie.png differ diff --git a/examples/demos/snake/content/pics/eyes.svg b/examples/demos/snake/content/pics/eyes.svg new file mode 100644 index 0000000000..1078692725 --- /dev/null +++ b/examples/demos/snake/content/pics/eyes.svg @@ -0,0 +1,118 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/examples/demos/snake/content/pics/head.png b/examples/demos/snake/content/pics/head.png new file mode 100644 index 0000000000..550e002687 Binary files /dev/null and b/examples/demos/snake/content/pics/head.png differ diff --git a/examples/demos/snake/content/pics/pause.png b/examples/demos/snake/content/pics/pause.png new file mode 100644 index 0000000000..056d97dd17 Binary files /dev/null and b/examples/demos/snake/content/pics/pause.png differ diff --git a/examples/demos/snake/content/pics/redStar.png b/examples/demos/snake/content/pics/redStar.png new file mode 100644 index 0000000000..cd06854719 Binary files /dev/null and b/examples/demos/snake/content/pics/redStar.png differ diff --git a/examples/demos/snake/content/pics/redStone.png b/examples/demos/snake/content/pics/redStone.png new file mode 100644 index 0000000000..9bb7fe4277 Binary files /dev/null and b/examples/demos/snake/content/pics/redStone.png differ diff --git a/examples/demos/snake/content/pics/skull.png b/examples/demos/snake/content/pics/skull.png new file mode 100644 index 0000000000..63186167bd Binary files /dev/null and b/examples/demos/snake/content/pics/skull.png differ diff --git a/examples/demos/snake/content/pics/snake.jpg b/examples/demos/snake/content/pics/snake.jpg new file mode 100644 index 0000000000..e91a784f71 Binary files /dev/null and b/examples/demos/snake/content/pics/snake.jpg differ diff --git a/examples/demos/snake/content/pics/star.png b/examples/demos/snake/content/pics/star.png new file mode 100644 index 0000000000..defbde53ca Binary files /dev/null and b/examples/demos/snake/content/pics/star.png differ diff --git a/examples/demos/snake/content/pics/stoneShadow.png b/examples/demos/snake/content/pics/stoneShadow.png new file mode 100644 index 0000000000..1bd56afd04 Binary files /dev/null and b/examples/demos/snake/content/pics/stoneShadow.png differ diff --git a/examples/demos/snake/content/pics/yellowStar.png b/examples/demos/snake/content/pics/yellowStar.png new file mode 100644 index 0000000000..52fb9c4b78 Binary files /dev/null and b/examples/demos/snake/content/pics/yellowStar.png differ diff --git a/examples/demos/snake/content/pics/yellowStone.png b/examples/demos/snake/content/pics/yellowStone.png new file mode 100644 index 0000000000..c56124a895 Binary files /dev/null and b/examples/demos/snake/content/pics/yellowStone.png differ diff --git a/examples/demos/snake/content/snake.js b/examples/demos/snake/content/snake.js new file mode 100644 index 0000000000..107c9f4591 --- /dev/null +++ b/examples/demos/snake/content/snake.js @@ -0,0 +1,316 @@ + +var snake = new Array; +var board = new Array; +var links = new Array; +var scheduledDirections = new Array; +var numRows = 1; +var numColumns = 1; +var linkComponent = Qt.createComponent("Link.qml"); +var cookieComponent = Qt.createComponent("Cookie.qml"); +var cookie; +var linksToGrow = 0; +var linksToDie = 0; +var waitForCookie = 0; +var growType = 0; +var skullMovementsBeforeDirectionChange = 0; + + +function rand(n) +{ + return (Math.floor(Math.random() * n)); +} + +function scheduleDirection(dir) +{ + if (state == "starting") { + direction = dir; + headDirection = direction; + head.rotation = headDirection; + } else if (state == "running"){ + direction = dir; + if(scheduledDirections[scheduledDirections.length-1]!=direction) + scheduledDirections.push(direction); + } +} + +function startNewGame() +{ + if (state == "starting") { + return; + } + + if (activeGame) { + endGame(); + startNewGameTimer.running = true; + return; + } + + state = "starting"; + + numRows = numRowsAvailable; + numColumns = numColumnsAvailable; + board = new Array(numRows * numColumns); + snake = new Array; + scheduledDirections = new Array; + growType = 0; + + skull.z = numRows * numColumns + 1; + + for (var i = 0; i < numRows * numColumns; ++i) { + if (i < links.length) { + var link = links[i]; + link.spawned = false; + link.dying = false; + } else { + if(linkComponent.status != Component.Ready) { + if(linkComponent.status == Component.Error) + console.log(linkComponent.errorString()); + else + console.log("Still loading linkComponent"); + continue;//TODO: Better error handling? + } + var link = linkComponent.createObject(playfield); + link.z = numRows * numColumns + 1 - i; + link.type = i == 0 ? 2 : 0; + link.spawned = false; + link.dying = false; + links.push(link); + } + } + + head = links[0]; + snake.push(head); + head.row = numRows/2 -1; + head.column = numColumns/2 -1; + head.spawned = true; + + linksToGrow = 5; + linksToDie = 0; + waitForCookie = 5; + score = 0; + startHeartbeatTimer.running = true; +} + +function endGame() +{ + activeGame = false; + for(var i in snake) + snake[i].dying = true; + if (cookie) { + cookie.dying = true; + cookie = 0; + } + lastScore = score; + highScores.saveScore(lastScore); + state = ""; +} + +function move() { + + if (!head) + return; + + var dir = direction; + + if (scheduledDirections.length) { + dir = scheduledDirections.shift(); + } + + if (state == "starting") { + var turn = (dir - headDirection); + head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); + headDirection = dir; + return; + } + + var row = head.row; + var column = head.column; + + if (dir == 0) { + row = row - 1; + } else if (dir == 1) { + column = column + 1 + } else if (dir == 2) { + row = row + 1; + } else if (dir == 3) { + column = column - 1; + } + + //validate the new position + if (row < 0 || row >= numRows + || column < 0 || column >= numColumns + || (row == skull.row && column == skull.column) + || !isFree(row, column)) { + var turn = (dir - headDirection); + head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); + headDirection = dir; + endGame(); + return; + } + + var newLink; + if (linksToGrow > 0) { + --linksToGrow; + newLink = links[snake.length]; + newLink.spawned = false; + newLink.rotation = snake[snake.length-1].rotation; + newLink.type = growType; + newLink.dying = false; + snake.push(newLink); + } else { + var lastLink = snake[snake.length-1]; + board[lastLink.row * numColumns + lastLink.column] = undefined; + } + + if (waitForCookie > 0) { + if (--waitForCookie == 0) + createCookie(cookie? (cookie.value+1) : 1); + } + + for (var i = snake.length-1; i > 0; --i) { + snake[i].row = snake[i-1].row; + snake[i].column = snake[i-1].column; + snake[i].rotation = snake[i-1].rotation; + } + + if (newLink) { + newLink.spawned = true; + } + + // move the head + head.row = row; + head.column = column; + board[row * numColumns + column] = head; + + var turn = (dir - headDirection); + head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn ); + headDirection = dir; + + var value = testCookie(row, column); + if (value > 0) { + linksToGrow += value; + score += value; + } +} + +function isFree(row, column) +{ + return board[row * numColumns + column] == undefined; +} + +function isHead(row, column) +{ + return head.column == column && head.row == row; +} + +function testCookie(row, column) +{ + if (cookie && !cookie.dying && cookie.row == row && cookie.column == column) { + var value = cookie.value; + waitForCookie = value; + growType = snake[snake.length-1].type == 1 ? 0 : 1; + cookie.dying = true; + cookie.z = numRows * numColumns + 2; + return value; + } + return 0; +} + +function moveSkull() +{ + + if (linksToDie > 0) { + --linksToDie; + var link = snake.pop(); + link.dying = true; + board[link.row * numColumns + link.column] = undefined; + if (score > 0) + --score; + if (snake.length == 0) { + endGame(); + return; + } + } + + var row = skull.row; + var column = skull.column; + if (isHead(row, column)) { + endGame(); + return; + } + row += skull.verticalMovement; + column += skull.horizontalMovement; + + var attempts = 4; + + while (skullMovementsBeforeDirectionChange == 0 || row < 0 || row >= numRows + || column < 0 || column >= numColumns + || (!isFree(row, column) && !isHead(row, column))) { + var d = rand(8); + skull.verticalMovement = 0; + skull.horizontalMovement = 0; + skullMovementsBeforeDirectionChange = rand(20)+1; + if (d == 0) { + skull.verticalMovement = -1 + } else if (d == 1) { + skull.horizontalMovement = -1; + } else if (d == 2) { + skull.verticalMovement = 1 + } else if (d == 3){ + skull.horizontalMovement = 1; + } else if (cookie) { + var rd = cookie.row - skull.row; + var rc = cookie.column - skull.column; + if (Math.abs(rd) > Math.abs(rc)) { + skull.verticalMovement = rd > 0 ? 1 : -1; + skullMovementsBeforeDirectionChange = Math.abs(rd); + } else { + skull.horizontalMovement= rc > 0 ? 1 : -1; + skullMovementsBeforeDirectionChange = Math.abs(rc); + } + } + row = skull.row + skull.verticalMovement; + column = skull.column + skull.horizontalMovement; + if (--attempts == 0) + return; + } + + skull.row = row; + skull.column = column; + --skullMovementsBeforeDirectionChange; + var value = testCookie(row, column); + if (value > 0) + linksToDie += value/2; + + if (isHead(row, column)) + endGame(); +} + +function createCookie(value) { + if (numRows * numColumns - snake.length < 10) + return; + + var column = rand(numColumns); + var row = rand(numRows); + while (!isFree(row, column)) { + column++; + if (column == numColumns) { + column = 0; + row++; + if (row == numRows) + row = 0; + } + } + + if(cookieComponent.status != Component.Ready) { + if(cookieComponent.status == Component.Error) + console.log(cookieComponent.errorString()); + else + console.log("Still loading cookieComponent"); + return;//TODO: Better error handling? + } + cookie = cookieComponent.createObject(head.parent); + cookie.value = value; + cookie.row = row; + cookie.column = column; +} diff --git a/examples/demos/snake/snake.qml b/examples/demos/snake/snake.qml new file mode 100644 index 0000000000..fca3273def --- /dev/null +++ b/examples/demos/snake/snake.qml @@ -0,0 +1,273 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" as Content +import "content/snake.js" as Logic +Item{ +Rectangle { + id: screen; + SystemPalette { id: activePalette } + color: activePalette.window + property bool activeGame: false + + property int gridSize : 34 + property int margin: 4 + property int numRowsAvailable: Math.floor((height-32-2*margin)/gridSize) + property int numColumnsAvailable: Math.floor((width-2*margin)/gridSize) + + property int lastScore : 0 + + property int score: 0; + property int heartbeatInterval: 200 + property int halfbeatInterval: 160 + + width: 480 + height: 750 + + property int direction + property int headDirection + + property variant head; + + Content.HighScoreModel { + id: highScores + game: "Snake" + } + + Timer { + id: heartbeat; + interval: screen.heartbeatInterval; + running: screen.activeGame + repeat: true + onTriggered: { Logic.move() } + } + Timer { + id: halfbeat; + interval: screen.halfbeatInterval; + repeat: true + running: heartbeat.running + onTriggered: { Logic.moveSkull() } + } + Timer { + id: startNewGameTimer; + interval: 700; + onTriggered: { Logic.startNewGame(); } + } + + Timer { + id: startHeartbeatTimer; + interval: 1000 ; + onTriggered: { screen.state = "running"; screen.activeGame = true; } + } + + Image{ + id: pauseDialog + z: 1 + source: "content/pics/pause.png" + anchors.centerIn: parent; + //opacity is deliberately not animated + opacity: 0 //Was !Qt.application.active && activeGame, but application doesn't work (QTBUG-23331) + } + + Image { + + Image { + id: title + source: "content/pics/snake.jpg" + fillMode: Image.PreserveAspectCrop + anchors.fill: parent + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + + Column { + spacing: 140 + anchors.verticalCenter: parent.verticalCenter; + anchors.left: parent.left; + anchors.right: parent.right; + + Text { + color: "white" + font.pointSize: 48 + font.italic: true; + font.bold: true; + text: "Snake" + anchors.horizontalCenter: parent.horizontalCenter; + } + + Text { + color: "white" + font.pointSize: 24 + anchors.horizontalCenter: parent.horizontalCenter; + //horizontalAlignment: Text.AlignHCenter + text: "Last Score:\t" + screen.lastScore + "\nHighscore:\t" + highScores.topScore; + } + } + } + + source: "content/pics/background.png" + fillMode: Image.PreserveAspectCrop + + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: toolbar.top + + Rectangle { + id: playfield + border.width: 1 + border.color: "white" + color: "transparent" + anchors.horizontalCenter: parent.horizontalCenter + y: (screen.height - 32 - height)/2; + width: screen.numColumnsAvailable * screen.gridSize + 2*screen.margin + height: screen.numRowsAvailable * screen.gridSize + 2*screen.margin + + + Content.Skull { + id: skull + } + + MouseArea { + anchors.fill: parent + onPressed: { + if (screen.state == "") { + Logic.startNewGame(); + return; + } + if (direction == 0 || direction == 2) + Logic.scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3); + else + Logic.scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0); + } + } + } + + } + + Rectangle { + id: progressBar + opacity: 0 + Behavior on opacity { NumberAnimation { duration: 200 } } + color: "transparent" + border.width: 2 + border.color: "#221edd" + x: 50 + y: 50 + width: 200 + height: 30 + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: 40 + + Rectangle { + id: progressIndicator + color: "#221edd"; + width: 0; + height: 30; + } + } + + Rectangle { + id: toolbar + color: activePalette.window + height: 32; width: parent.width + anchors.bottom: screen.bottom + + Content.Button { + id: btnA; text: "New Game"; onClicked: Logic.startNewGame(); + anchors.left: parent.left; anchors.leftMargin: 3 + anchors.verticalCenter: parent.verticalCenter + } + + Content.Button { + text: "Quit" + anchors { left: btnA.right; leftMargin: 3; verticalCenter: parent.verticalCenter } + onClicked: Qt.quit(); + } + + Text { + color: activePalette.text + text: "Score: " + screen.score; font.bold: true + anchors.right: parent.right; anchors.rightMargin: 3 + anchors.verticalCenter: parent.verticalCenter + } + } + + focus: true + Keys.onSpacePressed: Logic.startNewGame(); + Keys.onLeftPressed: if (state == "starting" || direction != 1) Logic.scheduleDirection(3); + Keys.onRightPressed: if (state == "starting" || direction != 3) Logic.scheduleDirection(1); + Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0); + Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2); + + states: [ + State { + name: "starting" + PropertyChanges {target: progressIndicator; width: 200} + PropertyChanges {target: title; opacity: 0} + PropertyChanges {target: progressBar; opacity: 1} + }, + State { + name: "running" + PropertyChanges {target: progressIndicator; width: 200} + PropertyChanges {target: title; opacity: 0} + PropertyChanges {target: skull; row: 0; column: 0; } + PropertyChanges {target: skull; spawned: 1} + } + ] + + transitions: [ + Transition { + from: "*" + to: "starting" + NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } + NumberAnimation { property: "opacity"; duration: 200 } + }, + Transition { + to: "starting" + NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } + NumberAnimation { property: "opacity"; duration: 200 } + } + ] + +} +} diff --git a/examples/demos/snake/snake.qmlproject b/examples/demos/snake/snake.qmlproject new file mode 100644 index 0000000000..fb015465d1 --- /dev/null +++ b/examples/demos/snake/snake.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "snake.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/demos/tic-tac-toe/content/Button.qml b/examples/demos/tic-tac-toe/content/Button.qml new file mode 100644 index 0000000000..6dd141f838 --- /dev/null +++ b/examples/demos/tic-tac-toe/content/Button.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text + property bool pressed: false + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 6 + border { width: 1; color: Qt.darker(container.color) } + radius: 8 + color: "lightgray" + smooth: true + + gradient: Gradient { + GradientStop { + position: 0.0 + color: container.pressed ? "darkgray" : "white" + } + GradientStop { + position: 1.0 + color: container.color + } + } + + MouseArea { + anchors.fill: parent + onClicked: container.clicked() + } + + Text { + id: buttonLabel + anchors.centerIn: container + text: container.text + font.pixelSize: 14 + } +} diff --git a/examples/demos/tic-tac-toe/content/TicTac.qml b/examples/demos/tic-tac-toe/content/TicTac.qml new file mode 100644 index 0000000000..e74bc6bcda --- /dev/null +++ b/examples/demos/tic-tac-toe/content/TicTac.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + signal clicked + + states: [ + State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } }, + State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } } + ] + + Image { + id: image + anchors.centerIn: parent + } + + MouseArea { + anchors.fill: parent + onClicked: parent.clicked() + } +} diff --git a/examples/demos/tic-tac-toe/content/pics/board.png b/examples/demos/tic-tac-toe/content/pics/board.png new file mode 100644 index 0000000000..7e5b7ba27c Binary files /dev/null and b/examples/demos/tic-tac-toe/content/pics/board.png differ diff --git a/examples/demos/tic-tac-toe/content/pics/o.png b/examples/demos/tic-tac-toe/content/pics/o.png new file mode 100644 index 0000000000..abc7ee020b Binary files /dev/null and b/examples/demos/tic-tac-toe/content/pics/o.png differ diff --git a/examples/demos/tic-tac-toe/content/pics/x.png b/examples/demos/tic-tac-toe/content/pics/x.png new file mode 100644 index 0000000000..ddc65c83b8 Binary files /dev/null and b/examples/demos/tic-tac-toe/content/pics/x.png differ diff --git a/examples/demos/tic-tac-toe/content/tic-tac-toe.js b/examples/demos/tic-tac-toe/content/tic-tac-toe.js new file mode 100644 index 0000000000..5a166b750f --- /dev/null +++ b/examples/demos/tic-tac-toe/content/tic-tac-toe.js @@ -0,0 +1,149 @@ +function winner(board) +{ + for (var i=0; i<3; ++i) { + if (board.children[i].state != "" + && board.children[i].state == board.children[i+3].state + && board.children[i].state == board.children[i+6].state) + return true + + if (board.children[i*3].state != "" + && board.children[i*3].state == board.children[i*3+1].state + && board.children[i*3].state == board.children[i*3+2].state) + return true + } + + if (board.children[0].state != "" + && board.children[0].state == board.children[4].state != "" + && board.children[0].state == board.children[8].state != "") + return true + + if (board.children[2].state != "" + && board.children[2].state == board.children[4].state != "" + && board.children[2].state == board.children[6].state != "") + return true + + return false +} + +function restartGame() +{ + game.running = true + + for (var i=0; i<9; ++i) + board.children[i].state = "" +} + +function makeMove(pos, player) +{ + board.children[pos].state = player + if (winner(board)) { + gameFinished(player + " wins") + return true + } else { + return false + } +} + +function canPlayAtPos(pos) +{ + return board.children[pos].state == "" +} + +function computerTurn() +{ + var r = Math.random(); + if (r < game.difficulty) + smartAI(); + else + randomAI(); +} + +function smartAI() +{ + function boardCopy(a) { + var ret = new Object; + ret.children = new Array(9); + for (var i = 0; i<9; i++) { + ret.children[i] = new Object; + ret.children[i].state = a.children[i].state; + } + return ret; + } + + for (var i=0; i<9; i++) { + var simpleBoard = boardCopy(board); + if (canPlayAtPos(i)) { + simpleBoard.children[i].state = "O"; + if (winner(simpleBoard)) { + makeMove(i, "O") + return + } + } + } + for (var i=0; i<9; i++) { + var simpleBoard = boardCopy(board); + if (canPlayAtPos(i)) { + simpleBoard.children[i].state = "X"; + if (winner(simpleBoard)) { + makeMove(i, "O") + return + } + } + } + + function thwart(a,b,c) { //If they are at a, try b or c + if (board.children[a].state == "X") { + if (canPlayAtPos(b)) { + makeMove(b, "O") + return true + } else if (canPlayAtPos(c)) { + makeMove(c, "O") + return true + } + } + return false; + } + + if (thwart(4,0,2)) return; + if (thwart(0,4,3)) return; + if (thwart(2,4,1)) return; + if (thwart(6,4,7)) return; + if (thwart(8,4,5)) return; + if (thwart(1,4,2)) return; + if (thwart(3,4,0)) return; + if (thwart(5,4,8)) return; + if (thwart(7,4,6)) return; + + for (var i =0; i<9; i++) { + if (canPlayAtPos(i)) { + makeMove(i, "O") + return + } + } + restartGame(); +} + +function randomAI() +{ + var unfilledPosns = new Array(); + + for (var i=0; i<9; ++i) { + if (canPlayAtPos(i)) + unfilledPosns.push(i); + } + + if (unfilledPosns.length == 0) { + restartGame(); + } else { + var choice = unfilledPosns[Math.floor(Math.random() * unfilledPosns.length)]; + makeMove(choice, "O"); + } +} + +function gameFinished(message) +{ + messageDisplay.text = message + messageDisplay.visible = true + game.running = false +} + diff --git a/examples/demos/tic-tac-toe/tic-tac-toe.qml b/examples/demos/tic-tac-toe/tic-tac-toe.qml new file mode 100644 index 0000000000..8d15233eaa --- /dev/null +++ b/examples/demos/tic-tac-toe/tic-tac-toe.qml @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" +import "content/tic-tac-toe.js" as Logic + +Rectangle { + id: game + + property bool running: true + property real difficulty: 1.0 //chance it will actually think + + width: display.width; height: display.height + 10 + + Image { + id: boardImage + source: "content/pics/board.png" + } + + + Column { + id: display + + Grid { + id: board + width: boardImage.width; height: boardImage.height + columns: 3 + + Repeater { + model: 9 + + TicTac { + width: board.width/3 + height: board.height/3 + + onClicked: { + if (game.running && Logic.canPlayAtPos(index)) { + if (!Logic.makeMove(index, "X")) + Logic.computerTurn(); + } + } + } + } + } + + Row { + spacing: 4 + anchors.horizontalCenter: parent.horizontalCenter + + Button { + text: "Hard" + pressed: game.difficulty == 1.0 + onClicked: { game.difficulty = 1.0 } + } + Button { + text: "Moderate" + pressed: game.difficulty == 0.8 + onClicked: { game.difficulty = 0.8 } + } + Button { + text: "Easy" + pressed: game.difficulty == 0.2 + onClicked: { game.difficulty = 0.2 } + } + } + } + + + Text { + id: messageDisplay + anchors.centerIn: parent + color: "blue" + style: Text.Outline; styleColor: "white" + font.pixelSize: 50; font.bold: true + visible: false + + Timer { + running: messageDisplay.visible + onTriggered: { + messageDisplay.visible = false; + Logic.restartGame(); + } + } + } +} diff --git a/examples/demos/tvtennis/tvtennis.qml b/examples/demos/tvtennis/tvtennis.qml new file mode 100644 index 0000000000..63866e3ce6 --- /dev/null +++ b/examples/demos/tvtennis/tvtennis.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + width: 640; height: 480 + color: "Black" + + // Make a ball to bounce + Rectangle { + id: ball + + // Add a property for the target y coordinate + property variant direction : "right" + + x: 20; width: 20; height: 20; z: 1 + color: "Lime" + + // Move the ball to the right and back to the left repeatedly + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { to: page.width - 40; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "left" } + NumberAnimation { to: 20; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "right" } + } + + // Make y move with a velocity of 200 + Behavior on y { SpringAnimation{ velocity: 200; } + } + + Component.onCompleted: y = page.height-10; // start the ball motion + + // Detect the ball hitting the top or bottom of the view and bounce it + onYChanged: { + if (y <= 0) { + y = page.height - 20; + } else if (y >= page.height - 20) { + y = 0; + } + } + } + + // Place bats to the left and right of the view, following the y + // coordinates of the ball. + Rectangle { + id: leftBat + color: "Lime" + x: 2; width: 20; height: 90 + y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45; + Behavior on y { SpringAnimation{ velocity: 300 } } + } + Rectangle { + id: rightBat + color: "Lime" + x: page.width - 22; width: 20; height: 90 + y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45; + Behavior on y { SpringAnimation{ velocity: 300 } } + } + + // The rest, to make it look realistic, if neither ever scores... + Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } + Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } + Repeater { + model: page.height / 20 + Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } + } +} diff --git a/examples/demos/twitter/TwitterCore/Button.qml b/examples/demos/twitter/TwitterCore/Button.qml new file mode 100644 index 0000000000..064fd4b277 --- /dev/null +++ b/examples/demos/twitter/TwitterCore/Button.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + signal clicked + + property string text + property bool keyUsing: false + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + BorderImage { + id: pressed + opacity: 0 + source: "images/toolbutton.sci" + width: container.width; height: container.height + } + MouseArea { + id: mouseRegion + anchors.fill: buttonImage + onClicked: { container.clicked(); } + } + Text { + id: btnText + color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";} + anchors.centerIn: buttonImage; font.bold: true + text: container.text; style: Text.Raised; styleColor: "black" + font.pixelSize: 12 + } + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed == true + PropertyChanges { target: pressed; opacity: 1 } + }, + State { + name: "Focused" + when: container.activeFocus == true + PropertyChanges { target: btnText; color: "#FFFFFF" } + } + ] + transitions: Transition { + ColorAnimation { target: btnText; } + } +} diff --git a/examples/demos/twitter/TwitterCore/FatDelegate.qml b/examples/demos/twitter/TwitterCore/FatDelegate.qml new file mode 100644 index 0000000000..5fd0d1622b --- /dev/null +++ b/examples/demos/twitter/TwitterCore/FatDelegate.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Component { + id: listDelegate + Item { + id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 60){txt.height+10}else{60} //50+5+5 + function handleLink(link){ + if(link.slice(0,3) == 'app'){ + screen.setUser(link.slice(7)); + }else if(link.slice(0,4) == 'http'){ + Qt.openUrlExternally(link); + } + } + function addTags(str){ + var ret = str.replace(/@[a-zA-Z0-9_]+/g, '$&');//click to jump to user? + var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '$&');//surrounds http links with html link tags + return ret2; + } + + // Strip away paranthesis + function userName(str) { + var user = str.replace(/\([\S|\s]*\)/gi, ""); + return user.trim(); + } + + Item { + id: moveMe; height: parent.height + Rectangle { + id: blackRect + color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1 + } + Item { + id: image; x: 6; width: 48; height: 48; smooth: true + anchors.verticalCenter: parent.verticalCenter + + Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready } + Image { + id: realImage; + source: userImage; x: 1; y: 1; + width:48; height:48; opacity:0 ; + onStatusChanged: { + if(status==Image.Ready) + image.state="loaded" + } + } + states: State { + name: "loaded"; + PropertyChanges { target: realImage ; opacity:1 } + } + transitions: Transition { NumberAnimation { target: realImage; property: "opacity"; duration: 200 } } + + } + Text { id:txt; y:4; x: 56 + text: '' + + ''+userName(name) + " from " +source + + "
          " + statusText + ""; + textFormat: Text.StyledText + color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap; linkColor: "#aaccaa" + anchors.left: image.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6 + onLinkActivated: wrapper.handleLink(link) + } + } + } +} diff --git a/examples/demos/twitter/TwitterCore/Input.qml b/examples/demos/twitter/TwitterCore/Input.qml new file mode 100644 index 0000000000..2987b9e5d8 --- /dev/null +++ b/examples/demos/twitter/TwitterCore/Input.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + id:container + width: 220 + height: 28 + BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } + signal accepted + property alias text: input.text + property alias item:input + TextInput{ + id: input + width: parent.width - 12 + anchors.centerIn: parent + maximumLength:21 + font.pixelSize: 16; + font.bold: true + color: "#151515"; selectionColor: "mediumseagreen" + focus: true + onAccepted:{container.accepted()} + text: "" + selectByMouse: true + } +} diff --git a/examples/demos/twitter/TwitterCore/Loading.qml b/examples/demos/twitter/TwitterCore/Loading.qml new file mode 100644 index 0000000000..8f7c868bee --- /dev/null +++ b/examples/demos/twitter/TwitterCore/Loading.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: loading; source: "images/loading.png" + NumberAnimation on rotation { + from: 0; to: 360; running: loading.visible == true; loops: Animation.Infinite; duration: 900 + } +} diff --git a/examples/demos/twitter/TwitterCore/MultiTitleBar.qml b/examples/demos/twitter/TwitterCore/MultiTitleBar.qml new file mode 100644 index 0000000000..f52ce5be26 --- /dev/null +++ b/examples/demos/twitter/TwitterCore/MultiTitleBar.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + TitleBar { id: titleBar; width: parent.width; height: 60; + y: -80 + untaggedString: "Latest tweets from everyone" + taggedString: "Latest tweets from " + } + states: [ + State { + name: "search"; when: screen.state!="search" + PropertyChanges { target: titleBar; y: 0 } + } + ] + transitions: [ + Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } } + ] +} + diff --git a/examples/demos/twitter/TwitterCore/RssModel.qml b/examples/demos/twitter/TwitterCore/RssModel.qml new file mode 100644 index 0000000000..c4050994e6 --- /dev/null +++ b/examples/demos/twitter/TwitterCore/RssModel.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +Item { id: wrapper + property variant model: xmlModel + property string from : "" + property string to : "" + property string phrase : "" + + property string mode : "everyone" + property int status: xmlModel.status + function reload() { xmlModel.reload(); } + + XmlListModel { + id: xmlModel + + function encodePhrase(x) { return encodeURIComponent(x); } + + source: (from=="" && to=="" && phrase=="") ? "" : + 'http://search.twitter.com/search.atom?from='+from+"&to="+to+"&phrase="+encodePhrase(phrase) + + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " + + "declare namespace twitter=\"http://api.twitter.com/\";"; + + query: "/feed/entry" + + XmlRole { name: "statusText"; query: "content/string()" } + XmlRole { name: "timestamp"; query: "published/string()" } + XmlRole { name: "source"; query: "twitter:source/string()" } + XmlRole { name: "name"; query: "author/name/string()" } + XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" } + + } + Binding { + property: "mode" + target: wrapper + value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}} + } +} diff --git a/examples/demos/twitter/TwitterCore/SearchView.qml b/examples/demos/twitter/TwitterCore/SearchView.qml new file mode 100644 index 0000000000..82a8559889 --- /dev/null +++ b/examples/demos/twitter/TwitterCore/SearchView.qml @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + id: wrapper + Column { + anchors.centerIn: parent + spacing: 20 + Column{ + spacing: 4 + Text { + text: "Posted by:" + font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + horizontalAlignment: Qt.AlignRight + } + Input{ + id: fromIn + KeyNavigation.backtab: searchbutton + KeyNavigation.tab:toIn + onAccepted:searchbutton.doSearch(); + focus: true + } + Text { + text: "In reply to:" + font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + horizontalAlignment: Qt.AlignRight + } + Input{ + id: toIn + KeyNavigation.backtab: fromIn + KeyNavigation.tab:phraseIn + onAccepted:searchbutton.doSearch(); + } + Text { + text: "Search phrase:" + font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" + horizontalAlignment: Qt.AlignRight + } + Input{ + id: phraseIn + KeyNavigation.backtab: toIn + KeyNavigation.tab:searchbutton + onAccepted:searchbutton.doSearch(); + text: "Qt Quick" + } + } + Button { + width: 100 + height: 32 + id: searchbutton + keyUsing: true; + opacity: 1 + text: "Search" + KeyNavigation.tab: fromIn + Keys.onReturnPressed: searchbutton.doSearch(); + Keys.onEnterPressed: searchbutton.doSearch(); + Keys.onSelectPressed: searchbutton.doSearch(); + Keys.onSpacePressed: searchbutton.doSearch(); + onClicked: searchbutton.doSearch(); + + function doSearch() { + // Search ! allowed + if (wrapper.state=="invalidinput") + return; + + rssModel.from=fromIn.text; + rssModel.to= toIn.text; + rssModel.phrase = phraseIn.text; + screen.focus = true; + screen.state = "" + } + } + } + states: + State { + name: "invalidinput" + when: fromIn.text=="" && toIn.text=="" && phraseIn.text=="" + PropertyChanges { target: searchbutton ; opacity: 0.6 ; } + } + transitions: + Transition { + NumberAnimation { target: searchbutton; property: "opacity"; duration: 200 } + } +} diff --git a/examples/demos/twitter/TwitterCore/TitleBar.qml b/examples/demos/twitter/TwitterCore/TitleBar.qml new file mode 100644 index 0000000000..3624048c4d --- /dev/null +++ b/examples/demos/twitter/TwitterCore/TitleBar.qml @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: titleBar + property string untaggedString: "Uploads from everyone" + property string taggedString: "Recent uploads tagged " + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Item { + id: container + width: (parent.width * 2) - 55 ; height: parent.height + + function accept() { + titleBar.state = "" + background.state = "" + rssModel.tags = editor.text + } + + Item { + id:imageBox + x: 6; width: 0; height: 50; smooth: true + anchors.verticalCenter: parent.verticalCenter + + UserModel { user: rssModel.from; id: userModel } + Component { + id: imgDelegate; + Item { + id:imageitem + visible:true + Loading { width:48; height:48; visible: realImage.status != Image.Ready } + Image { id: realImage; source: image; width:48; height:48; opacity:0; } + states: + State { + name: "loaded" + when: (realImage.status == Image.Ready) + PropertyChanges { target: realImage; opacity:1 } + } + transitions: Transition { + NumberAnimation { target: realImage; property: "opacity"; duration: 200 } + } + } + } + ListView { id:view; model: userModel.model; x:1; y:1; delegate: imgDelegate } + states: + State { + when: !userModel.user=="" + PropertyChanges { target: imageBox; width: 50; } + } + transitions: + Transition { + NumberAnimation { target: imageBox; property: "width"; duration: 200 } + } + } + + Image { + id: quitButton + x: 5 + anchors.verticalCenter: parent.verticalCenter + source: "images/quit.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + + Text { + id: categoryText + anchors { + left: quitButton.right; right: parent.right; leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + elide: Text.ElideLeft + text: (rssModel.from=="" ? untaggedString : taggedString + rssModel.from) + font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black" + font.pixelSize: 12 + } + } + + states: State { + name: "Tags" + PropertyChanges { target: container; x: -tagButton.x + 5 } + PropertyChanges { target: editor; focus: true } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } + } +} diff --git a/examples/demos/twitter/TwitterCore/ToolBar.qml b/examples/demos/twitter/TwitterCore/ToolBar.qml new file mode 100644 index 0000000000..06d3324ee3 --- /dev/null +++ b/examples/demos/twitter/TwitterCore/ToolBar.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: toolbar + + property alias button1Label: button1.text + property alias button2Label: button2.text + signal button1Clicked + signal button2Clicked + focus:true + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + Button { + id: button1 + anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32 + onClicked: toolbar.button1Clicked() + focus:true + } + Button { + id: button2 + anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32 + onClicked: toolbar.button2Clicked() + } +} diff --git a/examples/demos/twitter/TwitterCore/UserModel.qml b/examples/demos/twitter/TwitterCore/UserModel.qml new file mode 100644 index 0000000000..f88837c344 --- /dev/null +++ b/examples/demos/twitter/TwitterCore/UserModel.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +//This "model" gets the user information about the searched user. Mainly for the icon. + +Item { id: wrapper + property variant model: xmlModel + property string user : "" + property int status: xmlModel.status + function reload() { xmlModel.reload(); } + XmlListModel { + id: xmlModel + + source: user!= "" ? "http://twitter.com/users/show.xml?screen_name="+user : "" + query: "/user" + + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "screenName"; query: "screen_name/string()" } + XmlRole { name: "image"; query: "profile_image_url/string()" } + XmlRole { name: "location"; query: "location/string()" } + XmlRole { name: "description"; query: "description/string()" } + XmlRole { name: "followers"; query: "followers_count/string()" } + //TODO: Could also get the user's color scheme, timezone and a few other things + } +} diff --git a/examples/demos/twitter/TwitterCore/images/gloss.png b/examples/demos/twitter/TwitterCore/images/gloss.png new file mode 100644 index 0000000000..5d370cd93d Binary files /dev/null and b/examples/demos/twitter/TwitterCore/images/gloss.png differ diff --git a/examples/demos/twitter/TwitterCore/images/lineedit.png b/examples/demos/twitter/TwitterCore/images/lineedit.png new file mode 100644 index 0000000000..2cc38dc35b Binary files /dev/null and b/examples/demos/twitter/TwitterCore/images/lineedit.png differ diff --git a/examples/demos/twitter/TwitterCore/images/lineedit.sci b/examples/demos/twitter/TwitterCore/images/lineedit.sci new file mode 100644 index 0000000000..054bff78be --- /dev/null +++ b/examples/demos/twitter/TwitterCore/images/lineedit.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 10 +border.bottom: 10 +border.right: 10 +source: lineedit.png diff --git a/examples/demos/twitter/TwitterCore/images/loading.png b/examples/demos/twitter/TwitterCore/images/loading.png new file mode 100644 index 0000000000..47a1589c5d Binary files /dev/null and b/examples/demos/twitter/TwitterCore/images/loading.png differ diff --git a/examples/demos/twitter/TwitterCore/images/quit.png b/examples/demos/twitter/TwitterCore/images/quit.png new file mode 100644 index 0000000000..5bda1b6e0d Binary files /dev/null and b/examples/demos/twitter/TwitterCore/images/quit.png differ diff --git a/examples/demos/twitter/TwitterCore/images/stripes.png b/examples/demos/twitter/TwitterCore/images/stripes.png new file mode 100644 index 0000000000..9f36727ea4 Binary files /dev/null and b/examples/demos/twitter/TwitterCore/images/stripes.png differ diff --git a/examples/demos/twitter/TwitterCore/images/titlebar.png b/examples/demos/twitter/TwitterCore/images/titlebar.png new file mode 100644 index 0000000000..51c90082d0 Binary files /dev/null and b/examples/demos/twitter/TwitterCore/images/titlebar.png differ diff --git a/examples/demos/twitter/TwitterCore/images/titlebar.sci b/examples/demos/twitter/TwitterCore/images/titlebar.sci new file mode 100644 index 0000000000..0418d94cd6 --- /dev/null +++ b/examples/demos/twitter/TwitterCore/images/titlebar.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/examples/demos/twitter/TwitterCore/images/toolbutton.png b/examples/demos/twitter/TwitterCore/images/toolbutton.png new file mode 100644 index 0000000000..11310013ee Binary files /dev/null and b/examples/demos/twitter/TwitterCore/images/toolbutton.png differ diff --git a/examples/demos/twitter/TwitterCore/images/toolbutton.sci b/examples/demos/twitter/TwitterCore/images/toolbutton.sci new file mode 100644 index 0000000000..9e4f965307 --- /dev/null +++ b/examples/demos/twitter/TwitterCore/images/toolbutton.sci @@ -0,0 +1,5 @@ +border.left: 15 +border.top: 4 +border.bottom: 4 +border.right: 15 +source: toolbutton.png diff --git a/examples/demos/twitter/TwitterCore/qmldir b/examples/demos/twitter/TwitterCore/qmldir new file mode 100644 index 0000000000..452a648b23 --- /dev/null +++ b/examples/demos/twitter/TwitterCore/qmldir @@ -0,0 +1,10 @@ +SearchView 2.0 SearchView.qml +Button 2.0 Button.qml +Input 2.0 Input.qml +FatDelegate 2.0 FatDelegate.qml +Loading 2.0 Loading.qml +MultiTitleBar 2.0 MultiTitleBar.qml +TitleBar 2.0 TitleBar.qml +RssModel 2.0 RssModel.qml +UserModel 2.0 UserModel.qml +ToolBar 2.0 ToolBar.qml diff --git a/examples/demos/twitter/twitter.qml b/examples/demos/twitter/twitter.qml new file mode 100644 index 0000000000..26e4a7079b --- /dev/null +++ b/examples/demos/twitter/twitter.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 +import "TwitterCore" 2.0 as Twitter + +Item { + id: screen; width: 320; height: 480 + property bool userView : false + property variant tmpStr + function setUser(str){hack.running = true; tmpStr = str} + function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""} + state:"searchquery" + //Workaround for bug 260266 + Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack } + Keys.onEscapePressed: screen.state="searchquery" + Keys.onBacktabPressed: screen.state="searchquery" + Rectangle { + id: background + anchors.fill: parent; color: "#343434"; + + state:"searchquery" + Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } + + MouseArea { + anchors.fill: parent + onClicked: screen.focus = false; + } + + Twitter.RssModel { id: rssModel } + Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'} + Text { + width: 180 + text: "Could not access twitter using this screen name and password pair."; + color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap + visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent + } + + Item { + id: views + x: 2; width: parent.width - 4 + y:60 //Below the title bars + height: parent.height - 100 + + Text { + id:title + text: "Search Twitter" + anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black" + opacity:0 + } + + Twitter.SearchView{ + id: searchView + anchors.verticalCenter: parent.verticalCenter + width: parent.width; height: parent.height-60; + x: -(screen.width * 1.5) + } + + Twitter.FatDelegate { id: fatDelegate } + ListView { + id: mainView; model: rssModel.model; delegate: fatDelegate; + width: parent.width; height: parent.height; x: 0; cacheBuffer: 100; + } + } + + Twitter.MultiTitleBar { id: titleBar; width: parent.width } + Twitter.ToolBar { id: toolBar; height: 40; + //anchors.bottom: parent.bottom; + //TODO: Use anchor changes instead of hard coding + y: screen.height - 40 + width: parent.width; opacity: 0.9 + button1Label: "New Search" + button2Label: "Update" + onButton1Clicked: + { + screen.state="searchquery" + } + onButton2Clicked: rssModel.reload(); + } + } + states: [ + State { + name: "searchquery"; + PropertyChanges { target: searchView; x: 0; focus:true} + PropertyChanges { target: mainView; x: -(parent.width * 1.5) } + PropertyChanges { target: titleBar; y: -80 } + PropertyChanges { target: toolBar; y: screen.height } + PropertyChanges { target: toolBar } + PropertyChanges { target: title; opacity:1} + } + ] + transitions: [ + Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } } + ] +} diff --git a/examples/demos/twitter/twitter.qmlproject b/examples/demos/twitter/twitter.qmlproject new file mode 100644 index 0000000000..b14f71fdfd --- /dev/null +++ b/examples/demos/twitter/twitter.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "twitter.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/embedded/embedded.pro b/examples/embedded/embedded.pro deleted file mode 100644 index 81334fa552..0000000000 --- a/examples/embedded/embedded.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS += qmleasing qmlflickr qmldialcontrol qmlcalculator qmlphotoviewer qmlclocks qmltwitter diff --git a/examples/embedded/qmlcalculator/deployment.pri b/examples/embedded/qmlcalculator/deployment.pri deleted file mode 100644 index a3627b8fa2..0000000000 --- a/examples/embedded/qmlcalculator/deployment.pri +++ /dev/null @@ -1,4 +0,0 @@ -qmlcalculator_src = $$PWD/../../declarative/calculator - -qmlcalculator_files.files = $$qmlcalculator_src/calculator.qml $$qmlcalculator_src/Core -DEPLOYMENT += qmlcalculator_files diff --git a/examples/embedded/qmlcalculator/qmlcalculator.cpp b/examples/embedded/qmlcalculator/qmlcalculator.cpp deleted file mode 100644 index 4be7bc462d..0000000000 --- a/examples/embedded/qmlcalculator/qmlcalculator.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication application(argc, argv); - - const QString mainQmlApp = QLatin1String("calculator.qml"); - QDeclarativeView view; - view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); - QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); - -#if defined(QT_KEYPAD_NAVIGATION) - QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); -#endif // QT_KEYPAD_NAVIGATION - - view.show(); - return application.exec(); -} diff --git a/examples/embedded/qmlcalculator/qmlcalculator.pro b/examples/embedded/qmlcalculator/qmlcalculator.pro deleted file mode 100644 index 25c16ca78a..0000000000 --- a/examples/embedded/qmlcalculator/qmlcalculator.pro +++ /dev/null @@ -1,5 +0,0 @@ -!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") - -QT += declarative -SOURCES += $$PWD/qmlcalculator.cpp -include($$PWD/deployment.pri) diff --git a/examples/embedded/qmlclocks/deployment.pri b/examples/embedded/qmlclocks/deployment.pri deleted file mode 100644 index 771a4dba76..0000000000 --- a/examples/embedded/qmlclocks/deployment.pri +++ /dev/null @@ -1,4 +0,0 @@ -qmlclocks_src = $$PWD/../../../examples/declarative/toys/clocks - -qmlclocks_files.files = $$qmlclocks_src/clocks.qml $$qmlclocks_src/content -DEPLOYMENT += qmlclocks_files diff --git a/examples/embedded/qmlclocks/qmlclocks.cpp b/examples/embedded/qmlclocks/qmlclocks.cpp deleted file mode 100644 index ce42ec7b18..0000000000 --- a/examples/embedded/qmlclocks/qmlclocks.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication application(argc, argv); - - const QString mainQmlApp = QLatin1String("clocks.qml"); - QDeclarativeView view; - view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); - QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); - -#if defined(QT_KEYPAD_NAVIGATION) - QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); -#endif // QT_KEYPAD_NAVIGATION - - view.show(); - return application.exec(); -} diff --git a/examples/embedded/qmlclocks/qmlclocks.pro b/examples/embedded/qmlclocks/qmlclocks.pro deleted file mode 100644 index 8e9dcdf87c..0000000000 --- a/examples/embedded/qmlclocks/qmlclocks.pro +++ /dev/null @@ -1,5 +0,0 @@ -!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") - -QT += declarative -SOURCES += $$PWD/qmlclocks.cpp -include($$PWD/deployment.pri) diff --git a/examples/embedded/qmldialcontrol/deployment.pri b/examples/embedded/qmldialcontrol/deployment.pri deleted file mode 100644 index d845120923..0000000000 --- a/examples/embedded/qmldialcontrol/deployment.pri +++ /dev/null @@ -1,4 +0,0 @@ -qmldialcontrol_src = $$PWD/../../../examples/declarative/ui-components/dialcontrol - -qmldialcontrol_files.files = $$qmldialcontrol_src/dialcontrol.qml $$qmldialcontrol_src/content -DEPLOYMENT += qmldialcontrol_files diff --git a/examples/embedded/qmldialcontrol/qmldialcontrol.cpp b/examples/embedded/qmldialcontrol/qmldialcontrol.cpp deleted file mode 100644 index e66f6f6c56..0000000000 --- a/examples/embedded/qmldialcontrol/qmldialcontrol.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication application(argc, argv); - - const QString mainQmlApp = QLatin1String("dialcontrol.qml"); - QDeclarativeView view; - view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); - QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); - -#if defined(QT_KEYPAD_NAVIGATION) - QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); -#endif // QT_KEYPAD_NAVIGATION - - view.show(); - return application.exec(); -} diff --git a/examples/embedded/qmldialcontrol/qmldialcontrol.pro b/examples/embedded/qmldialcontrol/qmldialcontrol.pro deleted file mode 100644 index 08f876b926..0000000000 --- a/examples/embedded/qmldialcontrol/qmldialcontrol.pro +++ /dev/null @@ -1,5 +0,0 @@ -!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") - -QT += declarative -SOURCES += $$PWD/qmldialcontrol.cpp -include($$PWD/deployment.pri) diff --git a/examples/embedded/qmleasing/deployment.pri b/examples/embedded/qmleasing/deployment.pri deleted file mode 100644 index 7a5d0401cb..0000000000 --- a/examples/embedded/qmleasing/deployment.pri +++ /dev/null @@ -1,4 +0,0 @@ -qmleasing_src = $$PWD/../../../examples/declarative/animation/easing - -qmleasing_files.files = $$qmleasing_src/easing.qml $$qmleasing_src/content -DEPLOYMENT += qmleasing_files diff --git a/examples/embedded/qmleasing/qmleasing.cpp b/examples/embedded/qmleasing/qmleasing.cpp deleted file mode 100644 index 8220e03cff..0000000000 --- a/examples/embedded/qmleasing/qmleasing.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication application(argc, argv); - - const QString mainQmlApp = QLatin1String("easing.qml"); - QDeclarativeView view; - view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); - QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); - -#if defined(QT_KEYPAD_NAVIGATION) - QApplication::setNavigationMode(Qt::NavigationModeCursorAuto); -#endif // QT_KEYPAD_NAVIGATION - - view.show(); - return application.exec(); -} diff --git a/examples/embedded/qmleasing/qmleasing.pro b/examples/embedded/qmleasing/qmleasing.pro deleted file mode 100644 index c9f008d42e..0000000000 --- a/examples/embedded/qmleasing/qmleasing.pro +++ /dev/null @@ -1,5 +0,0 @@ -!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") - -QT += declarative -SOURCES += $$PWD/qmleasing.cpp -include($$PWD/deployment.pri) diff --git a/examples/embedded/qmlflickr/deployment.pri b/examples/embedded/qmlflickr/deployment.pri deleted file mode 100644 index 0d76ddc1db..0000000000 --- a/examples/embedded/qmlflickr/deployment.pri +++ /dev/null @@ -1,4 +0,0 @@ -qmlflickr_src = $$PWD/../../declarative/flickr - -qmlflickr_files.files = $$qmlflickr_src/flickr.qml $$qmlflickr_src/common $$qmlflickr_src/mobile -DEPLOYMENT += qmlflickr_files diff --git a/examples/embedded/qmlflickr/qmlflickr.cpp b/examples/embedded/qmlflickr/qmlflickr.cpp deleted file mode 100644 index 93b28f7cec..0000000000 --- a/examples/embedded/qmlflickr/qmlflickr.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise -// the system default. -class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory -{ -public: - ~NetworkAccessManagerFactory() { } - - QNetworkAccessManager *create(QObject *parent); -}; - -QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) -{ - QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent); - - QNetworkConfigurationManager manager; - if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { - // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); - settings.beginGroup(QLatin1String("QtNetwork")); - const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); - settings.endGroup(); - - // If the saved network configuration is not currently discovered use the system default - QNetworkConfiguration config = manager.configurationFromIdentifier(id); - if ((config.state() & QNetworkConfiguration::Discovered) != - QNetworkConfiguration::Discovered) { - config = manager.defaultConfiguration(); - } - - accessManager->setConfiguration(config); - } - - return accessManager; -} - -int main(int argc, char *argv[]) -{ - QApplication application(argc, argv); - - NetworkAccessManagerFactory networkAccessManagerFactory; - - const QString mainQmlApp = QLatin1String("flickr.qml"); - QDeclarativeView view; - view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); - view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); - QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); - view.setGeometry(QRect(100, 100, 360, 640)); - view.show(); - return application.exec(); -} - diff --git a/examples/embedded/qmlflickr/qmlflickr.pro b/examples/embedded/qmlflickr/qmlflickr.pro deleted file mode 100644 index 869d651b05..0000000000 --- a/examples/embedded/qmlflickr/qmlflickr.pro +++ /dev/null @@ -1,5 +0,0 @@ -!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") - -QT += declarative network -SOURCES += $$PWD/qmlflickr.cpp -include($$PWD/deployment.pri) diff --git a/examples/embedded/qmlphotoviewer/deployment.pri b/examples/embedded/qmlphotoviewer/deployment.pri deleted file mode 100644 index 504373914a..0000000000 --- a/examples/embedded/qmlphotoviewer/deployment.pri +++ /dev/null @@ -1,4 +0,0 @@ -qmlphotoviewer_src = $$PWD/../../declarative/photoviewer - -qmlphotoviewer_files.files = $$qmlphotoviewer_src/photoviewer.qml $$qmlphotoviewer_src/PhotoViewerCore -DEPLOYMENT += qmlphotoviewer_files diff --git a/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp b/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp deleted file mode 100644 index 32c9d24eaa..0000000000 --- a/examples/embedded/qmlphotoviewer/qmlphotoviewer.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise -// the system default. -class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory -{ -public: - ~NetworkAccessManagerFactory() { } - - QNetworkAccessManager *create(QObject *parent); -}; - -QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) -{ - QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent); - - QNetworkConfigurationManager manager; - if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { - // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); - settings.beginGroup(QLatin1String("QtNetwork")); - const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); - settings.endGroup(); - - // If the saved network configuration is not currently discovered use the system default - QNetworkConfiguration config = manager.configurationFromIdentifier(id); - if ((config.state() & QNetworkConfiguration::Discovered) != - QNetworkConfiguration::Discovered) { - config = manager.defaultConfiguration(); - } - - accessManager->setConfiguration(config); - } - - return accessManager; -} - -int main(int argc, char *argv[]) -{ - QApplication application(argc, argv); - - NetworkAccessManagerFactory networkAccessManagerFactory; - - const QString mainQmlApp = QLatin1String("photoviewer.qml"); - QDeclarativeView view; - view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); - view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); - - QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); - view.setGeometry(QRect(100, 100, 360, 640)); - view.show(); - return application.exec(); -} - diff --git a/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro b/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro deleted file mode 100644 index 9941b2e226..0000000000 --- a/examples/embedded/qmlphotoviewer/qmlphotoviewer.pro +++ /dev/null @@ -1,5 +0,0 @@ -!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") - -QT += declarative network -SOURCES += $$PWD/qmlphotoviewer.cpp -include($$PWD/deployment.pri) diff --git a/examples/embedded/qmltwitter/deployment.pri b/examples/embedded/qmltwitter/deployment.pri deleted file mode 100644 index a3c045ca54..0000000000 --- a/examples/embedded/qmltwitter/deployment.pri +++ /dev/null @@ -1,4 +0,0 @@ -qmltwitter_src = $$PWD/../../declarative/twitter - -qmltwitter_files.files = $$qmltwitter_src/twitter.qml $$qmltwitter_src/TwitterCore -DEPLOYMENT += qmltwitter_files diff --git a/examples/embedded/qmltwitter/qmltwitter.cpp b/examples/embedded/qmltwitter/qmltwitter.cpp deleted file mode 100644 index 19b187bc82..0000000000 --- a/examples/embedded/qmltwitter/qmltwitter.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Factory to create QNetworkAccessManagers that use the saved network configuration; otherwise -// the system default. -class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory -{ -public: - ~NetworkAccessManagerFactory() { } - - QNetworkAccessManager *create(QObject *parent); -}; - -QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) -{ - QNetworkAccessManager *accessManager = new QNetworkAccessManager(parent); - - QNetworkConfigurationManager manager; - if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { - // Get saved network configuration - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); - settings.beginGroup(QLatin1String("QtNetwork")); - const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); - settings.endGroup(); - - // If the saved network configuration is not currently discovered use the system default - QNetworkConfiguration config = manager.configurationFromIdentifier(id); - if ((config.state() & QNetworkConfiguration::Discovered) != - QNetworkConfiguration::Discovered) { - config = manager.defaultConfiguration(); - } - - accessManager->setConfiguration(config); - } - - return accessManager; -} - -int main(int argc, char *argv[]) -{ - QApplication application(argc, argv); - - NetworkAccessManagerFactory networkAccessManagerFactory; - - const QString mainQmlApp = QLatin1String("twitter.qml"); - QDeclarativeView view; - view.engine()->setNetworkAccessManagerFactory(&networkAccessManagerFactory); - view.setSource(QUrl(mainQmlApp)); - view.setResizeMode(QDeclarativeView::SizeRootObjectToView); - QObject::connect(view.engine(), SIGNAL(quit()), &application, SLOT(quit())); - view.setGeometry(QRect(100, 100, 360, 640)); - view.show(); - return application.exec(); -} - diff --git a/examples/embedded/qmltwitter/qmltwitter.pro b/examples/embedded/qmltwitter/qmltwitter.pro deleted file mode 100644 index ce40cd7489..0000000000 --- a/examples/embedded/qmltwitter/qmltwitter.pro +++ /dev/null @@ -1,5 +0,0 @@ -!wince*:warning("DEPLOYMENT support required. This project only works on WinCE.") - -QT += declarative network -SOURCES += $$PWD/qmltwitter.cpp -include($$PWD/deployment.pri) diff --git a/examples/examples.pro b/examples/examples.pro index 2c9497dde0..2b78ed7e12 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -SUBDIRS += declarative tutorials +SUBDIRS += demos shared localstorage particles qml qtquick tutorials window contains(QT_CONFIG, qmltest): SUBDIRS += qmltest diff --git a/examples/localstorage/hello.qml b/examples/localstorage/hello.qml new file mode 100644 index 0000000000..3496b86bd9 --- /dev/null +++ b/examples/localstorage/hello.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import QtQuick 2.0 +import QtQuick.LocalStorage 2.0 as LS + +Rectangle { + color: "white" + width: 200 + height: 100 + + Text { + text: "?" + anchors.horizontalCenter: parent.horizontalCenter + function findGreetings() { + var db = LS.openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); + + db.transaction( + function(tx) { + // Create the database if it doesn't already exist + tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); + + // Add (another) greeting row + tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); + + // Show all added greetings + var rs = tx.executeSql('SELECT * FROM Greeting'); + + var r = "" + for(var i = 0; i < rs.rows.length; i++) { + r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" + } + text = r + } + ) + } + + Component.onCompleted: findGreetings() + } +} +//![0] diff --git a/examples/localstorage/localstorage.pro b/examples/localstorage/localstorage.pro new file mode 100644 index 0000000000..967108504e --- /dev/null +++ b/examples/localstorage/localstorage.pro @@ -0,0 +1 @@ +TEMPLATE = subdirs diff --git a/examples/particles/affectors/age.qml b/examples/particles/affectors/age.qml new file mode 100644 index 0000000000..1e7774b63b --- /dev/null +++ b/examples/particles/affectors/age.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 600 + color: "white" + + ParticleSystem { id: particles } + + ImageParticle { + system: particles + sprites: Sprite { + name: "snow" + source: "../images/snowflake.png" + frames: 51 + frameDuration: 40 + frameDurationVariation: 8 + } + } + + Emitter { + system: particles + emitRate: 20 + lifeSpan: 8000 + speed: PointDirection { y:80; yVariation: 40; } + acceleration: PointDirection { y: 4 } + size: 36 + endSize: 12 + sizeVariation: 8 + width: parent.width + height: 100 + } + + MouseArea { + id: ma + anchors.fill: parent + hoverEnabled: true + } + + Rectangle { + color: "#803333AA" + border.color: "black" + x: ma.mouseX - 36 + y: ma.mouseY - 36 + width: 72 + height: 72 + Age { + anchors.fill: parent + system: particles + once: true + lifeLeft: 1200 + advancePosition: false + } + } +} diff --git a/examples/particles/affectors/attractor.qml b/examples/particles/affectors/attractor.qml new file mode 100644 index 0000000000..460a497a92 --- /dev/null +++ b/examples/particles/affectors/attractor.qml @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + property bool spacePressed: false + focus: true + Image { + source: "../images/finalfrontier.png" + anchors.centerIn:parent + } + Keys.onPressed: { + if (event.key == Qt.Key_Space) { + spacePressed = true; + event.accepted = true; + } + } + Keys.onReleased: { + if (event.key == Qt.Key_Space) { + spacePressed = false; + event.accepted = true; + } + } + + Emitter { + group: "stars" + system: particles + emitRate: 40 + lifeSpan: 4000 + enabled: true + size: 30 + sizeVariation: 10 + speed: PointDirection { x: 220; xVariation: 40 } + height: parent.height + } + Emitter { + group: "roids" + system: particles + emitRate: 10 + lifeSpan: 4000 + enabled: true + size: 30 + sizeVariation: 10 + speed: PointDirection { x: 220; xVariation: 40 } + height: parent.height + } + ParticleSystem { + id: particles + anchors.fill: parent + } + ImageParticle { + id: stars + groups: ["stars"] + system: particles + source: "../images/star.png" + color: "white" + colorVariation: 0.1 + alpha: 0 + } + ImageParticle { + id: roids + groups: ["roids"] + system: particles + sprites: Sprite { + id: spinState + name: "spinning" + source: "../images/meteor.png" + frames: 35 + frameDuration: 60 + } + } + ImageParticle { + id: shot + groups: ["shot"] + system: particles + source: "../images/star.png" + + color: "#0FF06600" + colorVariation: 0.3 + } + ImageParticle { + id: engine + groups: ["engine"] + system: particles + source: "../images/particle4.png" + + color: "orange" + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "red" + duration: 1000 + } + } + + colorVariation: 0.2 + } + Attractor { + id: gs; pointX: root.width/2; pointY: root.height/2; strength: 4000000; + system: particles + affectedParameter: Attractor.Acceleration + proportionalToDistance: Attractor.InverseQuadratic + } + Age { + system: particles + x: gs.pointX - 8; + y: gs.pointY - 8; + width: 16 + height: 16 + } + Rectangle { + color: "black" + width: 8 + height: 8 + radius: 4 + x: gs.pointX - 4 + y: gs.pointY - 4 + } + + Image { + source:"../images/rocket2.png" + id: ship + width: 45 + height: 22 + MouseArea { + id: ma + anchors.fill: parent; + drag.axis: Drag.XandYAxis + drag.target: ship + } + } + Emitter { + group: "engine" + system: particles + emitRate: 200 + lifeSpan: 1000 + size: 10 + endSize: 4 + sizeVariation: 4 + speed: PointDirection { x: -128; xVariation: 32 } + height: ship.height + y: ship.y + x: ship.x + width: 20 + } + Emitter { + group: "shot" + system: particles + emitRate: 32 + lifeSpan: 2000 + enabled: spacePressed + size: 40 + speed: PointDirection { x: 256; } + x: ship.x + ship.width + y: ship.y + ship.height/2 + } + + Text { + color: "white" + anchors.bottom: parent.bottom + text:"Drag the ship, Spacebar to fire." + } +} + diff --git a/examples/particles/affectors/customaffector.qml b/examples/particles/affectors/customaffector.qml new file mode 100644 index 0000000000..3f98cd5b43 --- /dev/null +++ b/examples/particles/affectors/customaffector.qml @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + width: 360 + height: 600 + + Image { + source: "../images/backgroundLeaves.jpg" + anchors.fill: parent + } + ParticleSystem { + id: sys + } + Emitter { + system: sys + width: parent.width + emitRate: 4 + lifeSpan: 14000 + size: 80 + speed: PointDirection { y: 60 } + } + Wander { + system: sys + anchors.fill: parent + anchors.bottomMargin: 100 + xVariance: 60 + pace: 60 + } + + Affector { + system: sys + property real coefficient: 0.1 + property real speed: 1.5 + width: parent.width + height: parent.height - 100 + onAffectParticles: { + /* //Linear movement + if (particle.r == 0) { + particle.r = Math.random() > 0.5 ? -1 : 1; + }else if (particle.r == 1) { + particle.rotation += speed * dt; + if(particle.rotation >= maxAngle) + particle.r = -1; + }else if (particle.r == -1) { + particle.rotation -= speed * dt; + if(particle.rotation <= -1 * maxAngle) + particle.r = 1; + } + */ + //Wobbly movement + for (var i=0; i 1.) + currentSize = 0.; + + highp vec2 pos = qt_ParticlePos + - currentSize / 2. + currentSize * qt_ParticleTex // adjust size + + qt_ParticleVec.xy * t * qt_ParticleData.y // apply speed vector.. + + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.); + + gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1); + + highp float fadeIn = min(t * 20., 1.); + highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.)); + + fFade = fadeIn * fadeOut * qt_Opacity; + fPos = vec2(pos.x/1024., pos.y/768.); + } + " + fragmentShader: " + varying highp vec2 fPos; + varying lowp float fFade; + varying highp vec2 qt_TexCoord0; + void main() {//*2 because this generates dark colors mostly + highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0); + highp float dist = length(circlePos); + highp float circleFactor = max(min(1.0 - dist, 1.0), 0.0); + gl_FragColor = vec4(fPos.x*2.0 - fPos.y, fPos.y*2.0 - fPos.x, fPos.x*fPos.y*2.0, 0.0) * circleFactor * fFade; + }" + + } +} diff --git a/examples/particles/customparticle/imagecolors.qml b/examples/particles/customparticle/imagecolors.qml new file mode 100644 index 0000000000..94e5123a0c --- /dev/null +++ b/examples/particles/customparticle/imagecolors.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: root + color: "white" + width: 310 + height: 300 + anchors.centerIn: parent + ParticleSystem { id: sys } + CustomParticle { + system: sys + property real maxWidth: root.width + property real maxHeight: root.height + ShaderEffectSource { + id: pictureSource + sourceItem: picture + hideSource: true + } + Image { + id: picture + source: "../images/starfish_3.png" + } + ShaderEffectSource { + id: particleSource + sourceItem: particle + hideSource: true + } + Image { + id: particle + source: "../images/particle4.png" + } + vertexShader:" + uniform highp float maxWidth; + uniform highp float maxHeight; + varying highp vec2 fTex2; + varying lowp float fFade; + uniform lowp float qt_Opacity; + + void main() { + fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight); + highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y; + fFade = min(t*4., (1.-t*t)*.75) * qt_Opacity; + defaultMain(); + } + " + property variant particleTexture: particleSource + property variant pictureTexture: pictureSource + fragmentShader: " + uniform sampler2D particleTexture; + uniform sampler2D pictureTexture; + varying highp vec2 qt_TexCoord0; + varying highp vec2 fTex2; + varying lowp float fFade; + void main() { + gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, qt_TexCoord0).w * fFade; + }" + } + + Emitter { + id: emitter + system: sys + enabled: false + lifeSpan: 8000 + maximumEmitted: 4000 + anchors.fill: parent + size: 16 + acceleration: PointDirection { xVariation: 12; yVariation: 12 } + } + MouseArea { + anchors.fill: parent + onClicked: emitter.burst(4000); + } + } +} diff --git a/examples/particles/emitters/burstandpulse.qml b/examples/particles/emitters/burstandpulse.qml new file mode 100644 index 0000000000..1b1c2a60c9 --- /dev/null +++ b/examples/particles/emitters/burstandpulse.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 360 + height: 540 + color: "black" + MouseArea { + id: ma + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + if (mouse.button == Qt.LeftButton) + emitter.burst(1000); + else + emitter.pulse(500); + } + } + + ParticleSystem { + id: particles + } + + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/star.png" + alpha: 0 + colorVariation: 0.6 + } + + Emitter { + id: emitter + x: ma.mouseX + y: ma.mouseY + system: particles + emitRate: 2000 + lifeSpan: 2000 + enabled: false + speed: AngleDirection{magnitude: 64; angleVariation: 360} + size: 24 + sizeVariation: 8 + } +} diff --git a/examples/particles/emitters/customemitter.qml b/examples/particles/emitters/customemitter.qml new file mode 100644 index 0000000000..757c836106 --- /dev/null +++ b/examples/particles/emitters/customemitter.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +ParticleSystem { + id: sys + width: 360 + height: 600 + running: true + Rectangle { + z: -1 + anchors.fill: parent + color: "black" + } + + property real petalLength: 180 + property real petalRotation: 0 + NumberAnimation on petalRotation { + from: 0; + to: 360; + loops: -1; + running: true + duration: 24000 + } + + function convert(a) {return a*(Math.PI/180);} + Emitter { + lifeSpan: 4000 + emitRate: 120 + size: 12 + anchors.centerIn: parent + onEmitParticles: { + for (var i=0; i 400 ? 32 : 16 + } +} diff --git a/examples/particles/imageparticle/colored.qml b/examples/particles/imageparticle/colored.qml new file mode 100644 index 0000000000..ac760b6219 --- /dev/null +++ b/examples/particles/imageparticle/colored.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 360 + height: 540 + color: "black" + ParticleSystem { + anchors.fill: parent + ImageParticle { + groups: ["stars"] + anchors.fill: parent + source: "../images/star.png" + } + Emitter { + group: "stars" + emitRate: 800 + lifeSpan: 2400 + size: 24 + sizeVariation: 8 + anchors.fill: parent + } + + ImageParticle { + anchors.fill: parent + source: "../images/star.png" + alpha: 0 + alphaVariation: 0.2 + colorVariation: 1.0 + } + + Emitter { + anchors.centerIn: parent + emitRate: 400 + lifeSpan: 2400 + size: 48 + sizeVariation: 8 + speed: AngleDirection {angleVariation: 180; magnitude: 60} + } + + Turbulence { + anchors.fill: parent + strength: 2 + } + } +} diff --git a/examples/particles/imageparticle/colortable.qml b/examples/particles/imageparticle/colortable.qml new file mode 100644 index 0000000000..623029dae0 --- /dev/null +++ b/examples/particles/imageparticle/colortable.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick.Particles 2.0 +import QtQuick 2.0 + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + + ParticleSystem { id: particles } + + ImageParticle { + system: particles + colorVariation: 0.5 + alpha: 0 + + source: "../images/particle.png" + colorTable: "../images/colortable.png" + sizeTable: "../images/colortable.png" + } + + Emitter { + system: particles + emitRate: 500 + lifeSpan: 2000 + + y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3 + x: root.width / 2 + Math.cos(t) * root.width * 0.3 + property real t; + + NumberAnimation on t { + from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite + } + + speedFromMovement: 20 + + speed: PointDirection { xVariation: 5; yVariation: 5;} + acceleration: PointDirection { xVariation: 5; yVariation: 5;} + + size: 16 + //endSize: 8 + //sizeVariation: 8 + } +} diff --git a/examples/particles/imageparticle/deformation.qml b/examples/particles/imageparticle/deformation.qml new file mode 100644 index 0000000000..e282927e78 --- /dev/null +++ b/examples/particles/imageparticle/deformation.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "goldenrod" + width: 400 + height: 400 + ParticleSystem {id:sys} + + ImageParticle { + system: sys + groups: ["goingLeft", "goingRight"] + source: "../images/starfish_4.png" + rotation: 90 + rotationSpeed: 90 + autoRotation: true + } + ImageParticle { + system: sys + groups: ["goingDown"] + source: "../images/starfish_0.png" + rotation: 180 + yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; } + } + + Timer { + running: true + repeat: false + interval: 100 + onTriggered: emitA.enabled = true; + } + Timer { + running: true + repeat: false + interval: 4200 + onTriggered: emitB.enabled = true; + } + Timer { + running: true + repeat: false + interval: 8400 + onTriggered: emitC.enabled = true; + } + + Emitter { + id: emitA + x: 0 + y: 120 + system: sys + enabled: false + group: "goingRight" + speed: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitB + x: 400 + y: 240 + system: sys + enabled: false + group: "goingLeft" + speed: PointDirection { x: -100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitC + x: 0 + y: 360 + system: sys + enabled: false + group: "goingDown" + speed: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } +} diff --git a/examples/particles/imageparticle/rotation.qml b/examples/particles/imageparticle/rotation.qml new file mode 100644 index 0000000000..3a75c379ed --- /dev/null +++ b/examples/particles/imageparticle/rotation.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "goldenrod" + width: 2000 + height: 2000 + ParticleSystem {id: sys} + ImageParticle { + id: up + system: sys + source: "../images/starfish_2.png" + } + + Emitter { + anchors.centerIn: parent + system: sys + emitRate: 10 + size: 200 + lifeSpan: 10000 + speed: AngleDirection {angleVariation: 360; magnitudeVariation: 100;} + } + + MouseArea { + anchors.fill: parent + onClicked: { + up.autoRotation = !up.autoRotation + up.rotation = up.autoRotation ? -90 : 0 + } + } +} diff --git a/examples/particles/imageparticle/sharing.qml b/examples/particles/imageparticle/sharing.qml new file mode 100644 index 0000000000..27e08322d9 --- /dev/null +++ b/examples/particles/imageparticle/sharing.qml @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example shows how to create your own highlight delegate for a ListView +// that uses a SpringAnimation to provide custom movement when the +// highlight bar is moved between items. + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + property real delegateHeight: 65 + width: 200; height: 300 + gradient: Gradient { + GradientStop { position: 0.0; color: "#EEEEFF" } + GradientStop { position: 1.0; color: "lightblue" } + } + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + Component { + id: petDelegate + Item { + id: wrapper + width: 200; height: delegateHeight + z: 10 + Column { + Text {color: "white"; text: name; font.pixelSize: 18 } + Text {color: "white"; text: 'Type: ' + type; font.pixelSize: 14 } + Text {color: "white"; text: 'Age: ' + age; font.pixelSize: 14 } + } + // indent the item if it is the current item + states: State { + name: "Current" + when: wrapper.ListView.isCurrentItem + PropertyChanges { target: wrapper; x: 20 } + } + transitions: Transition { + NumberAnimation { properties: "x"; duration: 200 } + } + } + } + + // Define a highlight with customised movement between items. + Component { + id: highlightBar + Rectangle { + z: 0 + width: 200; height: delegateHeight + gradient: Gradient { + GradientStop { position: 0.0; color: "#99FF99" } + GradientStop { position: 1.0; color: "#88FF88" } + } + y: listView.currentItem.y; + Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/flower.png" + color: "red" + clip: true + alpha: 1.0 + } + } + } + + ListView { + id: listView + width: 200; height: parent.height + + model: petsModel + delegate: petDelegate + focus: true + + // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem + // to false so the highlight delegate can control how the highlight is moved. + highlight: highlightBar + highlightFollowsCurrentItem: false + + ParticleSystem { id: particles } + Emitter { + system: particles + anchors.fill: parent + emitRate: 1 + lifeSpan: 10000 + size: 24 + sizeVariation: 8 + speed: AngleDirection { angleVariation: 360; magnitude: 3 } + maximumEmitted: 10 + startTime: 5000 + } + + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/flower.png" + alpha: 0.1 + color: "white" + rotationVariation: 180 + z: -1 + } + } + + ListModel { + id: petsModel + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } + } + +} diff --git a/examples/particles/imageparticle/sprites.qml b/examples/particles/imageparticle/sprites.qml new file mode 100644 index 0000000000..0fe4f31ea3 --- /dev/null +++ b/examples/particles/imageparticle/sprites.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + color: "lightsteelblue" + width: 800 + height: 800 + id: root + + SpriteImage { + sprites: Sprite { + name: "bear" + source: "../images/bear_tiles.png" + frames: 13 + frameDuration: 120 + } + width: 250 + height: 250 + x: 20 + anchors.bottom: parent.bottom + anchors.bottomMargin: 20 + z:4 + } + + ParticleSystem { id: sys } + + ImageParticle { + anchors.fill: parent + id: particles + system: sys + sprites: [Sprite { + name: "happy" + source: "../images/starfish_1.png" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "angry" + source: "../images/starfish_0.png" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "silly" + source: "../images/starfish_2.png" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "noticedbear": 0} + }, Sprite { + name: "noticedbear" + source: "../images/starfish_3.png" + frames: 1 + frameDuration: 2600 + }] + } + + Emitter { + system: sys + emitRate: 2 + lifeSpan: 10000 + speed: AngleDirection {angle: 90; magnitude: 60; angleVariation: 5} + acceleration: PointDirection { y: 10 } + size: 160 + sizeVariation: 40 + width: parent.width + height: 100 + } + + SpriteGoal { + system: sys + width: root.width; + height: root.height/2; + y: root.height/2; + goalState:"noticedbear" + } +} diff --git a/examples/particles/images/_explo.png b/examples/particles/images/_explo.png new file mode 100644 index 0000000000..4297245d49 Binary files /dev/null and b/examples/particles/images/_explo.png differ diff --git a/examples/particles/images/backgroundLeaves.jpg b/examples/particles/images/backgroundLeaves.jpg new file mode 100755 index 0000000000..08be16751d Binary files /dev/null and b/examples/particles/images/backgroundLeaves.jpg differ diff --git a/examples/particles/images/bear_tiles.png b/examples/particles/images/bear_tiles.png new file mode 100644 index 0000000000..6bbb2a9b6d Binary files /dev/null and b/examples/particles/images/bear_tiles.png differ diff --git a/examples/particles/images/candle.png b/examples/particles/images/candle.png new file mode 100644 index 0000000000..8fa3193719 Binary files /dev/null and b/examples/particles/images/candle.png differ diff --git a/examples/particles/images/colortable.png b/examples/particles/images/colortable.png new file mode 100644 index 0000000000..a62ceeb4a0 Binary files /dev/null and b/examples/particles/images/colortable.png differ diff --git a/examples/particles/images/finalfrontier.png b/examples/particles/images/finalfrontier.png new file mode 100644 index 0000000000..2ba1815230 Binary files /dev/null and b/examples/particles/images/finalfrontier.png differ diff --git a/examples/particles/images/flower.png b/examples/particles/images/flower.png new file mode 100644 index 0000000000..b5c606210e Binary files /dev/null and b/examples/particles/images/flower.png differ diff --git a/examples/particles/images/launcherIcons/allatonce.png b/examples/particles/images/launcherIcons/allatonce.png new file mode 100644 index 0000000000..b61d2d50d8 Binary files /dev/null and b/examples/particles/images/launcherIcons/allatonce.png differ diff --git a/examples/particles/images/launcherIcons/attractor.png b/examples/particles/images/launcherIcons/attractor.png new file mode 100644 index 0000000000..4bd8040c3b Binary files /dev/null and b/examples/particles/images/launcherIcons/attractor.png differ diff --git a/examples/particles/images/launcherIcons/blurparticles.png b/examples/particles/images/launcherIcons/blurparticles.png new file mode 100644 index 0000000000..4337f979cb Binary files /dev/null and b/examples/particles/images/launcherIcons/blurparticles.png differ diff --git a/examples/particles/images/launcherIcons/close.png b/examples/particles/images/launcherIcons/close.png new file mode 100644 index 0000000000..c37714ee8f Binary files /dev/null and b/examples/particles/images/launcherIcons/close.png differ diff --git a/examples/particles/images/launcherIcons/colortable.png b/examples/particles/images/launcherIcons/colortable.png new file mode 100644 index 0000000000..8841ea30f9 Binary files /dev/null and b/examples/particles/images/launcherIcons/colortable.png differ diff --git a/examples/particles/images/launcherIcons/customaffector.png b/examples/particles/images/launcherIcons/customaffector.png new file mode 100644 index 0000000000..d02e7918fa Binary files /dev/null and b/examples/particles/images/launcherIcons/customaffector.png differ diff --git a/examples/particles/images/launcherIcons/customemitter.png b/examples/particles/images/launcherIcons/customemitter.png new file mode 100644 index 0000000000..6d492573d1 Binary files /dev/null and b/examples/particles/images/launcherIcons/customemitter.png differ diff --git a/examples/particles/images/launcherIcons/deformation.png b/examples/particles/images/launcherIcons/deformation.png new file mode 100644 index 0000000000..d1b722df01 Binary files /dev/null and b/examples/particles/images/launcherIcons/deformation.png differ diff --git a/examples/particles/images/launcherIcons/delegates.png b/examples/particles/images/launcherIcons/delegates.png new file mode 100644 index 0000000000..929414cd0e Binary files /dev/null and b/examples/particles/images/launcherIcons/delegates.png differ diff --git a/examples/particles/images/launcherIcons/dynamicemitters.png b/examples/particles/images/launcherIcons/dynamicemitters.png new file mode 100644 index 0000000000..0cdef9d21e Binary files /dev/null and b/examples/particles/images/launcherIcons/dynamicemitters.png differ diff --git a/examples/particles/images/launcherIcons/emitmask.png b/examples/particles/images/launcherIcons/emitmask.png new file mode 100644 index 0000000000..e943a4adb9 Binary files /dev/null and b/examples/particles/images/launcherIcons/emitmask.png differ diff --git a/examples/particles/images/launcherIcons/flickr.png b/examples/particles/images/launcherIcons/flickr.png new file mode 100644 index 0000000000..4de2650280 Binary files /dev/null and b/examples/particles/images/launcherIcons/flickr.png differ diff --git a/examples/particles/images/launcherIcons/fragmentshader.png b/examples/particles/images/launcherIcons/fragmentshader.png new file mode 100644 index 0000000000..7c6de498d5 Binary files /dev/null and b/examples/particles/images/launcherIcons/fragmentshader.png differ diff --git a/examples/particles/images/launcherIcons/gridsplosion.png b/examples/particles/images/launcherIcons/gridsplosion.png new file mode 100644 index 0000000000..ec75453df6 Binary files /dev/null and b/examples/particles/images/launcherIcons/gridsplosion.png differ diff --git a/examples/particles/images/launcherIcons/groupgoal.png b/examples/particles/images/launcherIcons/groupgoal.png new file mode 100644 index 0000000000..69c6f64e54 Binary files /dev/null and b/examples/particles/images/launcherIcons/groupgoal.png differ diff --git a/examples/particles/images/launcherIcons/imagecolors.png b/examples/particles/images/launcherIcons/imagecolors.png new file mode 100644 index 0000000000..0ff13a346e Binary files /dev/null and b/examples/particles/images/launcherIcons/imagecolors.png differ diff --git a/examples/particles/images/launcherIcons/list.png b/examples/particles/images/launcherIcons/list.png new file mode 100644 index 0000000000..bc13263cff Binary files /dev/null and b/examples/particles/images/launcherIcons/list.png differ diff --git a/examples/particles/images/launcherIcons/maximumemitted.png b/examples/particles/images/launcherIcons/maximumemitted.png new file mode 100644 index 0000000000..4ef0435991 Binary files /dev/null and b/examples/particles/images/launcherIcons/maximumemitted.png differ diff --git a/examples/particles/images/launcherIcons/multiplepainters.png b/examples/particles/images/launcherIcons/multiplepainters.png new file mode 100644 index 0000000000..a28e3c4f02 Binary files /dev/null and b/examples/particles/images/launcherIcons/multiplepainters.png differ diff --git a/examples/particles/images/launcherIcons/package.png b/examples/particles/images/launcherIcons/package.png new file mode 100644 index 0000000000..eba8951c26 Binary files /dev/null and b/examples/particles/images/launcherIcons/package.png differ diff --git a/examples/particles/images/launcherIcons/particleview.png b/examples/particles/images/launcherIcons/particleview.png new file mode 100644 index 0000000000..a74f9a0340 Binary files /dev/null and b/examples/particles/images/launcherIcons/particleview.png differ diff --git a/examples/particles/images/launcherIcons/plasmapatrol.png b/examples/particles/images/launcherIcons/plasmapatrol.png new file mode 100644 index 0000000000..fda852b420 Binary files /dev/null and b/examples/particles/images/launcherIcons/plasmapatrol.png differ diff --git a/examples/particles/images/launcherIcons/remove.png b/examples/particles/images/launcherIcons/remove.png new file mode 100644 index 0000000000..c37714ee8f Binary files /dev/null and b/examples/particles/images/launcherIcons/remove.png differ diff --git a/examples/particles/images/launcherIcons/rotation.png b/examples/particles/images/launcherIcons/rotation.png new file mode 100644 index 0000000000..6a8dbea236 Binary files /dev/null and b/examples/particles/images/launcherIcons/rotation.png differ diff --git a/examples/particles/images/launcherIcons/samegame.png b/examples/particles/images/launcherIcons/samegame.png new file mode 100644 index 0000000000..d00698264b Binary files /dev/null and b/examples/particles/images/launcherIcons/samegame.png differ diff --git a/examples/particles/images/launcherIcons/shapeanddirection.png b/examples/particles/images/launcherIcons/shapeanddirection.png new file mode 100644 index 0000000000..9c1f910d0c Binary files /dev/null and b/examples/particles/images/launcherIcons/shapeanddirection.png differ diff --git a/examples/particles/images/launcherIcons/spaceexplorer.png b/examples/particles/images/launcherIcons/spaceexplorer.png new file mode 100644 index 0000000000..770584a0fa Binary files /dev/null and b/examples/particles/images/launcherIcons/spaceexplorer.png differ diff --git a/examples/particles/images/launcherIcons/spritegoal.png b/examples/particles/images/launcherIcons/spritegoal.png new file mode 100644 index 0000000000..77480c6f09 Binary files /dev/null and b/examples/particles/images/launcherIcons/spritegoal.png differ diff --git a/examples/particles/images/launcherIcons/sprites.png b/examples/particles/images/launcherIcons/sprites.png new file mode 100644 index 0000000000..144216ac7c Binary files /dev/null and b/examples/particles/images/launcherIcons/sprites.png differ diff --git a/examples/particles/images/launcherIcons/spritevariedparticles.png b/examples/particles/images/launcherIcons/spritevariedparticles.png new file mode 100644 index 0000000000..495bb6beee Binary files /dev/null and b/examples/particles/images/launcherIcons/spritevariedparticles.png differ diff --git a/examples/particles/images/launcherIcons/startstop.png b/examples/particles/images/launcherIcons/startstop.png new file mode 100644 index 0000000000..0ff53196a6 Binary files /dev/null and b/examples/particles/images/launcherIcons/startstop.png differ diff --git a/examples/particles/images/launcherIcons/timedgroupchanges.png b/examples/particles/images/launcherIcons/timedgroupchanges.png new file mode 100644 index 0000000000..ec9f826495 Binary files /dev/null and b/examples/particles/images/launcherIcons/timedgroupchanges.png differ diff --git a/examples/particles/images/launcherIcons/trailemitter.png b/examples/particles/images/launcherIcons/trailemitter.png new file mode 100644 index 0000000000..39acf8b40d Binary files /dev/null and b/examples/particles/images/launcherIcons/trailemitter.png differ diff --git a/examples/particles/images/launcherIcons/trails.png b/examples/particles/images/launcherIcons/trails.png new file mode 100644 index 0000000000..0337ebcfd8 Binary files /dev/null and b/examples/particles/images/launcherIcons/trails.png differ diff --git a/examples/particles/images/launcherIcons/turbulence.png b/examples/particles/images/launcherIcons/turbulence.png new file mode 100644 index 0000000000..2b9446ea90 Binary files /dev/null and b/examples/particles/images/launcherIcons/turbulence.png differ diff --git a/examples/particles/images/launcherIcons/velocityfrommotion.png b/examples/particles/images/launcherIcons/velocityfrommotion.png new file mode 100644 index 0000000000..79baa08293 Binary files /dev/null and b/examples/particles/images/launcherIcons/velocityfrommotion.png differ diff --git a/examples/particles/images/launcherIcons/wander.png b/examples/particles/images/launcherIcons/wander.png new file mode 100644 index 0000000000..d98e14b8ae Binary files /dev/null and b/examples/particles/images/launcherIcons/wander.png differ diff --git a/examples/particles/images/matchmask.png b/examples/particles/images/matchmask.png new file mode 100644 index 0000000000..e575875c55 Binary files /dev/null and b/examples/particles/images/matchmask.png differ diff --git a/examples/particles/images/meteor.png b/examples/particles/images/meteor.png new file mode 100644 index 0000000000..e8c368aea7 Binary files /dev/null and b/examples/particles/images/meteor.png differ diff --git a/examples/particles/images/meteor_explo.png b/examples/particles/images/meteor_explo.png new file mode 100644 index 0000000000..e659bfe2cf Binary files /dev/null and b/examples/particles/images/meteor_explo.png differ diff --git a/examples/particles/images/meteors.png b/examples/particles/images/meteors.png new file mode 100644 index 0000000000..bada8a1407 Binary files /dev/null and b/examples/particles/images/meteors.png differ diff --git a/examples/particles/images/nullRock.png b/examples/particles/images/nullRock.png new file mode 100644 index 0000000000..4076327a1a Binary files /dev/null and b/examples/particles/images/nullRock.png differ diff --git a/examples/particles/images/particle.png b/examples/particles/images/particle.png new file mode 100644 index 0000000000..5c83896d22 Binary files /dev/null and b/examples/particles/images/particle.png differ diff --git a/examples/particles/images/particle2.png b/examples/particles/images/particle2.png new file mode 100644 index 0000000000..36349c6c6e Binary files /dev/null and b/examples/particles/images/particle2.png differ diff --git a/examples/particles/images/particle3.png b/examples/particles/images/particle3.png new file mode 100644 index 0000000000..905d8f37b8 Binary files /dev/null and b/examples/particles/images/particle3.png differ diff --git a/examples/particles/images/particle4.png b/examples/particles/images/particle4.png new file mode 100644 index 0000000000..bc95b703c1 Binary files /dev/null and b/examples/particles/images/particle4.png differ diff --git a/examples/particles/images/particleA.png b/examples/particles/images/particleA.png new file mode 100644 index 0000000000..c63acdee1f Binary files /dev/null and b/examples/particles/images/particleA.png differ diff --git a/examples/particles/images/portal_bg.png b/examples/particles/images/portal_bg.png new file mode 100644 index 0000000000..3c59eeabb9 Binary files /dev/null and b/examples/particles/images/portal_bg.png differ diff --git a/examples/particles/images/realLeaf1.png b/examples/particles/images/realLeaf1.png new file mode 100644 index 0000000000..6cabf29efd Binary files /dev/null and b/examples/particles/images/realLeaf1.png differ diff --git a/examples/particles/images/realLeaf2.png b/examples/particles/images/realLeaf2.png new file mode 100644 index 0000000000..bfeca861d5 Binary files /dev/null and b/examples/particles/images/realLeaf2.png differ diff --git a/examples/particles/images/realLeaf3.png b/examples/particles/images/realLeaf3.png new file mode 100644 index 0000000000..b1071e862b Binary files /dev/null and b/examples/particles/images/realLeaf3.png differ diff --git a/examples/particles/images/realLeaf4.png b/examples/particles/images/realLeaf4.png new file mode 100644 index 0000000000..d61d53d10e Binary files /dev/null and b/examples/particles/images/realLeaf4.png differ diff --git a/examples/particles/images/rocket.png b/examples/particles/images/rocket.png new file mode 100644 index 0000000000..a171610b03 Binary files /dev/null and b/examples/particles/images/rocket.png differ diff --git a/examples/particles/images/rocket2.png b/examples/particles/images/rocket2.png new file mode 100644 index 0000000000..7110f8fdc6 Binary files /dev/null and b/examples/particles/images/rocket2.png differ diff --git a/examples/particles/images/sizeInOut.png b/examples/particles/images/sizeInOut.png new file mode 100644 index 0000000000..0a306ea21a Binary files /dev/null and b/examples/particles/images/sizeInOut.png differ diff --git a/examples/particles/images/snowflake.png b/examples/particles/images/snowflake.png new file mode 100644 index 0000000000..490887a82f Binary files /dev/null and b/examples/particles/images/snowflake.png differ diff --git a/examples/particles/images/sparkleSize.png b/examples/particles/images/sparkleSize.png new file mode 100644 index 0000000000..752056541b Binary files /dev/null and b/examples/particles/images/sparkleSize.png differ diff --git a/examples/particles/images/star.png b/examples/particles/images/star.png new file mode 100644 index 0000000000..0d592cfa87 Binary files /dev/null and b/examples/particles/images/star.png differ diff --git a/examples/particles/images/starfish_0.png b/examples/particles/images/starfish_0.png new file mode 100644 index 0000000000..8747f0236e Binary files /dev/null and b/examples/particles/images/starfish_0.png differ diff --git a/examples/particles/images/starfish_1.png b/examples/particles/images/starfish_1.png new file mode 100644 index 0000000000..1f3f159d5e Binary files /dev/null and b/examples/particles/images/starfish_1.png differ diff --git a/examples/particles/images/starfish_2.png b/examples/particles/images/starfish_2.png new file mode 100644 index 0000000000..c6c7e5a676 Binary files /dev/null and b/examples/particles/images/starfish_2.png differ diff --git a/examples/particles/images/starfish_3.png b/examples/particles/images/starfish_3.png new file mode 100644 index 0000000000..307a89f815 Binary files /dev/null and b/examples/particles/images/starfish_3.png differ diff --git a/examples/particles/images/starfish_4.png b/examples/particles/images/starfish_4.png new file mode 100644 index 0000000000..d61c26545a Binary files /dev/null and b/examples/particles/images/starfish_4.png differ diff --git a/examples/particles/images/starfish_mask.png b/examples/particles/images/starfish_mask.png new file mode 100644 index 0000000000..2ef74f902b Binary files /dev/null and b/examples/particles/images/starfish_mask.png differ diff --git a/examples/particles/itemparticle/content/Delegate.qml b/examples/particles/itemparticle/content/Delegate.qml new file mode 100644 index 0000000000..97c7840cb4 --- /dev/null +++ b/examples/particles/itemparticle/content/Delegate.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Package { + Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } + + Rectangle { + id: wrapper + width: 200; height: 25 + color: 'lightsteelblue' + + Text { text: display; anchors.centerIn: parent } + MouseArea { + anchors.fill: parent + onClicked: { + if (wrapper.state == 'inList') + wrapper.state = 'inGrid'; + else + wrapper.state = 'inList'; + } + } + + state: 'inList' + states: [ + State { + name: 'inList' + ParentChange { target: wrapper; parent: listDelegate } + }, + State { + name: 'inGrid' + ParentChange { + target: wrapper; parent: gridDelegate + x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } +} +//![0] diff --git a/examples/particles/itemparticle/content/Delegate2.qml b/examples/particles/itemparticle/content/Delegate2.qml new file mode 100644 index 0000000000..cf60d43dc2 --- /dev/null +++ b/examples/particles/itemparticle/content/Delegate2.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Package { + Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' } + Item { id: particleDelegate; width: w; height: h; Package.name: 'particles' + + Rectangle { + id: wrapper + width: w; height: h; + color: col + rotation: Math.random()*360 + Behavior on rotation {RotationAnimation {}} + + states: State { + name: "gridded" + when: root.inGrid + PropertyChanges { + target: wrapper + rotation: 0 + } + ParentChange { + target: wrapper + parent: gridDelegate + x:0 + y:0 + } + } + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } + } +} +//![0] diff --git a/examples/particles/itemparticle/content/ExpandingDelegate.qml b/examples/particles/itemparticle/content/ExpandingDelegate.qml new file mode 100644 index 0000000000..87f723d3f7 --- /dev/null +++ b/examples/particles/itemparticle/content/ExpandingDelegate.qml @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../../../modelviews/listview/content" + +// This example illustrates expanding a list item to show a more detailed view. + + // Delegate for the recipes. This delegate has two modes: + // 1. List mode (default), which just shows the picture and title of the recipe. + // 2. Details mode, which also shows the ingredients and method. + Component { + id: recipeDelegate + + Item { + id: recipe + + // Create a property to contain the visibility of the details. + // We can bind multiple element's opacity to this one property, + // rather than having a "PropertyChanges" line for each element we + // want to fade. + property real detailsOpacity : 0 + + //this bit changed for aesthetics + width: 70 + height: 70 + // A simple rounded rectangle for the background + Rectangle { + id: background + x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 + color: "ivory" + border.color: "orange" + radius: 5 + } + Image { + anchors.fill:parent + anchors.margins: -32 + source: "bubble.png" + } + + + // This mouse region covers the entire delegate. + // When clicked it changes mode to 'Details'. If we are already + // in Details mode, then no change will happen. + MouseArea { + anchors.fill: parent + onClicked: recipe.state = 'Details'; + } + + // Lay out the page: picture, title and ingredients at the top, and method at the + // bottom. Note that elements that should not be visible in the list + // mode have their opacity set to recipe.detailsOpacity. + Row { + id: topLayout + x: 10; y: 10; height: recipeImage.height; width: parent.width + spacing: 10 + + Image { + id: recipeImage + width: 50; height: 50 + source: "../../modelviews/listview/" + picture + } + + Column { + width: background.width - recipeImage.width - 20; height: recipeImage.height + spacing: 5 + + Text { + text: title + font.bold: true; font.pointSize: 16 + } + + Text { + text: "Ingredients" + font.pointSize: 12; font.bold: true + opacity: recipe.detailsOpacity + } + + Text { + text: ingredients + wrapMode: Text.WordWrap + width: parent.width + opacity: recipe.detailsOpacity + } + } + } + + Item { + id: details + x: 10; width: parent.width - 20 + anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + opacity: recipe.detailsOpacity + + Text { + id: methodTitle + anchors.top: parent.top + text: "Method" + font.pointSize: 12; font.bold: true + } + + Flickable { + id: flick + width: parent.width + anchors { top: methodTitle.bottom; bottom: parent.bottom } + contentHeight: methodText.height + clip: true + + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } + } + + Image { + anchors { right: flick.right; top: flick.top } + source: "../../modelviews/listview/" + "content/pics/moreUp.png" + opacity: flick.atYBeginning ? 0 : 1 + } + + Image { + anchors { right: flick.right; bottom: flick.bottom } + source: "../../modelviews/listview/" + "content/pics/moreDown.png" + opacity: flick.atYEnd ? 0 : 1 + } + } + + // A button to close the detailed view, i.e. set the state back to default (''). + TextButton { + y: 10 + anchors { right: background.right; rightMargin: 10 } + opacity: recipe.detailsOpacity + text: "Close" + + onClicked: recipe.state = ''; + } + + states: State { + name: "Details" + + PropertyChanges { target: background; color: "white" } + PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger + PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible + PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view + + // Move the list so that this item is at the top. + //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } + + // Disallow flicking while we're in detailed view + //PropertyChanges { target: recipe.ListView.view; interactive: false } + } + + transitions: Transition { + //The only strictly necessary particle specific lines + to: "Details" + reversible: true + ScriptAction {script: { + if(state == "Details") + mp.freeze(index); + else + mp.unfreeze(index); + } + } + // Make the state changes smooth + ParallelAnimation { + ColorAnimation { property: "color"; duration: 500 } + NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" } + } + } + } + } diff --git a/examples/particles/itemparticle/content/RssModel.qml b/examples/particles/itemparticle/content/RssModel.qml new file mode 100644 index 0000000000..46027600b3 --- /dev/null +++ b/examples/particles/itemparticle/content/RssModel.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +XmlListModel { + property string tags : "" + + function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } + + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "") + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "content"; query: "content/string()" } + XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } +} diff --git a/examples/particles/itemparticle/content/bubble.png b/examples/particles/itemparticle/content/bubble.png new file mode 100644 index 0000000000..c7f479e9e3 Binary files /dev/null and b/examples/particles/itemparticle/content/bubble.png differ diff --git a/examples/particles/itemparticle/content/script.js b/examples/particles/itemparticle/content/script.js new file mode 100644 index 0000000000..e8ef93a847 --- /dev/null +++ b/examples/particles/itemparticle/content/script.js @@ -0,0 +1,27 @@ +.pragma library + +function getWidth(string) { + return (string.match(/width=\"([0-9]+)\"/))[1] +} + +function getHeight(string) { + return (string.match(/height=\"([0-9]+)\"/))[1] +} + +function getImagePath(string) { + var pattern = /src=\"http:\/\/(\S+)\"/ + return (string.match(pattern))[1] +} + +function calculateScale(width, height, cellSize) { + var widthScale = (cellSize * 1.0) / width + var heightScale = (cellSize * 1.0) / height + var scale = 0 + + if (widthScale <= heightScale) { + scale = widthScale; + } else if (heightScale < widthScale) { + scale = heightScale; + } + return scale; +} diff --git a/examples/particles/itemparticle/delegates.qml b/examples/particles/itemparticle/delegates.qml new file mode 100644 index 0000000000..58734d320a --- /dev/null +++ b/examples/particles/itemparticle/delegates.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root; + width: 360 + height: 600 + color: "black" + + function newPithySaying() { + switch (Math.floor(Math.random()*16)) { + case 0: return "Hello World"; + case 1: return "G'day Mate"; + case 2: return "Code Less"; + case 3: return "Create More"; + case 4: return "Deploy Everywhere"; + case 5: return "Qt Meta-object Language"; + case 6: return "Qt Magic Language"; + case 7: return "Fluid UIs"; + case 8: return "Touchable"; + case 9: return "How's it going?"; + case 10: return "Do you like text?"; + case 11: return "Enjoy!"; + case 12: return "ERROR: Out of pith"; + case 13: return "Punctuation Failure"; + case 14: return "I can go faster"; + case 15: return "I can go slower"; + default: return "OMGWTFBBQ"; + } + } + + ParticleSystem { + anchors.fill: parent + id: syssy + Emitter { + anchors.centerIn: parent + emitRate: 1 + lifeSpan: 4800 + lifeSpanVariation: 1600 + speed: AngleDirection {angleVariation: 360; magnitude: 40; magnitudeVariation: 20} + } + ItemParticle { + delegate: Text { + text: root.newPithySaying(); + color: "white" + font.pixelSize: 18 + font.bold: true + } + } + } +} diff --git a/examples/particles/itemparticle/particleview.qml b/examples/particles/itemparticle/particleview.qml new file mode 100644 index 0000000000..774539a958 --- /dev/null +++ b/examples/particles/itemparticle/particleview.qml @@ -0,0 +1,274 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content/script.js" as Script +import "content" + +Item { + id: root + width: 640 + height: 480 + Rectangle { + anchors.fill: parent + color: "black" + z: -1 + } + Item { + id: loading + Behavior on opacity {NumberAnimation {}} + anchors.fill: parent + Text { + anchors.centerIn: parent + text: "Loading" + color: "white" + } + } + ParticleSystem { + id: sys; + running: true + } + Emitter { + id: emitter + system: sys + height: parent.height - 132/2 + x: -132/2 + y: 132/2 + speed: PointDirection { x: 32; xVariation: 8 } + emitRate: 0.5 + lifeSpan: Emitter.InfiniteLife + group: "photos" + } + Age { + system: sys + x: parent.width + 132/2 + height: parent.height + width: 1000 + } + ImageParticle { + system: sys + groups: ["fireworks"] + source: "../trails/../images/star.png" + color: "lightsteelblue" + alpha: 0 + colorVariation: 0 + z: 1000 + } + ItemParticle { + id: mp + z: 0 + system: sys + fade: false + groups: ["photos"] + } + Component { + id: alertDelegate + Rectangle { + width: 132 + height: 132 + NumberAnimation on scale { + running: true + loops: 1 + from: 0.2 + to: 1 + } + Image { + source: "../asteroid/../images/rocket.png" + anchors.centerIn: parent + } + Text { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: "A new ship has arrived!" + } + } + } + property Item alertItem; + function alert() { + //resetter.active = false + force.active = true; + alertItem = alertDelegate.createObject(root); + alertItem.x = root.width/2 - alertItem.width/2 + alertItem.y = root.height/2 - alertItem.height/2 + spawnFireworks.pulse(200); + stopAlert.start(); + } + focus: true + Keys.onSpacePressed: alert(); + Timer { + id: stopAlert + running: false + repeat: false + interval: 800 + onTriggered: { + force.active = false + //resetter.active = true; + mp.take(alertItem, true); + centerEmitter.burst(1); + } + } + Attractor { + id: force + system: sys + pointX: root.width/2 + pointY: root.height/2 + strength: -10000 + enabled: false + anchors.centerIn: parent + width: parent.width/2 + height: parent.height/2 + groups:["photos"] + affectedParameter: Attractor.Position + } + Emitter { + id: centerEmitter + speed: PointDirection { x: 32; xVariation: 8;} + emitRate: 0.5 + lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first) + maximumEmitted: 20 + group: "photos" + system: sys + anchors.centerIn: parent + enabled: false + + //TODO: Zoom in effect + } + Emitter { + id: spawnFireworks + group: "fireworks" + system: sys + maximumEmitted: 400 + emitRate: 400 + lifeSpan: 2800 + x: parent.width/2 + y: parent.height/2 - 64 + width: 8 + height: 8 + enabled: false + size: 32 + endSize: 8 + speed: AngleDirection { magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 } + acceleration: PointDirection { y: 160 } + } + Item { x: -1000; y: -1000 //offscreen + Repeater {//Load them here, add to system on completed + model: theModel + delegate: theDelegate + } + } + RssModel {id: theModel; tags:"particle,particles"} + Component { + id: theDelegate + Rectangle { + id: container + border.width: 2 + property real myRand: Math.random();//'depth' + z: Math.floor(myRand * 100) + scale: (myRand + 1.0)/2; + //TODO: Darken based on 'depth' + width: 132 + height: 132 + //ItemParticle.onAttached: console.log("I'm in" + x + "," + y + ":" + opacity); + ItemParticle.onDetached: mp.take(container);//respawns + function manage() + { + if (state == "selected") { + console.log("Taking " + index); + mp.freeze(container); + } else { + console.log("Returning " +index); + mp.unfreeze(container); + } + } + Image { + id: img + anchors.centerIn: parent + smooth: true; source: "http://" + Script.getImagePath(content); cache: true + fillMode: Image.PreserveAspectFit; + width: parent.width-4; height: parent.height-4 + onStatusChanged: if (img.status == Image.Ready) { + loading.opacity = 0; + mp.take(container); + } + } + Text { + anchors.bottom: parent.bottom + width: parent.width + horizontalAlignment: Text.AlignHCenter + elide: Text.ElideRight + text: title + color: "black" + } + MouseArea { + anchors.fill: parent + onClicked: container.state == "selected" ? container.state = "" : container.state = "selected" + } + states: State { + name: "selected" + ParentChange { + target: container + parent: root + x: 0 + y: 0 + } + PropertyChanges { + target: container + width: root.width + height: root.height + z: 101 + opacity: 1 + rotation: 0 + } + } + transitions: Transition { + to: "selected" + reversible: true + SequentialAnimation { + ScriptAction {script: container.manage();} + ParallelAnimation { + ParentAnimation {NumberAnimation { properties: "x,y" }}//Doesn't work, particles takes control of x,y instantly + NumberAnimation { properties: "width, height, z, rotation" } + } + } + } + } + } +} diff --git a/examples/particles/particles.pro b/examples/particles/particles.pro new file mode 100644 index 0000000000..967108504e --- /dev/null +++ b/examples/particles/particles.pro @@ -0,0 +1 @@ +TEMPLATE = subdirs diff --git a/examples/particles/simple/dynamiccomparison.qml b/examples/particles/simple/dynamiccomparison.qml new file mode 100644 index 0000000000..a7cdb9b32a --- /dev/null +++ b/examples/particles/simple/dynamiccomparison.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + color: "black" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + + ImageParticle { + system: sys + source: "../images/particle.png" + color: "white" + colorVariation: 1.0 + alpha: 0.1 + entryEffect: ImageParticle.None + } + + Emitter { + id: emitter + system: sys + width: parent.width/2 + speed: PointDirection {y: 72; yVariation: 24} + lifeSpan: 10000 + emitRate: 1000 + enabled: false + size: 32 + } + + Item { + id: fakeEmitter + function burst(number) { + while (number > 0) { + var item = fakeParticle.createObject(root); + item.lifeSpan = Math.random() * 5000 + 5000; + item.x = Math.random() * 320 + 320; + item.y = 0; + number--; + } + } + + Component { + id: fakeParticle + Image { + id: container + property int lifeSpan: 10000 + width: 32 + height: 32 + source: "../images/particle.png" + y: 0 + PropertyAnimation on y {from: -16; to: 480-16; duration: container.lifeSpan; running: true} + SequentialAnimation on opacity { + running: true + NumberAnimation { from:0; to: 1; duration: 500} + PauseAnimation { duration: container.lifeSpan - 1000} + NumberAnimation { from:1; to: 0; duration: 500} + ScriptAction { script: container.destroy(); } + } + } + } + } + + Text { + anchors.left: parent.left + anchors.bottom: parent.bottom + text: "1000 particles" + color: "white" + MouseArea { + anchors.fill: parent + onClicked: emitter.burst(1000); + } + } + Text { + anchors.right: parent.right + anchors.bottom: parent.bottom + text: "1000 items" + color: "white" + MouseArea { + anchors.fill: parent + onClicked: fakeEmitter.burst(1000); + } + } +} diff --git a/examples/particles/simple/dynamicemitters.qml b/examples/particles/simple/dynamicemitters.qml new file mode 100644 index 0000000000..4431ebe82e --- /dev/null +++ b/examples/particles/simple/dynamicemitters.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + color: "black" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + ImageParticle { + system: sys + source: "../images/particle.png" + color: "white" + colorVariation: 1.0 + alpha: 0.1 + } + + Component { + id: emitterComp + Emitter { + id: container + Emitter { + id: emitMore + system: sys + emitRate: 128 + lifeSpan: 600 + size: 16 + endSize: 8 + speed: AngleDirection {angleVariation:360; magnitude: 60} + } + + property int life: 2600 + property real targetX: 0 + property real targetY: 0 + function go() { + xAnim.start(); + yAnim.start(); + container.enabled = true + } + system: sys + emitRate: 32 + lifeSpan: 600 + size: 24 + endSize: 8 + NumberAnimation on x { + id: xAnim; + to: targetX + duration: life + running: false + } + NumberAnimation on y { + id: yAnim; + to: targetY + duration: life + running: false + } + Timer { + interval: life + running: true + onTriggered: container.destroy(); + } + } + } + + MouseArea { + anchors.fill: parent + onClicked: { + for (var i=0; i<8; i++) { + var obj = emitterComp.createObject(root); + obj.x = mouse.x + obj.y = mouse.y + obj.targetX = Math.random() * 240 - 120 + obj.x + obj.targetY = Math.random() * 240 - 120 + obj.y + obj.life = Math.round(Math.random() * 2400) + 200 + obj.emitRate = Math.round(Math.random() * 32) + 32 + obj.go(); + } + } + } +} diff --git a/examples/particles/simple/multiplepainters.qml b/examples/particles/simple/multiplepainters.qml new file mode 100644 index 0000000000..c1b85caa2d --- /dev/null +++ b/examples/particles/simple/multiplepainters.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 600 + color: "darkblue" + property bool cloneMode: false + ParticleSystem { + id: sys + } + MouseArea { + anchors.fill: parent + onClicked: cloneMode = !cloneMode; + } + Emitter { + system: sys + y:root.height + 20 + width: root.width + emitRate: 200 + lifeSpan: 4000 + startTime: 4000 + speed: PointDirection { y: -120; } + } + + ImageParticle { + system: sys + visible: !cloneMode + source: "../images/particle2.png" + } + + ImageParticle { + system: sys + visible: cloneMode + z: 0 + source: "../images/particle3.png" + } + + ImageParticle { + system: sys + clip: true + visible: cloneMode + y: 120 + height: 240 + width: root.width + z: 1 + source: "../images/particle.png" + } +} diff --git a/examples/particles/simple/startstop.qml b/examples/particles/simple/startstop.qml new file mode 100644 index 0000000000..62105b28a0 --- /dev/null +++ b/examples/particles/simple/startstop.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + width: 360 + height: 540 + color: "black" + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + if (mouse.button == Qt.LeftButton) + particles.running = !particles.running + else + particles.paused = !particles.paused; + } + } + + ParticleSystem { + id: particles + running: false + } + + ImageParticle { + anchors.fill: parent + system: particles + source: "../images/star.png" + sizeTable: "../images/sparkleSize.png" + alpha: 0 + colorVariation: 0.6 + } + + Emitter { + anchors.fill: parent + system: particles + emitRate: 2000 + lifeSpan: 2000 + size: 30 + sizeVariation: 10 + } +} diff --git a/examples/qml/cppextensions/cppextensions.pro b/examples/qml/cppextensions/cppextensions.pro new file mode 100644 index 0000000000..cde19b5c90 --- /dev/null +++ b/examples/qml/cppextensions/cppextensions.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + imageprovider \ + plugins \ + networkaccessmanagerfactory \ + referenceexamples + diff --git a/examples/qml/cppextensions/cppextensions.qmlproject b/examples/qml/cppextensions/cppextensions.qmlproject new file mode 100644 index 0000000000..6b362842cb --- /dev/null +++ b/examples/qml/cppextensions/cppextensions.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + importPaths: [ "plugins" ] +} diff --git a/examples/qml/cppextensions/imageprovider/ImageProviderCore/qmldir b/examples/qml/cppextensions/imageprovider/ImageProviderCore/qmldir new file mode 100644 index 0000000000..6be88bccec --- /dev/null +++ b/examples/qml/cppextensions/imageprovider/ImageProviderCore/qmldir @@ -0,0 +1,2 @@ +plugin qmlimageproviderplugin + diff --git a/examples/qml/cppextensions/imageprovider/imageprovider-example.qml b/examples/qml/cppextensions/imageprovider/imageprovider-example.qml new file mode 100644 index 0000000000..fe2f1b130b --- /dev/null +++ b/examples/qml/cppextensions/imageprovider/imageprovider-example.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import "ImageProviderCore" // import the plugin that registers the color image provider + +//![0] +Column { + Image { source: "image://colors/yellow" } + Image { source: "image://colors/red" } +} +//![0] + diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.cpp b/examples/qml/cppextensions/imageprovider/imageprovider.cpp new file mode 100644 index 0000000000..7fe4b72c08 --- /dev/null +++ b/examples/qml/cppextensions/imageprovider/imageprovider.cpp @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include + +#include +#include +#include +#include + +//![0] +class ColorImageProvider : public QDeclarativeImageProvider +{ +public: + ColorImageProvider() + : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap) + { + } + + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) + { + int width = 100; + int height = 50; + + if (size) + *size = QSize(width, height); + QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, + requestedSize.height() > 0 ? requestedSize.height() : height); + pixmap.fill(QColor(id).rgba()); +//![0] + + // write the color name + QPainter painter(&pixmap); + QFont f = painter.font(); + f.setPixelSize(20); + painter.setFont(f); + painter.setPen(Qt::black); + if (requestedSize.isValid()) + painter.scale(requestedSize.width() / width, requestedSize.height() / height); + painter.drawText(QRectF(0, 0, width, height), Qt::AlignCenter, id); + +//![1] + return pixmap; + } +}; +//![1] + + +class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "imageprovider.json") +public: + void registerTypes(const char *uri) + { + Q_UNUSED(uri); + } + + void initializeEngine(QDeclarativeEngine *engine, const char *uri) + { + Q_UNUSED(uri); + engine->addImageProvider("colors", new ColorImageProvider); + } + +}; + + +#define QDeclarativeExtensionInterface_iid "org.qt-project.Qt.QDeclarativeExtensionInterface" + + +#include "imageprovider.moc" diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.pro b/examples/qml/cppextensions/imageprovider/imageprovider.pro new file mode 100644 index 0000000000..dd128d56a8 --- /dev/null +++ b/examples/qml/cppextensions/imageprovider/imageprovider.pro @@ -0,0 +1,22 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += declarative + +DESTDIR = ImageProviderCore +TARGET = qmlimageproviderplugin + +SOURCES += imageprovider.cpp + +OTHER_FILES += imageprovider.json + +sources.files = $$SOURCES imageprovider.qml imageprovider.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider/ImageProviderCore + +ImageProviderCore_sources.files = \ + ImageProviderCore/qmldir +ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/imageprovider/ImageProviderCore + +INSTALLS = sources ImageProviderCore_sources target + diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.qmlproject b/examples/qml/cppextensions/imageprovider/imageprovider.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/cppextensions/imageprovider/imageprovider.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp b/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp new file mode 100644 index 0000000000..2bad2aa285 --- /dev/null +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/main.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include + +#include +#include +#include + + +/* + This example illustrates using a QDeclarativeNetworkAccessManagerFactory to + create a QNetworkAccessManager with a proxy. + + Usage: + networkaccessmanagerfactory [-host -port ] [file] +*/ + +static QString proxyHost; +static int proxyPort = 0; + +class MyNetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory +{ +public: + virtual QNetworkAccessManager *create(QObject *parent); +}; + +QNetworkAccessManager *MyNetworkAccessManagerFactory::create(QObject *parent) +{ + QNetworkAccessManager *nam = new QNetworkAccessManager(parent); + if (!proxyHost.isEmpty()) { + qDebug() << "Created QNetworkAccessManager using proxy" << (proxyHost + ":" + QString::number(proxyPort)); + QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, proxyHost, proxyPort); + nam->setProxy(proxy); + } + + return nam; +} + +int main(int argc, char ** argv) +{ + QUrl source("qrc:view.qml"); + + QGuiApplication app(argc, argv); + + for (int i = 1; i < argc; ++i) { + QString arg(argv[i]); + if (arg == "-host" && i < argc-1) { + proxyHost = argv[++i]; + } else if (arg == "-port" && i < argc-1) { + arg = argv[++i]; + proxyPort = arg.toInt(); + } else if (arg[0] != '-') { + source = QUrl::fromLocalFile(arg); + } else { + qWarning() << "Usage: networkaccessmanagerfactory [-host -port ] [file]"; + exit(1); + } + } + + QQuickView view; + view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); + + view.setSource(source); + view.show(); + + return app.exec(); +} + diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro new file mode 100644 index 0000000000..479af364d0 --- /dev/null +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro @@ -0,0 +1,4 @@ +QT += declarative quick network + +SOURCES += main.cpp +RESOURCES += networkaccessmanagerfactory.qrc diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc new file mode 100644 index 0000000000..17e9301471 --- /dev/null +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/qml/cppextensions/networkaccessmanagerfactory/view.qml b/examples/qml/cppextensions/networkaccessmanagerfactory/view.qml new file mode 100644 index 0000000000..b2d46a991f --- /dev/null +++ b/examples/qml/cppextensions/networkaccessmanagerfactory/view.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + width: 100 + height: 100 + source: "http://qt.nokia.com/logo.png" +} diff --git a/examples/qml/cppextensions/plugins/README b/examples/qml/cppextensions/plugins/README new file mode 100644 index 0000000000..f4f9074059 --- /dev/null +++ b/examples/qml/cppextensions/plugins/README @@ -0,0 +1,9 @@ +This example shows a module "com.nokia.TimeExample" that is implemented +by a C++ plugin (providing the "Time" type), and by QML files (providing the +"Clock" type). + +To run: + + make install + QML_IMPORT_PATH=$PWD qmlscene plugins.qml + diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml new file mode 100644 index 0000000000..eac9226a00 --- /dev/null +++ b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/Clock.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: clock + width: 200; height: 200; color: "gray" + + property alias city: cityLabel.text + property variant hours + property variant minutes + property variant shift : 0 + + Image { id: background; source: "clock.png" } + + Image { + x: 92.5; y: 27 + source: "hour.png" + smooth: true + transform: Rotation { + id: hourRotation + origin.x: 7.5; origin.y: 73; + angle: (clock.hours * 30) + (clock.minutes * 0.5) + Behavior on angle { + SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + x: 93.5; y: 17 + source: "minute.png" + smooth: true + transform: Rotation { + id: minuteRotation + origin.x: 6.5; origin.y: 83; + angle: clock.minutes * 6 + Behavior on angle { + SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + anchors.centerIn: background; source: "center.png" + } + + Text { + id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white" + anchors.horizontalCenter: parent.horizontalCenter + } +} diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/center.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/center.png new file mode 100644 index 0000000000..7fbd802a44 Binary files /dev/null and b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/center.png differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png new file mode 100644 index 0000000000..462edacc0e Binary files /dev/null and b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/clock.png differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png new file mode 100644 index 0000000000..f8061a1235 Binary files /dev/null and b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/hour.png differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png new file mode 100644 index 0000000000..1297ec7c2b Binary files /dev/null and b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/minute.png differ diff --git a/examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir new file mode 100644 index 0000000000..e1288cfac0 --- /dev/null +++ b/examples/qml/cppextensions/plugins/com/nokia/TimeExample/qmldir @@ -0,0 +1,2 @@ +Clock 1.0 Clock.qml +plugin qmlqtimeexampleplugin diff --git a/examples/qml/cppextensions/plugins/plugin.cpp b/examples/qml/cppextensions/plugins/plugin.cpp new file mode 100644 index 0000000000..4ba0a928eb --- /dev/null +++ b/examples/qml/cppextensions/plugins/plugin.cpp @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +// Implements a "TimeModel" class with hour and minute properties +// that change on-the-minute yet efficiently sleep the rest +// of the time. + +class MinuteTimer : public QObject +{ + Q_OBJECT +public: + MinuteTimer(QObject *parent) : QObject(parent) + { + } + + void start() + { + if (!timer.isActive()) { + time = QTime::currentTime(); + timer.start(60000-time.second()*1000, this); + } + } + + void stop() + { + timer.stop(); + } + + int hour() const { return time.hour(); } + int minute() const { return time.minute(); } + +signals: + void timeChanged(); + +protected: + void timerEvent(QTimerEvent *) + { + QTime now = QTime::currentTime(); + if (now.second() == 59 && now.minute() == time.minute() && now.hour() == time.hour()) { + // just missed time tick over, force it, wait extra 0.5 seconds + time.addSecs(60); + timer.start(60500, this); + } else { + time = now; + timer.start(60000-time.second()*1000, this); + } + emit timeChanged(); + } + +private: + QTime time; + QBasicTimer timer; +}; + +//![0] +class TimeModel : public QObject +{ + Q_OBJECT + Q_PROPERTY(int hour READ hour NOTIFY timeChanged) + Q_PROPERTY(int minute READ minute NOTIFY timeChanged) +//![0] + +public: + TimeModel(QObject *parent=0) : QObject(parent) + { + if (++instances == 1) { + if (!timer) + timer = new MinuteTimer(QCoreApplication::instance()); + connect(timer, SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); + timer->start(); + } + } + + ~TimeModel() + { + if (--instances == 0) { + timer->stop(); + } + } + + int minute() const { return timer->minute(); } + int hour() const { return timer->hour(); } + +signals: + void timeChanged(); + +private: + QTime t; + static MinuteTimer *timer; + static int instances; +}; + +int TimeModel::instances=0; +MinuteTimer *TimeModel::timer=0; + +//![plugin] +class QExampleQmlPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "plugin.json") + +public: + void registerTypes(const char *uri) + { + Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); + qmlRegisterType(uri, 1, 0, "Time"); + } +}; +//![plugin] + +#include "plugin.moc" diff --git a/examples/qml/cppextensions/plugins/plugins.pro b/examples/qml/cppextensions/plugins/plugins.pro new file mode 100644 index 0000000000..a28582a07a --- /dev/null +++ b/examples/qml/cppextensions/plugins/plugins.pro @@ -0,0 +1,27 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += declarative + +DESTDIR = com/nokia/TimeExample +TARGET = qmlqtimeexampleplugin + +SOURCES += plugin.cpp + +OTHER_FILES += "plugin.json" + +qdeclarativesources.files += \ + com/nokia/TimeExample/qmldir \ + com/nokia/TimeExample/center.png \ + com/nokia/TimeExample/clock.png \ + com/nokia/TimeExample/Clock.qml \ + com/nokia/TimeExample/hour.png \ + com/nokia/TimeExample/minute.png + +qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/TimeExample + +sources.files += plugins.pro plugin.cpp plugins.qml README +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/TimeExample + +INSTALLS += qdeclarativesources sources target + diff --git a/examples/qml/cppextensions/plugins/plugins.qml b/examples/qml/cppextensions/plugins/plugins.qml new file mode 100644 index 0000000000..f1048ddd36 --- /dev/null +++ b/examples/qml/cppextensions/plugins/plugins.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import com.nokia.TimeExample 1.0 // import types from the plugin + +Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml) + + Time { // this class is defined in C++ (plugin.cpp) + id: time + } + + hours: time.hour + minutes: time.minute + +} +//![0] diff --git a/examples/qml/cppextensions/plugins/plugins.qmlproject b/examples/qml/cppextensions/plugins/plugins.qmlproject new file mode 100644 index 0000000000..771ab45b66 --- /dev/null +++ b/examples/qml/cppextensions/plugins/plugins.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "plugins.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/cppextensions/referenceexamples/adding/adding.pro b/examples/qml/cppextensions/referenceexamples/adding/adding.pro new file mode 100644 index 0000000000..1a972926b7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/adding.pro @@ -0,0 +1,11 @@ +QT += declarative + +SOURCES += main.cpp \ + person.cpp +HEADERS += person.h +RESOURCES += adding.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/adding +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/adding +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/adding/adding.qrc b/examples/qml/cppextensions/referenceexamples/adding/adding.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/adding.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/adding/example.qml b/examples/qml/cppextensions/referenceexamples/adding/example.qml new file mode 100644 index 0000000000..3b2ca34d10 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/example.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ![0] +import People 1.0 + +Person { + name: "Bob Jones" + shoeSize: 12 +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/adding/main.cpp b/examples/qml/cppextensions/referenceexamples/adding/main.cpp new file mode 100644 index 0000000000..4c1918b6de --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); +//![0] + qmlRegisterType("People", 1,0, "Person"); +//![0] + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + Person *person = qobject_cast(component.create()); + if (person) { + qWarning() << "The person's name is" << person->name(); + qWarning() << "They wear a" << person->shoeSize() << "sized shoe"; + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/adding/person.cpp b/examples/qml/cppextensions/referenceexamples/adding/person.cpp new file mode 100644 index 0000000000..0e78b0b77b --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/person.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +// ![0] +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/adding/person.h b/examples/qml/cppextensions/referenceexamples/adding/person.h new file mode 100644 index 0000000000..45fb2f3297 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/adding/person.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +//![0] +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); + +private: + QString m_name; + int m_shoeSize; +}; +//![0] + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/attached/attached.pro b/examples/qml/cppextensions/referenceexamples/attached/attached.pro new file mode 100644 index 0000000000..4cfd4e0aed --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/attached.pro @@ -0,0 +1,13 @@ +QT += declarative + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += attached.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/attached +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/attached +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/attached/attached.qrc b/examples/qml/cppextensions/referenceexamples/attached/attached.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/attached.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp new file mode 100644 index 0000000000..feefef4fe1 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + m_rsvp = d; +} + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h new file mode 100644 index 0000000000..c789c0bd51 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/birthdayparty.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + //! [static attached] + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + //! [static attached] +private: + Person *m_host; + QList m_guests; +}; + +//! [declare attached] +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) +//! [declare attached] +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/attached/example.qml b/examples/qml/cppextensions/referenceexamples/attached/example.qml new file mode 100644 index 0000000000..6a83af2804 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/example.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +//! [begin] +BirthdayParty { +//! [begin] + +//! [rsvp] + Boy { + name: "Robert Campbell" + BirthdayParty.rsvp: "2009-07-01" + } +//! [rsvp] + // ![1] + Boy { + name: "Leo Hodges" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + + BirthdayParty.rsvp: "2009-07-06" + } + // ![1] + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } +//! [end] +} +//! [end] + diff --git a/examples/qml/cppextensions/referenceexamples/attached/main.cpp b/examples/qml/cppextensions/referenceexamples/attached/main.cpp new file mode 100644 index 0000000000..4c2c3003fe --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/main.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + //! [query rsvp] + QDate rsvpDate; + QObject *attached = qmlAttachedPropertiesObject(guest, false); + + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + //! [query rsvp] + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/attached/person.cpp b/examples/qml/cppextensions/referenceexamples/attached/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/attached/person.h b/examples/qml/cppextensions/referenceexamples/attached/person.h new file mode 100644 index 0000000000..032eca3c17 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/attached/person.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(ShoeDescription *shoe READ shoe) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/binding/binding.pro b/examples/qml/cppextensions/referenceexamples/binding/binding.pro new file mode 100644 index 0000000000..2add33fa47 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/binding.pro @@ -0,0 +1,15 @@ +QT += declarative + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp \ + happybirthdaysong.cpp +HEADERS += person.h \ + birthdayparty.h \ + happybirthdaysong.h + +RESOURCES += binding.qrc +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/binding +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/binding +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/binding/binding.qrc b/examples/qml/cppextensions/referenceexamples/binding/binding.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/binding.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp new file mode 100644 index 0000000000..4f5acdfb75 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + if (d != m_rsvp) { + m_rsvp = d; + emit rsvpChanged(); + } +} + + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + if (c == m_host) return; + m_host = c; + emit hostChanged(); +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::startParty() +{ + QTime time = QTime::currentTime(); + emit partyStarted(time); +} + +QString BirthdayParty::announcement() const +{ + return QString(); +} + +void BirthdayParty::setAnnouncement(const QString &speak) +{ + qWarning() << qPrintable(speak); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h new file mode 100644 index 0000000000..376d107f26 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/birthdayparty.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +signals: + void rsvpChanged(); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] + Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged) +// ![0] + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + QString announcement() const; + void setAnnouncement(const QString &); + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + + void startParty(); +signals: + void partyStarted(const QTime &time); + void hostChanged(); + +private: + Person *m_host; + QList m_guests; +}; + +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/binding/example.qml b/examples/qml/cppextensions/referenceexamples/binding/example.qml new file mode 100644 index 0000000000..99a0098ff6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/example.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + id: theParty + + HappyBirthdaySong on announcement { name: theParty.host.name } + + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } +// ![0] + onPartyStarted: console.log("This party started rockin' at " + time); + + + Boy { + name: "Leo Hodges" + BirthdayParty.rsvp: "2009-07-06" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + } + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } + Girl { + name: "Anne Brown" + BirthdayParty.rsvp: "2009-07-01" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + } + +// ![1] +} +// ![1] diff --git a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp new file mode 100644 index 0000000000..df4dbec9c4 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "happybirthdaysong.h" +#include + +HappyBirthdaySong::HappyBirthdaySong(QObject *parent) +: QObject(parent), m_line(-1) +{ + setName(QString()); + QTimer *timer = new QTimer(this); + QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); + timer->start(1000); +} + +void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) +{ + m_target = p; +} + +QString HappyBirthdaySong::name() const +{ + return m_name; +} + +void HappyBirthdaySong::setName(const QString &name) +{ + if (m_name == name) + return; + + m_name = name; + + m_lyrics.clear(); + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday dear " + m_name + ","; + m_lyrics << "Happy birthday to you!"; + m_lyrics << ""; + + emit nameChanged(); +} + +void HappyBirthdaySong::advance() +{ + m_line = (m_line + 1) % m_lyrics.count(); + + m_target.write(m_lyrics.at(m_line)); +} + diff --git a/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h new file mode 100644 index 0000000000..a9f3a94544 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/happybirthdaysong.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H + +#include +#include + +#include + +class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_INTERFACES(QDeclarativePropertyValueSource) +public: + HappyBirthdaySong(QObject *parent = 0); + + virtual void setTarget(const QDeclarativeProperty &); + + QString name() const; + void setName(const QString &); + +private slots: + void advance(); + +signals: + void nameChanged(); +private: + int m_line; + QStringList m_lyrics; + QDeclarativeProperty m_target; + QString m_name; +}; + +#endif // HAPPYBIRTHDAYSONG_H + diff --git a/examples/qml/cppextensions/referenceexamples/binding/main.cpp b/examples/qml/cppextensions/referenceexamples/binding/main.cpp new file mode 100644 index 0000000000..551d24b702 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/main.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "happybirthdaysong.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "HappyBirthdaySong"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + QDate rsvpDate; + QObject *attached = + qmlAttachedPropertiesObject(guest, false); + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + party->startParty(); + } else { + qWarning() << component.errors(); + } + + return app.exec(); +} diff --git a/examples/qml/cppextensions/referenceexamples/binding/person.cpp b/examples/qml/cppextensions/referenceexamples/binding/person.cpp new file mode 100644 index 0000000000..89e7127caf --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/person.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + if (m_size == s) + return; + + m_size = s; + emit shoeChanged(); +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + if (m_color == c) + return; + + m_color = c; + emit shoeChanged(); +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + if (m_brand == b) + return; + + m_brand = b; + emit shoeChanged(); +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + if (m_price == p) + return; + + m_price = p; + emit shoeChanged(); +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + if (m_name == n) + return; + + m_name = n; + emit nameChanged(); +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/binding/person.h b/examples/qml/cppextensions/referenceexamples/binding/person.h new file mode 100644 index 0000000000..d0f196b95c --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/binding/person.h @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize NOTIFY shoeChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY shoeChanged) + Q_PROPERTY(QString brand READ brand WRITE setBrand NOTIFY shoeChanged) + Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +signals: + void shoeChanged(); + +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) +// ![0] + Q_PROPERTY(ShoeDescription *shoe READ shoe CONSTANT) +// ![0] +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +signals: + void nameChanged(); + +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp new file mode 100644 index 0000000000..1859ca9461 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + diff --git a/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h new file mode 100644 index 0000000000..4315d3727e --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/birthdayparty.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) +// ![0] +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro b/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro new file mode 100644 index 0000000000..742b85b683 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/coercion.pro @@ -0,0 +1,13 @@ +QT += declarative + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += coercion.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/coercion +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/coercion +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc b/examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/coercion.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/coercion/example.qml b/examples/qml/cppextensions/referenceexamples/coercion/example.qml new file mode 100644 index 0000000000..25791f38f8 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/example.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoeSize: 12 + } + guests: [ + Boy { name: "Leo Hodges" }, + Boy { name: "Jack Smith" }, + Girl { name: "Anne Brown" } + ] +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/coercion/main.cpp b/examples/qml/cppextensions/referenceexamples/coercion/main.cpp new file mode 100644 index 0000000000..95b309de4c --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/main.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + //![0] + qmlRegisterType(); + //![0] + + //![register boy girl] + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + //![register boy girl] + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) + qWarning() << " " << party->guest(ii)->name(); + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/coercion/person.cpp b/examples/qml/cppextensions/referenceexamples/coercion/person.cpp new file mode 100644 index 0000000000..b28d63216e --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/person.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + +// ![1] +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + +// ![1] diff --git a/examples/qml/cppextensions/referenceexamples/coercion/person.h b/examples/qml/cppextensions/referenceexamples/coercion/person.h new file mode 100644 index 0000000000..dc4ae43dd6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/coercion/person.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); +private: + QString m_name; + int m_shoeSize; +}; + + +// ![0] +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +//! [girl class] +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; +//! [girl class] + +// ![0] + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp new file mode 100644 index 0000000000..1859ca9461 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + diff --git a/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h new file mode 100644 index 0000000000..cfca6689db --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/birthdayparty.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +// ![0] +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; +// ![0] + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/default/default.pro b/examples/qml/cppextensions/referenceexamples/default/default.pro new file mode 100644 index 0000000000..6533cdd7d3 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/default.pro @@ -0,0 +1,13 @@ +QT += declarative + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += default.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/default +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/default +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/default/default.qrc b/examples/qml/cppextensions/referenceexamples/default/default.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/default.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/default/example.qml b/examples/qml/cppextensions/referenceexamples/default/example.qml new file mode 100644 index 0000000000..9ef24b59b7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/example.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoeSize: 12 + } + + Boy { name: "Leo Hodges" } + Boy { name: "Jack Smith" } + Girl { name: "Anne Brown" } +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/default/main.cpp b/examples/qml/cppextensions/referenceexamples/default/main.cpp new file mode 100644 index 0000000000..3a03279129 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/main.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) + qWarning() << " " << party->guest(ii)->name(); + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/default/person.cpp b/examples/qml/cppextensions/referenceexamples/default/person.cpp new file mode 100644 index 0000000000..5a615a1ecd --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/person.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/default/person.h b/examples/qml/cppextensions/referenceexamples/default/person.h new file mode 100644 index 0000000000..d85672798c --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/default/person.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); +private: + QString m_name; + int m_shoeSize; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/extended/example.qml b/examples/qml/cppextensions/referenceexamples/extended/example.qml new file mode 100644 index 0000000000..642a95d443 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/example.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +QLineEdit { + leftMargin: 20 +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/extended/extended.pro b/examples/qml/cppextensions/referenceexamples/extended/extended.pro new file mode 100644 index 0000000000..3d9f59c470 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/extended.pro @@ -0,0 +1,11 @@ +QT += declarative widgets + +SOURCES += main.cpp \ + lineedit.cpp +HEADERS += lineedit.h +RESOURCES += extended.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/extended +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/extended +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/extended/extended.qrc b/examples/qml/cppextensions/referenceexamples/extended/extended.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/extended.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp b/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp new file mode 100644 index 0000000000..8f7fd8aa93 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/lineedit.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "lineedit.h" +#include + +LineEditExtension::LineEditExtension(QObject *object) +: QObject(object), m_lineedit(static_cast(object)) +{ +} + +int LineEditExtension::leftMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return l; +} + +void LineEditExtension::setLeftMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(m, t, r, b); +} + +int LineEditExtension::rightMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return r; +} + +void LineEditExtension::setRightMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(l, t, m, b); +} + +int LineEditExtension::topMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return t; +} + +void LineEditExtension::setTopMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(l, m, r, b); +} + +int LineEditExtension::bottomMargin() const +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + return b; +} + +void LineEditExtension::setBottomMargin(int m) +{ + int l, r, t, b; + m_lineedit->getTextMargins(&l, &t, &r, &b); + m_lineedit->setTextMargins(l, t, r, m); +} + + diff --git a/examples/qml/cppextensions/referenceexamples/extended/lineedit.h b/examples/qml/cppextensions/referenceexamples/extended/lineedit.h new file mode 100644 index 0000000000..fa8c75df78 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/lineedit.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef LINEEDIT_H +#define LINEEDIT_H + +#include + +class LineEditExtension : public QObject +{ + Q_OBJECT + Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY marginsChanged) + Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY marginsChanged) + Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY marginsChanged) + Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY marginsChanged) +public: + LineEditExtension(QObject *); + + int leftMargin() const; + void setLeftMargin(int); + + int rightMargin() const; + void setRightMargin(int); + + int topMargin() const; + void setTopMargin(int); + + int bottomMargin() const; + void setBottomMargin(int); +signals: + void marginsChanged(); + +private: + QLineEdit *m_lineedit; +}; + +#endif // LINEEDIT_H diff --git a/examples/qml/cppextensions/referenceexamples/extended/main.cpp b/examples/qml/cppextensions/referenceexamples/extended/main.cpp new file mode 100644 index 0000000000..3c580396f2 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/extended/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include +#include "lineedit.h" + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + qmlRegisterExtendedType("People", 1,0, "QLineEdit"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + QLineEdit *edit = qobject_cast(component.create()); + + if (edit) { + edit->show(); + return app.exec(); + } else { + qWarning() << component.errors(); + return 0; + } +} diff --git a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp new file mode 100644 index 0000000000..1859ca9461 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + diff --git a/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h new file mode 100644 index 0000000000..491903adc5 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/birthdayparty.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; + + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/grouped/example.qml b/examples/qml/cppextensions/referenceexamples/grouped/example.qml new file mode 100644 index 0000000000..9ae80f222e --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/example.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Bikey"; price: 90.0 } + } + + Boy { + name: "Leo Hodges" +//![grouped] + shoe { size: 10; color: "black"; brand: "Thebok"; price: 59.95 } +//![grouped] + } + // ![1] + Boy { + name: "Jack Smith" + shoe { + size: 8 + color: "blue" + brand: "Luma" + price: 19.95 + } + } + // ![1] + Girl { + name: "Anne Brown" +//![ungrouped] + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Job Macobs" + shoe.price: 699.99 +//![ungrouped] + } +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro b/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro new file mode 100644 index 0000000000..aab0c8469a --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/grouped.pro @@ -0,0 +1,13 @@ +QT += declarative + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += grouped.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/grouped +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/grouped +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc b/examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/grouped.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/grouped/main.cpp b/examples/qml/cppextensions/referenceexamples/grouped/main.cpp new file mode 100644 index 0000000000..de7d714c52 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/main.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + Person *bestShoe = 0; + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + qWarning() << " " << guest->name(); + + if (!bestShoe || bestShoe->shoe()->price() < guest->shoe()->price()) + bestShoe = guest; + } + if (bestShoe) + qWarning() << bestShoe->name() << "is wearing the best shoes!"; + + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/grouped/person.cpp b/examples/qml/cppextensions/referenceexamples/grouped/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/grouped/person.h b/examples/qml/cppextensions/referenceexamples/grouped/person.h new file mode 100644 index 0000000000..dea715bacb --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/grouped/person.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) +// ![1] + Q_PROPERTY(ShoeDescription *shoe READ shoe) +// ![1] +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp new file mode 100644 index 0000000000..35444f505a --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +// ![0] +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::invite(const QString &name) +{ + Person *person = new Person(this); + person->setName(name); + m_guests.append(person); +} +// ![0] + diff --git a/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h new file mode 100644 index 0000000000..e49afdb78d --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/birthdayparty.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +// ![0] + Q_INVOKABLE void invite(const QString &name); +// ![0] + +private: + Person *m_host; + QList m_guests; +}; + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/methods/example.qml b/examples/qml/cppextensions/referenceexamples/methods/example.qml new file mode 100644 index 0000000000..9119835e04 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/example.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import People 1.0 + +BirthdayParty { + host: Person { + name: "Bob Jones" + shoeSize: 12 + } + guests: [ + Person { name: "Leo Hodges" }, + Person { name: "Jack Smith" }, + Person { name: "Anne Brown" } + ] + +// ![0] + Component.onCompleted: invite("William Green") +// ![0] +} diff --git a/examples/qml/cppextensions/referenceexamples/methods/main.cpp b/examples/qml/cppextensions/referenceexamples/methods/main.cpp new file mode 100644 index 0000000000..d037d88f20 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/main.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "Person"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + qWarning() << "They are inviting:"; + for (int ii = 0; ii < party->guestCount(); ++ii) + qWarning() << " " << party->guest(ii)->name(); + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/methods/methods.pro b/examples/qml/cppextensions/referenceexamples/methods/methods.pro new file mode 100644 index 0000000000..ee28355188 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/methods.pro @@ -0,0 +1,13 @@ +QT += declarative + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += methods.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/methods +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS methods.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/methods +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/methods/methods.qrc b/examples/qml/cppextensions/referenceexamples/methods/methods.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/methods.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/methods/person.cpp b/examples/qml/cppextensions/referenceexamples/methods/person.cpp new file mode 100644 index 0000000000..30d1e46e5a --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/person.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + diff --git a/examples/qml/cppextensions/referenceexamples/methods/person.h b/examples/qml/cppextensions/referenceexamples/methods/person.h new file mode 100644 index 0000000000..dd3ad4d188 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/methods/person.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); +private: + QString m_name; + int m_shoeSize; +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp new file mode 100644 index 0000000000..0038cd0a41 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +// ![0] +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} +// ![0] + diff --git a/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h new file mode 100644 index 0000000000..2c3d128b6d --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/birthdayparty.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include "person.h" + +// ![0] +class BirthdayParty : public QObject +{ + Q_OBJECT +// ![0] +// ![1] + Q_PROPERTY(Person *host READ host WRITE setHost) +// ![1] +// ![2] + Q_PROPERTY(QDeclarativeListProperty guests READ guests) +// ![2] +// ![3] +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + +private: + Person *m_host; + QList m_guests; +}; +// ![3] + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/properties/example.qml b/examples/qml/cppextensions/referenceexamples/properties/example.qml new file mode 100644 index 0000000000..36ee952243 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/example.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + host: Person { + name: "Bob Jones" + shoeSize: 12 + } + guests: [ + Person { name: "Leo Hodges" }, + Person { name: "Jack Smith" }, + Person { name: "Anne Brown" } + ] +} +// ![0] diff --git a/examples/qml/cppextensions/referenceexamples/properties/main.cpp b/examples/qml/cppextensions/referenceexamples/properties/main.cpp new file mode 100644 index 0000000000..421ce9fbaa --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + +//![register list] + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "Person"); +//![register list] + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + qWarning() << "They are inviting:"; + for (int ii = 0; ii < party->guestCount(); ++ii) + qWarning() << " " << party->guest(ii)->name(); + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/properties/person.cpp b/examples/qml/cppextensions/referenceexamples/properties/person.cpp new file mode 100644 index 0000000000..30d1e46e5a --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/person.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +Person::Person(QObject *parent) +: QObject(parent), m_shoeSize(0) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +int Person::shoeSize() const +{ + return m_shoeSize; +} + +void Person::setShoeSize(int s) +{ + m_shoeSize = s; +} + diff --git a/examples/qml/cppextensions/referenceexamples/properties/person.h b/examples/qml/cppextensions/referenceexamples/properties/person.h new file mode 100644 index 0000000000..dd3ad4d188 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/person.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + int shoeSize() const; + void setShoeSize(int); +private: + QString m_name; + int m_shoeSize; +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/properties/properties.pro b/examples/qml/cppextensions/referenceexamples/properties/properties.pro new file mode 100644 index 0000000000..936d0ea429 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/properties.pro @@ -0,0 +1,13 @@ +QT += declarative + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += properties.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/properties +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/properties +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/properties/properties.qrc b/examples/qml/cppextensions/referenceexamples/properties/properties.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/properties/properties.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/referenceexamples.pro b/examples/qml/cppextensions/referenceexamples/referenceexamples.pro new file mode 100644 index 0000000000..505cefd331 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/referenceexamples.pro @@ -0,0 +1,14 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + adding \ + attached \ + binding \ + coercion \ + default \ + extended \ + grouped \ + properties \ + signal \ + valuesource \ + methods diff --git a/examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject b/examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/referenceexamples.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp new file mode 100644 index 0000000000..d576c2a278 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + m_rsvp = d; +} + + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::startParty() +{ + QTime time = QTime::currentTime(); + emit partyStarted(time); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h new file mode 100644 index 0000000000..45ad4f0acf --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/birthdayparty.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + + void startParty(); +// ![0] +signals: + void partyStarted(const QTime &time); +// ![0] + +private: + Person *m_host; + QList m_guests; +}; +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/signal/example.qml b/examples/qml/cppextensions/referenceexamples/signal/example.qml new file mode 100644 index 0000000000..796c2f32a1 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/example.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +BirthdayParty { +// ![0] + onPartyStarted: console.log("This party started rockin' at " + time); +// ![0] + + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + Boy { + name: "Leo Hodges" + BirthdayParty.rsvp: "2009-07-06" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + } + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } + Girl { + name: "Anne Brown" + BirthdayParty.rsvp: "2009-07-01" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + } +// ![1] +} +// ![1] diff --git a/examples/qml/cppextensions/referenceexamples/signal/main.cpp b/examples/qml/cppextensions/referenceexamples/signal/main.cpp new file mode 100644 index 0000000000..5800cf450f --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/main.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + QDate rsvpDate; + QObject *attached = + qmlAttachedPropertiesObject(guest, false); + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + party->startParty(); + } else { + qWarning() << component.errors(); + } + + return 0; +} diff --git a/examples/qml/cppextensions/referenceexamples/signal/person.cpp b/examples/qml/cppextensions/referenceexamples/signal/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/signal/person.h b/examples/qml/cppextensions/referenceexamples/signal/person.h new file mode 100644 index 0000000000..032eca3c17 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/person.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(ShoeDescription *shoe READ shoe) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/signal/signal.pro b/examples/qml/cppextensions/referenceexamples/signal/signal.pro new file mode 100644 index 0000000000..8ffdb50f90 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/signal.pro @@ -0,0 +1,13 @@ +QT += declarative + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp +HEADERS += person.h \ + birthdayparty.h +RESOURCES += signal.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/signal +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/signal +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/signal/signal.qrc b/examples/qml/cppextensions/referenceexamples/signal/signal.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/signal/signal.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp new file mode 100644 index 0000000000..09137c41a8 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "birthdayparty.h" + +BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) +: QObject(object) +{ +} + +QDate BirthdayPartyAttached::rsvp() const +{ + return m_rsvp; +} + +void BirthdayPartyAttached::setRsvp(const QDate &d) +{ + m_rsvp = d; +} + + +BirthdayParty::BirthdayParty(QObject *parent) +: QObject(parent), m_host(0) +{ +} + +Person *BirthdayParty::host() const +{ + return m_host; +} + +void BirthdayParty::setHost(Person *c) +{ + m_host = c; +} + +QDeclarativeListProperty BirthdayParty::guests() +{ + return QDeclarativeListProperty(this, m_guests); +} + +int BirthdayParty::guestCount() const +{ + return m_guests.count(); +} + +Person *BirthdayParty::guest(int index) const +{ + return m_guests.at(index); +} + +void BirthdayParty::startParty() +{ + QTime time = QTime::currentTime(); + emit partyStarted(time); +} + +QString BirthdayParty::announcement() const +{ + return QString(); +} + +void BirthdayParty::setAnnouncement(const QString &speak) +{ + qWarning() << qPrintable(speak); +} + +BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) +{ + return new BirthdayPartyAttached(object); +} + diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h new file mode 100644 index 0000000000..5d561da807 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/birthdayparty.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef BIRTHDAYPARTY_H +#define BIRTHDAYPARTY_H + +#include +#include +#include +#include +#include "person.h" + +class BirthdayPartyAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) +public: + BirthdayPartyAttached(QObject *object); + + QDate rsvp() const; + void setRsvp(const QDate &); + +private: + QDate m_rsvp; +}; + +class BirthdayParty : public QObject +{ + Q_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty guests READ guests) +// ![0] + Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) +// ![0] + Q_CLASSINFO("DefaultProperty", "guests") +public: + BirthdayParty(QObject *parent = 0); + + Person *host() const; + void setHost(Person *); + + QDeclarativeListProperty guests(); + int guestCount() const; + Person *guest(int) const; + + QString announcement() const; + void setAnnouncement(const QString &); + + static BirthdayPartyAttached *qmlAttachedProperties(QObject *); + + void startParty(); +signals: + void partyStarted(const QTime &time); + +private: + Person *m_host; + QList m_guests; +}; +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) + +#endif // BIRTHDAYPARTY_H diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/example.qml b/examples/qml/cppextensions/referenceexamples/valuesource/example.qml new file mode 100644 index 0000000000..04c3048e9e --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/example.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import People 1.0 + +// ![0] +BirthdayParty { + HappyBirthdaySong on announcement { name: "Bob Jones" } +// ![0] + + onPartyStarted: console.log("This party started rockin' at " + time); + + + host: Boy { + name: "Bob Jones" + shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } + } + + Boy { + name: "Leo Hodges" + BirthdayParty.rsvp: "2009-07-06" + shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } + } + Boy { + name: "Jack Smith" + shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } + } + Girl { + name: "Anne Brown" + BirthdayParty.rsvp: "2009-07-01" + shoe.size: 7 + shoe.color: "red" + shoe.brand: "Marc Jacobs" + shoe.price: 699.99 + } + +// ![1] +} +// ![1] diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp new file mode 100644 index 0000000000..629c354543 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "happybirthdaysong.h" +#include + +HappyBirthdaySong::HappyBirthdaySong(QObject *parent) +: QObject(parent), m_line(-1) +{ + setName(QString()); + QTimer *timer = new QTimer(this); + QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); + timer->start(1000); +} + +void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) +{ + m_target = p; +} + +QString HappyBirthdaySong::name() const +{ + return m_name; +} + +void HappyBirthdaySong::setName(const QString &name) +{ + m_name = name; + + m_lyrics.clear(); + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday to you,"; + m_lyrics << "Happy birthday dear " + m_name + ","; + m_lyrics << "Happy birthday to you!"; + m_lyrics << ""; +} + +void HappyBirthdaySong::advance() +{ + m_line = (m_line + 1) % m_lyrics.count(); + + m_target.write(m_lyrics.at(m_line)); +} + diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h new file mode 100644 index 0000000000..9721350435 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/happybirthdaysong.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H + +#include +#include +#include + +#include + +// ![0] +class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource +{ + Q_OBJECT + Q_INTERFACES(QDeclarativePropertyValueSource) +// ![0] + Q_PROPERTY(QString name READ name WRITE setName) +// ![1] +public: + HappyBirthdaySong(QObject *parent = 0); + + virtual void setTarget(const QDeclarativeProperty &); +// ![1] + + QString name() const; + void setName(const QString &); + +private slots: + void advance(); + +private: + int m_line; + QStringList m_lyrics; + QDeclarativeProperty m_target; + QString m_name; +// ![2] +}; +// ![2] + +#endif // HAPPYBIRTHDAYSONG_H + diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp new file mode 100644 index 0000000000..53d676dfbe --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "birthdayparty.h" +#include "happybirthdaysong.h" +#include "person.h" + +int main(int argc, char ** argv) +{ + QCoreApplication app(argc, argv); + + qmlRegisterType(); + qmlRegisterType("People", 1,0, "BirthdayParty"); + qmlRegisterType("People", 1,0, "HappyBirthdaySong"); + qmlRegisterType(); + qmlRegisterType(); + qmlRegisterType("People", 1,0, "Boy"); + qmlRegisterType("People", 1,0, "Girl"); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); + BirthdayParty *party = qobject_cast(component.create()); + + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; + + if (qobject_cast(party->host())) + qWarning() << "He is inviting:"; + else + qWarning() << "She is inviting:"; + + for (int ii = 0; ii < party->guestCount(); ++ii) { + Person *guest = party->guest(ii); + + QDate rsvpDate; + QObject *attached = + qmlAttachedPropertiesObject(guest, false); + if (attached) + rsvpDate = attached->property("rsvp").toDate(); + + if (rsvpDate.isNull()) + qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; + else + qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); + } + + party->startParty(); + } else { + qWarning() << component.errors(); + } + + return app.exec(); +} diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/person.cpp b/examples/qml/cppextensions/referenceexamples/valuesource/person.cpp new file mode 100644 index 0000000000..7afcdc6ca6 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/person.cpp @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "person.h" + +ShoeDescription::ShoeDescription(QObject *parent) +: QObject(parent), m_size(0), m_price(0) +{ +} + +int ShoeDescription::size() const +{ + return m_size; +} + +void ShoeDescription::setSize(int s) +{ + m_size = s; +} + +QColor ShoeDescription::color() const +{ + return m_color; +} + +void ShoeDescription::setColor(const QColor &c) +{ + m_color = c; +} + +QString ShoeDescription::brand() const +{ + return m_brand; +} + +void ShoeDescription::setBrand(const QString &b) +{ + m_brand = b; +} + +qreal ShoeDescription::price() const +{ + return m_price; +} + +void ShoeDescription::setPrice(qreal p) +{ + m_price = p; +} + +Person::Person(QObject *parent) +: QObject(parent) +{ +} + +QString Person::name() const +{ + return m_name; +} + +void Person::setName(const QString &n) +{ + m_name = n; +} + +ShoeDescription *Person::shoe() +{ + return &m_shoe; +} + + +Boy::Boy(QObject * parent) +: Person(parent) +{ +} + + +Girl::Girl(QObject * parent) +: Person(parent) +{ +} + diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/person.h b/examples/qml/cppextensions/referenceexamples/valuesource/person.h new file mode 100644 index 0000000000..032eca3c17 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/person.h @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PERSON_H +#define PERSON_H + +#include +#include + +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize) + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(QString brand READ brand WRITE setBrand) + Q_PROPERTY(qreal price READ price WRITE setPrice) +public: + ShoeDescription(QObject *parent = 0); + + int size() const; + void setSize(int); + + QColor color() const; + void setColor(const QColor &); + + QString brand() const; + void setBrand(const QString &); + + qreal price() const; + void setPrice(qreal); +private: + int m_size; + QColor m_color; + QString m_brand; + qreal m_price; +}; + +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(ShoeDescription *shoe READ shoe) +public: + Person(QObject *parent = 0); + + QString name() const; + void setName(const QString &); + + ShoeDescription *shoe(); +private: + QString m_name; + ShoeDescription m_shoe; +}; + +class Boy : public Person +{ + Q_OBJECT +public: + Boy(QObject * parent = 0); +}; + +class Girl : public Person +{ + Q_OBJECT +public: + Girl(QObject * parent = 0); +}; + +#endif // PERSON_H diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro new file mode 100644 index 0000000000..a978d8452a --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.pro @@ -0,0 +1,15 @@ +QT += declarative + +SOURCES += main.cpp \ + person.cpp \ + birthdayparty.cpp \ + happybirthdaysong.cpp +HEADERS += person.h \ + birthdayparty.h \ + happybirthdaysong.h +RESOURCES += valuesource.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/valuesource +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/extending/valuesource +INSTALLS += target sources diff --git a/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc new file mode 100644 index 0000000000..e2fa01d5e7 --- /dev/null +++ b/examples/qml/cppextensions/referenceexamples/valuesource/valuesource.qrc @@ -0,0 +1,5 @@ + + + example.qml + + diff --git a/examples/qml/i18n/i18n.qml b/examples/qml/i18n/i18n.qml new file mode 100644 index 0000000000..f8bf30d0f0 --- /dev/null +++ b/examples/qml/i18n/i18n.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +// +// The QML runtime automatically loads a translation from the i18n subdirectory of the root +// QML file, based on the system language. +// +// The files are created/updated by running: +// +// lupdate i18n.qml -ts i18n/base.ts +// +// Translations for new languages are created by copying i18n/base.ts to i18n/qml_.ts +// The .ts files can then be edited with Linguist: +// +// linguist i18n/qml_fr.ts +// +// The run-time translation files are then generated by running: +// +// lrelease i18n/*.ts +// + +Rectangle { + width: 640; height: 480 + + Column { + anchors.fill: parent; spacing: 20 + + Text { + text: "If a translation is available for the system language (eg. French) then the "+ + "string below will translated (eg. 'Bonjour'). Otherwise it will show 'Hello'." + width: parent.width; wrapMode: Text.WordWrap + } + + Text { + text: qsTr("Hello") + font.pointSize: 25; anchors.horizontalCenter: parent.horizontalCenter + } + } +} diff --git a/examples/qml/i18n/i18n/base.ts b/examples/qml/i18n/i18n/base.ts new file mode 100644 index 0000000000..82547a1f93 --- /dev/null +++ b/examples/qml/i18n/i18n/base.ts @@ -0,0 +1,12 @@ + + + + + i18n + + + Hello + + + + diff --git a/examples/qml/i18n/i18n/qml_en_AU.ts b/examples/qml/i18n/i18n/qml_en_AU.ts new file mode 100644 index 0000000000..e991affe7f --- /dev/null +++ b/examples/qml/i18n/i18n/qml_en_AU.ts @@ -0,0 +1,12 @@ + + + + + i18n + + + Hello + G'day + + + diff --git a/examples/qml/i18n/i18n/qml_fr.ts b/examples/qml/i18n/i18n/qml_fr.ts new file mode 100644 index 0000000000..365abd95c2 --- /dev/null +++ b/examples/qml/i18n/i18n/qml_fr.ts @@ -0,0 +1,12 @@ + + + + + i18n + + + Hello + Bonjour + + + diff --git a/examples/qml/locale/locale.qml b/examples/qml/locale/locale.qml new file mode 100644 index 0000000000..08d08d6bbd --- /dev/null +++ b/examples/qml/locale/locale.qml @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + width: 320 + height: 480 + color: "lightgray" + + property string locale: view.currentItem.locale + + Text { + id: title + text: "Select locale:" + } + + Rectangle { + id: chooser + anchors.top: title.bottom + anchors.topMargin: 5 + width: parent.width-10 + x: 5 + height: parent.height/2 - 10 + color: "#40300030" + ListView { + id: view + clip: true + focus: true + anchors.fill: parent + model: [ + "en_US", + "en_GB", + "fi_FI", + "de_DE", + "ar_SA", + "hi_IN", + "zh_CN", + "th_TH", + "fr_FR", + "nb_NO", + "sv_SE" + ] + delegate: Text { + property string locale: modelData + height: 30 + width: view.width + text: Qt.locale(modelData).name + " ("+ Qt.locale(modelData).nativeCountryName + "/" + Qt.locale(modelData).nativeLanguageName + ")" + MouseArea { + anchors.fill: parent + onClicked: view.currentIndex = index + } + } + highlight: Rectangle { + height: 30 + color: "#60300030" + } + } + } + + Rectangle { + color: "white" + anchors.top: chooser.bottom + anchors.topMargin: 5 + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + x: 5; width: parent.width - 10 + + Column { + anchors.fill: parent + spacing: 5 + Text { + property var date: new Date() + text: "Date: " + date.toLocaleDateString(Qt.locale(root.locale)) + } + Text { + property var date: new Date() + text: "Time: " + date.toLocaleTimeString(Qt.locale(root.locale)) + } + Text { + property var dow: Qt.locale(root.locale).firstDayOfWeek + text: "First day of week: " + Qt.locale(root.locale).standaloneDayName(dow) + } + Text { + property var num: 10023823 + text: "Number: " + num.toLocaleString(Qt.locale(root.locale)) + } + Text { + property var num: 10023823 + text: "Currency: " + num.toLocaleCurrencyString(Qt.locale(root.locale)) + } + } + } +} diff --git a/examples/qml/qml.pro b/examples/qml/qml.pro new file mode 100644 index 0000000000..967108504e --- /dev/null +++ b/examples/qml/qml.pro @@ -0,0 +1 @@ +TEMPLATE = subdirs diff --git a/examples/qml/script/script.pro b/examples/qml/script/script.pro new file mode 100644 index 0000000000..98c1bbc5ee --- /dev/null +++ b/examples/qml/script/script.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs + +SUBDIRS = \ + shell diff --git a/examples/qml/script/shell/main.cpp b/examples/qml/script/shell/main.cpp new file mode 100644 index 0000000000..9f0edf4a25 --- /dev/null +++ b/examples/qml/script/shell/main.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#include +#include +#include +#include + +#include + +#include + +#include + + +class CommandInterface : public QObject +{ + Q_OBJECT +public: + Q_INVOKABLE void quit() { m_wantsToQuit = true; } + static bool wantsToQuit() { return m_wantsToQuit; } +private: + static bool m_wantsToQuit; +}; + +bool CommandInterface::m_wantsToQuit = false; + + +static void interactive(QJSEngine *eng) +{ + QTextStream qin(stdin, QFile::ReadOnly); + const char *prompt = "qs> "; + + forever { + QString line; + + printf("%s", prompt); + fflush(stdout); + + line = qin.readLine(); + if (line.isNull()) + break; + + if (line.trimmed().isEmpty()) + continue; + + line += QLatin1Char('\n'); + + QJSValue result = eng->evaluate(line, QLatin1String("typein")); + + fprintf(stderr, "%s\n", qPrintable(result.toString())); + + if (CommandInterface::wantsToQuit()) + break; + } +} + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + QScopedPointer eng(new QJSEngine()); + { + QJSValue globalObject = eng->globalObject(); + QJSValue interface = eng->newQObject(new CommandInterface); + globalObject.setProperty("qt", interface); + } + + if (! *++argv) { + interactive(eng.data()); + return EXIT_SUCCESS; + } + + while (const char *arg = *argv++) { + QString fileName = QString::fromLocal8Bit(arg); + + if (fileName == QLatin1String("-i")) { + interactive(eng.data()); + break; + } + + QString contents; + int lineNumber = 1; + + if (fileName == QLatin1String("-")) { + QTextStream stream(stdin, QFile::ReadOnly); + contents = stream.readAll(); + } else { + QFile file(fileName); + if (file.open(QFile::ReadOnly)) { + QTextStream stream(&file); + contents = stream.readAll(); + file.close(); + + // strip off #!/usr/bin/env qjs line + if (contents.startsWith("#!")) { + contents.remove(0, contents.indexOf("\n")); + ++lineNumber; + } + } + } + + if (contents.isEmpty()) + continue; + + QJSValue result = eng->evaluate(contents, fileName, lineNumber); + if (eng->hasUncaughtException()) { + fprintf (stderr, " %s\n\n", qPrintable(result.toString())); + return EXIT_FAILURE; + } + } + + return EXIT_SUCCESS; +} + +#include diff --git a/examples/qml/script/shell/shell.pro b/examples/qml/script/shell/shell.pro new file mode 100644 index 0000000000..00191ab3d0 --- /dev/null +++ b/examples/qml/script/shell/shell.pro @@ -0,0 +1,7 @@ +QT += declarative + +win32: CONFIG += console +mac:CONFIG -= app_bundle + +SOURCES += main.cpp + diff --git a/examples/qml/xmlhttprequest/data.xml b/examples/qml/xmlhttprequest/data.xml new file mode 100644 index 0000000000..8b7f1e116d --- /dev/null +++ b/examples/qml/xmlhttprequest/data.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/qml/xmlhttprequest/xmlhttprequest-example.qml b/examples/qml/xmlhttprequest/xmlhttprequest-example.qml new file mode 100644 index 0000000000..28ba078160 --- /dev/null +++ b/examples/qml/xmlhttprequest/xmlhttprequest-example.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 350; height: 400 + + function showRequestInfo(text) { + log.text = log.text + "\n" + text + console.log(text) + } + + Text { id: log; anchors.fill: parent; anchors.margins: 10 } + + Rectangle { + id: button + anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.margins: 10 + width: buttonText.width + 10; height: buttonText.height + 10 + border.width: mouseArea.pressed ? 2 : 1 + radius : 5; smooth: true + + Text { id: buttonText; anchors.centerIn: parent; text: "Request data.xml" } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + log.text = "" + console.log("\n") + + var doc = new XMLHttpRequest(); + doc.onreadystatechange = function() { + if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { + showRequestInfo("Headers -->"); + showRequestInfo(doc.getAllResponseHeaders ()); + showRequestInfo("Last modified -->"); + showRequestInfo(doc.getResponseHeader ("Last-Modified")); + + } else if (doc.readyState == XMLHttpRequest.DONE) { + var a = doc.responseXML.documentElement; + for (var ii = 0; ii < a.childNodes.length; ++ii) { + showRequestInfo(a.childNodes[ii].nodeName); + } + showRequestInfo("Headers -->"); + showRequestInfo(doc.getAllResponseHeaders ()); + showRequestInfo("Last modified -->"); + showRequestInfo(doc.getResponseHeader ("Last-Modified")); + } + } + + doc.open("GET", "data.xml"); + doc.send(); + } + } + } +} + diff --git a/examples/qtquick/accessibility/accessibility.pro b/examples/qtquick/accessibility/accessibility.pro new file mode 100644 index 0000000000..20d68e0c5c --- /dev/null +++ b/examples/qtquick/accessibility/accessibility.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +QT += quick declarative +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/accessibility +qml.files = accessibility.qml content +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/accessibility +INSTALLS += target qml + diff --git a/examples/qtquick/accessibility/accessibility.qml b/examples/qtquick/accessibility/accessibility.qml new file mode 100644 index 0000000000..ff115ab4b3 --- /dev/null +++ b/examples/qtquick/accessibility/accessibility.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +/*! + \title QtQuick Examples - Accessibility + \example qtquick/accessibility + \brief This example has accessible buttons. + +*/ + +Rectangle { + id: window + + width: 320; height: 480 + color: "white" + + Column { + id: column + spacing: 6 + anchors.fill: parent + width: parent.width + Row { + spacing: 6 + width: column.width + Button { width: 100; height: column.h + 20; text: "Send" } + Button { width: 100; height: column.h + 20; text: "Discard" } + } + + Row { + spacing: 6 + width: column.width + height: column.h + Text { + id: subjectLabel + Accessible.role: Accessible.StaticText + Accessible.name: text + text: "Subject:" + } + Rectangle { + id: subjectBorder + Accessible.role: Accessible.EditableText + Accessible.name: subjectEdit.text + border.width: 1 + border.color: "black" + height: subjectEdit.height + width: 240 + TextInput { + id: subjectEdit + text: "Vacation plans" + } + } + } + Rectangle { + id: textBorder + Accessible.role: Accessible.EditableText + property alias text : textEdit.text + border.width: 1 + border.color: "black" + width: parent.width - 2 + height: parent.height - (textBorder.y + column.spacing) + TextEdit { + id: textEdit + text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke" + width: parent.width + wrapMode: TextEdit.WordWrap + } + } + } +} diff --git a/examples/qtquick/accessibility/accessibility.qmlproject b/examples/qtquick/accessibility/accessibility.qmlproject new file mode 100644 index 0000000000..04a3190914 --- /dev/null +++ b/examples/qtquick/accessibility/accessibility.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "accessibility.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/accessibility/content/Button.qml b/examples/qtquick/accessibility/content/Button.qml new file mode 100644 index 0000000000..33cee8036c --- /dev/null +++ b/examples/qtquick/accessibility/content/Button.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: button + + property bool checked: false + property alias text : buttonText.text + Accessible.name: text + Accessible.description: "This button does " + text + Accessible.role: Accessible.Button + + signal clicked + + width: buttonText.width + 20 + height: 30 + gradient: Gradient { + GradientStop { position: 0.0; color: "lightsteelblue" } + GradientStop { position: 1.0; color: "blue" } + } + border.width: 2 + border.color: "black"; + radius: 10 + + Text { + id: buttonText + text: parent.description + anchors.centerIn: parent + font.pixelSize: parent.height * .5 + style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + checked = !checked; + } + } +} diff --git a/examples/qtquick/accessibility/main.cpp b/examples/qtquick/accessibility/main.cpp new file mode 100644 index 0000000000..89e23b477b --- /dev/null +++ b/examples/qtquick/accessibility/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(accessibility) diff --git a/examples/qtquick/animation/animation.pro b/examples/qtquick/animation/animation.pro new file mode 100644 index 0000000000..7e4cf9ef66 --- /dev/null +++ b/examples/qtquick/animation/animation.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +QT += quick declarative +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation +qml.files = animation.qml basics behaviors easing pathanimation pathinterpolator states +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/animation +INSTALLS += target qml + diff --git a/examples/qtquick/animation/animation.qml b/examples/qtquick/animation/animation.qml new file mode 100644 index 0000000000..62a85a9cfa --- /dev/null +++ b/examples/qtquick/animation/animation.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../../shared" as Examples + +/*! + \title QtQuick Examples - Animation + \example qtquick/animation + \brief This is a collection of QML Animation examples. + \image qml-animations-example.png + + This is a collection of small QML examples relating to animation. Each example is + a small QML file emphasizing a particular element or feature. + + ColorAnimation demonstrates using a color animation to fade a sky from day to night. + + PropertyAnimation demonstrates using a number animation to bounce a circle up and down. + + Behaviors demonstrates using behaviors to animate moving a rectangle to whereever you click. + + Wiggly Text demonstrates using more complex behaviors to animate and wiggle some text around as you drag it. + + Easing Curves shows off all the easing curves available in Qt Quick animations. + + States demonstrates how the properties of an item can vary between states. + + Transitions takes the States example and animates the property changes. + + PathAnimation animates an image along a beizer curve using a PathAnimation. + + PathInterpolator animates an image along the same beizer curve, using a PathInterpolator instead. +*/ + +Item { + height: 480 + width: 320 + Examples.LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("ColorAnimation", "Interpolates between colors", Qt.resolvedUrl("basics/color-animation.qml")); + addExample("PropertyAnimation", "Interpolates between numbers", Qt.resolvedUrl("basics/property-animation.qml")); + addExample("Behaviors", "Animates procedural movement", Qt.resolvedUrl("behaviors/behavior-example.qml")); + addExample("Wiggly Text", "Text that wiggles as you drag it", Qt.resolvedUrl("behaviors/wigglytext.qml")); + addExample("Easing Curves", "Compare available easing curves", Qt.resolvedUrl("easing/easing.qml")); + addExample("States", "Simple states", Qt.resolvedUrl("states/states.qml")); + addExample("Transitions", "Simple states with animated transitions", Qt.resolvedUrl("states/transitions.qml")); + addExample("PathAnimation", "Animate along a path", Qt.resolvedUrl("pathanimation/pathanimation.qml")); + addExample("PathInterpolator", "Interpolates along a path", Qt.resolvedUrl("pathinterpolator/pathinterpolator.qml")); + } + } +} diff --git a/examples/qtquick/animation/animation.qmlproject b/examples/qtquick/animation/animation.qmlproject new file mode 100644 index 0000000000..2e96daa881 --- /dev/null +++ b/examples/qtquick/animation/animation.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "animation.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/animation/basics/color-animation.qml b/examples/qtquick/animation/basics/color-animation.qml new file mode 100644 index 0000000000..f1bf40c40b --- /dev/null +++ b/examples/qtquick/animation/basics/color-animation.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Item { + id: window + width: 320; height: 480 + + // Let's draw the sky... + Rectangle { + anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { + position: 0.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 } + ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 } + } + } + GradientStop { + position: 1.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 } + ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 } + } + } + } + } + + // the sun, moon, and stars + Item { + width: parent.width; height: 2 * parent.height + NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite } + Image { + source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter + rotation: -3 * parent.rotation + } + Image { + source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter + rotation: -parent.rotation + } + ParticleSystem { + id: particlesystem + x: 0; y: parent.height/2 + width: parent.width; height: parent.height/2 + ImageParticle { + source: "images/star.png" + groups: ["star"] + color: "#00333333" + SequentialAnimation on opacity { + loops: Animation.Infinite + NumberAnimation { from: 0; to: 1; duration: 5000 } + NumberAnimation { from: 1; to: 0; duration: 5000 } + } + } + Emitter { + group: "star" + anchors.fill: parent + emitRate: parent.width / 50 + lifeSpan: 5000 + } + } + } + + // ...and the ground. + Rectangle { + anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { + position: 0.0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 } + ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 } + } + } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } +} diff --git a/examples/qtquick/animation/basics/images/face-smile.png b/examples/qtquick/animation/basics/images/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qtquick/animation/basics/images/face-smile.png differ diff --git a/examples/qtquick/animation/basics/images/moon.png b/examples/qtquick/animation/basics/images/moon.png new file mode 100644 index 0000000000..9407b2b4f0 Binary files /dev/null and b/examples/qtquick/animation/basics/images/moon.png differ diff --git a/examples/qtquick/animation/basics/images/shadow.png b/examples/qtquick/animation/basics/images/shadow.png new file mode 100644 index 0000000000..8270565e87 Binary files /dev/null and b/examples/qtquick/animation/basics/images/shadow.png differ diff --git a/examples/qtquick/animation/basics/images/star.png b/examples/qtquick/animation/basics/images/star.png new file mode 100644 index 0000000000..27ef924267 Binary files /dev/null and b/examples/qtquick/animation/basics/images/star.png differ diff --git a/examples/qtquick/animation/basics/images/sun.png b/examples/qtquick/animation/basics/images/sun.png new file mode 100644 index 0000000000..7713ca5ce7 Binary files /dev/null and b/examples/qtquick/animation/basics/images/sun.png differ diff --git a/examples/qtquick/animation/basics/property-animation.qml b/examples/qtquick/animation/basics/property-animation.qml new file mode 100644 index 0000000000..4a4d3e3b2a --- /dev/null +++ b/examples/qtquick/animation/basics/property-animation.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: window + width: 320; height: 480 + + // Let's draw the sky... + Rectangle { + anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { position: 0.0; color: "DeepSkyBlue" } + GradientStop { position: 1.0; color: "LightSkyBlue" } + } + } + + // ...and the ground. + Rectangle { + anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + // The shadow for the smiley face + Image { + anchors.horizontalCenter: parent.horizontalCenter + y: smiley.minHeight + 58 + source: "images/shadow.png" + + // The scale property depends on the y position of the smiley face. + scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) + } + + Image { + id: smiley + property int maxHeight: window.height / 3 + property int minHeight: 2 * window.height / 3 + + anchors.horizontalCenter: parent.horizontalCenter + y: minHeight + source: "images/face-smile.png" + + // Animate the y property. Setting loops to Animation.Infinite makes the + // animation repeat indefinitely, otherwise it would only run once. + SequentialAnimation on y { + loops: Animation.Infinite + + // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function + NumberAnimation { + from: smiley.minHeight; to: smiley.maxHeight + easing.type: Easing.OutExpo; duration: 300 + } + + // Then move back to minHeight in 1 second, using the OutBounce easing function + NumberAnimation { + from: smiley.maxHeight; to: smiley.minHeight + easing.type: Easing.OutBounce; duration: 1000 + } + + // Then pause for 500ms + PauseAnimation { duration: 500 } + } + } +} diff --git a/examples/qtquick/animation/behaviors/SideRect.qml b/examples/qtquick/animation/behaviors/SideRect.qml new file mode 100644 index 0000000000..623c6965d8 --- /dev/null +++ b/examples/qtquick/animation/behaviors/SideRect.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: myRect + + property string text + + width: 75; height: 50 + radius: 6 + color: "#646464" + border.width: 4; border.color: "white" + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: { + focusRect.x = myRect.x; + focusRect.y = myRect.y; + focusRect.text = myRect.text; + } + } +} diff --git a/examples/qtquick/animation/behaviors/behavior-example.qml b/examples/qtquick/animation/behaviors/behavior-example.qml new file mode 100644 index 0000000000..a88d7c8c7b --- /dev/null +++ b/examples/qtquick/animation/behaviors/behavior-example.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 320; height: 480 + color: "#343434" + + Rectangle { + anchors.centerIn: parent + width: 200; height: 200 + radius: 30 + color: "transparent" + border.width: 4; border.color: "white" + + + SideRect { + id: leftRect + anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left } + text: "Left" + } + + SideRect { + id: rightRect + anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right } + text: "Right" + } + + SideRect { + id: topRect + anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter } + text: "Top" + } + + SideRect { + id: bottomRect + anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter } + text: "Bottom" + } + + + Rectangle { + id: focusRect + + property string text + + x: 62; y: 75; width: 75; height: 50 + radius: 6 + border.width: 4; border.color: "white" + color: "firebrick" + + // Set an 'elastic' behavior on the focusRect's x property. + Behavior on x { + NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + // Set an 'elastic' behavior on the focusRect's y property. + Behavior on y { + NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } + } + + Text { + id: focusText + text: focusRect.text + anchors.centerIn: parent + color: "white" + font.pixelSize: 16; font.bold: true + + // Set a behavior on the focusText's x property: + // Set the opacity to 0, set the new text value, then set the opacity back to 1. + Behavior on text { + SequentialAnimation { + NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } + NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } + } + } + } + } + } +} diff --git a/examples/qtquick/animation/behaviors/wigglytext.qml b/examples/qtquick/animation/behaviors/wigglytext.qml new file mode 100644 index 0000000000..4bb94da100 --- /dev/null +++ b/examples/qtquick/animation/behaviors/wigglytext.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Drag me!" + property bool animated: true + + width: 320; height: 480; color: "#474747"; focus: true + + Keys.onPressed: { + if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace) + container.remove() + else if (event.text != "") { + container.append(event.text) + } + } + + function append(text) { + container.animated = false + var lastLetter = container.children[container.children.length - 1] + var newLetter = letterComponent.createObject(container) + newLetter.text = text + newLetter.follow = lastLetter + container.animated = true + } + + function remove() { + if (container.children.length) + container.children[container.children.length - 1].destroy() + } + + function doLayout() { + var follow = null + for (var i = 0; i < container.text.length; ++i) { + var newLetter = letterComponent.createObject(container) + newLetter.text = container.text[i] + newLetter.follow = follow + follow = newLetter + } + } + + Component { + id: letterComponent + Text { + id: letter + property variant follow + + x: follow ? follow.x + follow.width : container.width / 6 + y: follow ? follow.y : container.height / 2 + + font.pixelSize: 40; font.bold: true + color: "#999999"; styleColor: "#222222"; style: Text.Raised + + MouseArea { + anchors.fill: parent + drag.target: letter; drag.axis: Drag.XandYAxis + onPressed: letter.color = "#dddddd" + onReleased: letter.color = "#999999" + } + + Behavior on x { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } + Behavior on y { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } + } + } + + Component.onCompleted: doLayout() +} diff --git a/examples/qtquick/animation/easing/content/QuitButton.qml b/examples/qtquick/animation/easing/content/QuitButton.qml new file mode 100644 index 0000000000..702b892d23 --- /dev/null +++ b/examples/qtquick/animation/easing/content/QuitButton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/qtquick/animation/easing/content/quit.png b/examples/qtquick/animation/easing/content/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/qtquick/animation/easing/content/quit.png differ diff --git a/examples/qtquick/animation/easing/easing.qml b/examples/qtquick/animation/easing/easing.qml new file mode 100644 index 0000000000..8977029fb3 --- /dev/null +++ b/examples/qtquick/animation/easing/easing.qml @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: window + width: 320; height: 480; color: "#232323" + + property var easingCurve: [ 0.2, 0.2, 0.13, 0.65, 0.2, 0.8, + 0.624, 0.98, 0.93, 0.95, 1, 1 ] + + ListModel { + id: easingTypes + ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" } + ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" } + ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" } + ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" } + ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" } + ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" } + ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" } + ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" } + ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" } + ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" } + ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" } + ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" } + ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" } + ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" } + ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" } + ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" } + ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" } + ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" } + ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" } + ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" } + ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" } + ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" } + ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" } + ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" } + ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" } + ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" } + ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" } + ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" } + ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" } + ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" } + ListElement { name: "Easing.OutElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } + ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" } + ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" } + ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" } + ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" } + ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" } + ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" } + ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" } + ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" } + ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" } + ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" } + ListElement { name: "Easing.Bezier"; type: Easing.Bezier; ballColor: "Chartreuse"; } + } + + Component { + id: delegate + + Item { + height: 56; width: window.width + + Text { text: name; anchors.centerIn: parent; color: "White" } + + Rectangle { + id: slot1; color: "#121212"; x: 30; height: 46; width: 46 + border.color: "#343434"; border.width: 1; radius: 12 + anchors.verticalCenter: parent.verticalCenter + } + + Rectangle { + id: slot2; color: "#121212"; x: window.width - 76; height: 46; width: 46 + border.color: "#343434"; border.width: 1; radius: 12 + anchors.verticalCenter: parent.verticalCenter + } + + Rectangle { + id: rect; x: 30; color: "#454545" + border.color: "White"; border.width: 2 + height: 46; width: 46; radius: 12 + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + onClicked: if (rect.state == '') rect.state = "right"; else rect.state = '' + anchors.fill: parent + anchors.margins: -5 // Make MouseArea bigger than the rectangle, itself + } + + states : State { + name: "right" + PropertyChanges { target: rect; x: window.width - 76; color: ballColor } + } + + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 } + ColorAnimation { properties: "color"; easing.type: type; easing.bezierCurve: getBezierCurve(name); duration: 1000 } + } + } + } + } + + Flickable { + anchors.fill: parent + contentHeight: layout.height + Column { + id: layout + Repeater { model: easingTypes; delegate: delegate } + } + } + + function getBezierCurve(name) + { + if (name === "Easing.Bezier") + return easingCurve; + return []; + } +} diff --git a/examples/qtquick/animation/main.cpp b/examples/qtquick/animation/main.cpp new file mode 100644 index 0000000000..799dfd7725 --- /dev/null +++ b/examples/qtquick/animation/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(animation) diff --git a/examples/qtquick/animation/pathanimation/pathanimation.qml b/examples/qtquick/animation/pathanimation/pathanimation.qml new file mode 100644 index 0000000000..f995218c6c --- /dev/null +++ b/examples/qtquick/animation/pathanimation/pathanimation.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: window + width: 320 + height: 480 + + Canvas { + id: canvas + anchors.fill: parent + smooth: true + + onPaint: { + var context = canvas.getContext("2d") + context.clearRect(0, 0, width, height) + context.strokeStyle = "black" + context.path = pathAnim.path + context.stroke() + } + } + + SequentialAnimation { + running: true + loops: -1 + + PauseAnimation { duration: 1000 } + PathAnimation { + id: pathAnim + + duration: 2000 + easing.type: Easing.InQuad + + target: box + orientation: PathAnimation.RightFirst + anchorPoint: Qt.point(box.width/2, box.height/2) + path: Path { + startX: 50; startY: 50 + + PathCubic { + x: window.width - 50 + y: window.height - 50 + + control1X: x; control1Y: 50 + control2X: 50; control2Y: y + } + + onChanged: canvas.requestPaint() + } + } + } + + Rectangle { + id: box + + x: 25; y: 25 + width: 50; height: 50 + border.width: 1 + smooth: true + + Text { + anchors.centerIn: parent + text: "Box" + } + } +} diff --git a/examples/qtquick/animation/pathinterpolator/pathinterpolator.qml b/examples/qtquick/animation/pathinterpolator/pathinterpolator.qml new file mode 100644 index 0000000000..5a137c732d --- /dev/null +++ b/examples/qtquick/animation/pathinterpolator/pathinterpolator.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: window + width: 320 + height: 480 + + Canvas { + id: canvas + anchors.fill: parent + smooth: true + + onPaint: { + var context = canvas.getContext("2d") + context.clearRect(0, 0, width, height) + context.strokeStyle = "black" + context.path = motionPath.path + context.stroke() + } + } + + PathInterpolator { + id: motionPath + + path: Path { + startX: 50; startY: 50 + + PathCubic { + x: window.width - 50 + y: window.height - 50 + + control1X: x; control1Y: 50 + control2X: 50; control2Y: y + } + + onChanged: canvas.requestPaint() + } + + SequentialAnimation on progress { + running: true + loops: -1 + PauseAnimation { duration: 1000 } + NumberAnimation { + id: progressAnim + running: false + from: 0; to: 1 + duration: 2000 + easing.type: Easing.InQuad + } + } + } + + Rectangle { + id: box + + width: 50; height: 50 + border.width: 1 + smooth: true + + //bind our attributes to follow the path as progress changes + x: motionPath.x + y: motionPath.y + rotation: motionPath.angle + transform: Translate { x: -box.width/2; y: -box.height/2 } + + Text { + anchors.centerIn: parent + text: "Box" + } + } + +} diff --git a/examples/qtquick/animation/states/qt-logo.png b/examples/qtquick/animation/states/qt-logo.png new file mode 100644 index 0000000000..14ddf2a028 Binary files /dev/null and b/examples/qtquick/animation/states/qt-logo.png differ diff --git a/examples/qtquick/animation/states/states.qml b/examples/qtquick/animation/states/states.qml new file mode 100644 index 0000000000..7ca56a9295 --- /dev/null +++ b/examples/qtquick/animation/states/states.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + width: 640; height: 480 + color: "#343434" + + Image { + id: userIcon + x: topLeftRect.x; y: topLeftRect.y + source: "qt-logo.png" + } + + Rectangle { + id: topLeftRect + + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to the default state, returning the image to + // its initial position + MouseArea { anchors.fill: parent; onClicked: page.state = '' } + } + + Rectangle { + id: middleRightRect + + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'middleRight' + MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } + } + + Rectangle { + id: bottomLeftRect + + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'bottomLeft' + MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } + } + + states: [ + // In state 'middleRight', move the image to middleRightRect + State { + name: "middleRight" + PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } + }, + + // In state 'bottomLeft', move the image to bottomLeftRect + State { + name: "bottomLeft" + PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } + } + ] +} diff --git a/examples/qtquick/animation/states/transitions.qml b/examples/qtquick/animation/states/transitions.qml new file mode 100644 index 0000000000..d57924d6d2 --- /dev/null +++ b/examples/qtquick/animation/states/transitions.qml @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +/* + This is exactly the same as states.qml, except that we have appended + a set of transitions to apply animations when the item changes + between each state. +*/ + +Rectangle { + id: page + width: 640; height: 480 + color: "#343434" + + Image { + id: userIcon + x: topLeftRect.x; y: topLeftRect.y + source: "qt-logo.png" + } + + Rectangle { + id: topLeftRect + + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to the default state, returning the image to + // its initial position + MouseArea { anchors.fill: parent; onClicked: page.state = '' } + } + + Rectangle { + id: middleRightRect + + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'middleRight' + MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } + } + + Rectangle { + id: bottomLeftRect + + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 46; height: 54 + color: "Transparent"; border.color: "Gray"; radius: 6 + + // Clicking in here sets the state to 'bottomLeft' + MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } + } + + states: [ + // In state 'middleRight', move the image to middleRightRect + State { + name: "middleRight" + PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } + }, + + // In state 'bottomLeft', move the image to bottomLeftRect + State { + name: "bottomLeft" + PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } + } + ] + + // Transitions define how the properties change when the item moves between each state + transitions: [ + + // When transitioning to 'middleRight' move x,y over a duration of 1 second, + // with OutBounce easing function. + Transition { + from: "*"; to: "middleRight" + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 } + }, + + // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds, + // with InOutQuad easing function. + Transition { + from: "*"; to: "bottomLeft" + NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 } + }, + + // For any other state changes move x,y linearly over duration of 200ms. + Transition { + NumberAnimation { properties: "x,y"; duration: 200 } + } + ] +} diff --git a/examples/qtquick/canvas/bezierCurve/bezierCurve.qml b/examples/qtquick/canvas/bezierCurve/bezierCurve.qml new file mode 100644 index 0000000000..f57839b0a5 --- /dev/null +++ b/examples/qtquick/canvas/bezierCurve/bezierCurve.qml @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Bezier Curve"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + property string strokeStyle:"red" + property string fillStyle:"red" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + + Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } + Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onAlphaChanged:requestPaint(); + onScaleXChanged:requestPaint(); + onScaleYChanged:requestPaint(); + onRotateChanged:requestPaint(); + + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.beginPath(); + ctx.moveTo(75,40); + ctx.bezierCurveTo(75,37,70,25,50,25); + ctx.bezierCurveTo(20,25,20,62.5,20,62.5); + ctx.bezierCurveTo(20,80,40,102,75,120); + ctx.bezierCurveTo(110,102,130,80,130,62.5); + ctx.bezierCurveTo(130,62.5,130,25,100,25); + ctx.bezierCurveTo(85,25,75,37,75,40); + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qtquick/canvas/clip/clip.qml b/examples/qtquick/canvas/clip/clip.qml new file mode 100644 index 0000000000..d861ff0a46 --- /dev/null +++ b/examples/qtquick/canvas/clip/clip.qml @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Makes squircle icon with clip"; anchors.horizontalCenter:parent.horizontalCenter} + Canvas { + id:canvas + width:360 + height:360 + property string strokeStyle:"blue" + property string fillStyle:"steelblue" + property int lineWidth:2 + property int nSize:nCtrl.value + property real radius:rCtrl.value + property bool fill:true + property bool stroke:false + property real px:xCtrl.value + property real py:yCtrl.value + property real alpha:alphaCtrl.value + property string imagefile:"../contents/qt-logo.png" + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + Component.onCompleted:loadImage(canvas.imagefile); + + onAlphaChanged:requestPaint(); + onRadiusChanged:requestPaint(); + onLineWidthChanged:requestPaint(); + onNSizeChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onPxChanged:requestPaint(); + onPyChanged:requestPaint(); + + onImageLoaded : requestPaint(); + + onPaint: squcirle(); + + function squcirle() { + var ctx = canvas.getContext("2d"); + var N = canvas.nSize; + var R = canvas.radius; + + N=Math.abs(N); + var M=N; + if (N>100) M=100; + if (N<0.00000000001) M=0.00000000001; + + ctx.save(); + ctx.globalAlpha =canvas.alpha; + ctx.fillStyle = "gray"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + + ctx.beginPath(); + var i = 0, x, y; + for (i=0; i<(2*R+1); i++){ + x = Math.round(i-R) + canvas.px; + y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py; + + if (i == 0) + ctx.moveTo(x, y); + else + ctx.lineTo(x, y); + } + + for (i=(2*R); i<(4*R+1); i++){ + x =Math.round(3*R-i)+canvas.px; + y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py; + ctx.lineTo(x, y); + } + ctx.closePath(); + if (canvas.stroke) { + ctx.stroke(); + } + + if (canvas.fill) { + ctx.fill(); + } + ctx.clip(); + + ctx.drawImage(canvas.imagefile, 0, 0); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"} + Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"} + Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"} + Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qtquick/canvas/contents/Button.qml b/examples/qtquick/canvas/contents/Button.qml new file mode 100644 index 0000000000..1413cdb9fa --- /dev/null +++ b/examples/qtquick/canvas/contents/Button.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: container + + signal clicked + + property string text + width: buttonText.width + 28 + height: buttonText.height + 14 + + BorderImage { + id: buttonImage + source: "images/toolbutton.sci" + width: container.width - 10 + height: container.height + } + BorderImage { + id: pressed + opacity: 0 + source: "images/toolbutton.sci" + width: container.width - 10 + height: container.height + } + MouseArea { + id: mouseRegion + anchors.fill: buttonImage + onClicked: { container.clicked(); } + } + Text { + id: buttonText + color: "white" + anchors.centerIn: buttonImage + font.bold: true + font.pointSize: 15 + text: container.text + style: Text.Raised + styleColor: "black" + } + states: [ + State { + name: "Pressed" + when: mouseRegion.pressed == true + PropertyChanges { target: pressed; opacity: 1 } + } + ] +} \ No newline at end of file diff --git a/examples/qtquick/canvas/contents/ScrollBar.qml b/examples/qtquick/canvas/contents/ScrollBar.qml new file mode 100644 index 0000000000..98b8efee4a --- /dev/null +++ b/examples/qtquick/canvas/contents/ScrollBar.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt Mobility Components. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: scrollBar + // The properties that define the scrollbar's state. + // position and pageSize are in the range 0.0 - 1.0. They are relative to the + // height of the page, i.e. a pageSize of 0.5 means that you can see 50% + // of the height of the view. + // orientation can be either 'Vertical' or 'Horizontal' + property real position + property real pageSize + property string orientation : "Vertical" + property alias bgColor: background.color + property alias fgColor: thumb.color + + // A light, semi-transparent background + Rectangle { + id: background + radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) + color: "white"; opacity: 0.3 + anchors.fill: parent + } + // Size the bar to the required size, depending upon the orientation. + Rectangle { + id: thumb + opacity: 0.7 + color: "black" + radius: orientation == 'Vertical' ? (width/2 - 1) : (height/2 - 1) + x: orientation == 'Vertical' ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) + y: orientation == 'Vertical' ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 + width: orientation == 'Vertical' ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) + height: orientation == 'Vertical' ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) + } +} diff --git a/examples/qtquick/canvas/contents/Slider.qml b/examples/qtquick/canvas/contents/Slider.qml new file mode 100644 index 0000000000..1050e307f6 --- /dev/null +++ b/examples/qtquick/canvas/contents/Slider.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id:slider + property real min:0 + property real max:1 + property real value: min + (max - min) * (bar.x / (foo.width - bar.width)) + property real init:min+(max-min)/2 + property string name:"Slider" + + Component.onCompleted: setValue(init) + function setValue(v) { + if (min < max) + bar.x = v/(max - min) * (foo.width - bar.width); + } + Rectangle { + id:sliderName + anchors.left:parent.left + height: childrenRect.height + width:childrenRect.width + anchors.verticalCenter:parent.verticalCenter + Text { + text:slider.name + font.pointSize:12 + } + } + Item { + id: foo + height: 6 + width: parent.width - 4 - sliderName.width + anchors.verticalCenter:parent.verticalCenter + anchors.left:sliderName.right + anchors.leftMargin:5 + Rectangle { + height: parent.height + anchors.left: parent.left + anchors.right: bar.horizontalCenter + color: "blue" + radius: 3 + } + Rectangle { + height: parent.height + anchors.left: bar.horizontalCenter + anchors.right: parent.right + color: "gray" + radius: 3 + } + Rectangle { + anchors.fill: parent + color: "transparent" + radius: 3 + border.width: 2 + border.color: "black" + } + + Rectangle { + id: bar + y: -7 + width: 20 + height: 20 + radius: 15 + color: "white" + border.width: 2 + border.color: "black" + MouseArea { + anchors.fill: parent + drag.target: parent + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: foo.width - parent.width + } + } + } +} diff --git a/examples/qtquick/canvas/contents/Stocks.qml b/examples/qtquick/canvas/contents/Stocks.qml new file mode 100644 index 0000000000..043bca132e --- /dev/null +++ b/examples/qtquick/canvas/contents/Stocks.qml @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + id:stocks + //Data from : http://en.wikipedia.org/wiki/NASDAQ-100 + + ListElement {name:"Activision Blizzard"; stockId:"ATVI"} + ListElement {name:"Adobe Systems Incorporated"; stockId:"ADBE"} + ListElement {name:"Akamai Technologies, Inc"; stockId:"AKAM"} + ListElement {name:"Alexion Pharmaceuticals"; stockId:"ALXN"} + ListElement {name:"Altera Corporation"; stockId:"ALTR"} + ListElement {name:"Amazon.com, Inc."; stockId:"AMZN"} + ListElement {name:"Amgen Inc."; stockId:"AMGN"} + ListElement {name:"Apollo Group, Inc."; stockId:"APOL"} + ListElement {name:"Apple Inc."; stockId:"AAPL"} + ListElement {name:"Applied Materials, Inc."; stockId:"AMAT"} + ListElement {name:"Autodesk, Inc."; stockId:"ADSK"} + ListElement {name:"Automatic Data Processing, Inc."; stockId:"ADP"} + ListElement {name:"Baidu.com, Inc."; stockId:"BIDU"} + ListElement {name:"Bed Bath & Beyond Inc."; stockId:"BBBY"} + ListElement {name:"Biogen Idec, Inc"; stockId:"BIIB"} + ListElement {name:"BMC Software, Inc."; stockId:"BMC"} + ListElement {name:"Broadcom Corporation"; stockId:"BRCM"} + ListElement {name:"C. H. Robinson Worldwide, Inc."; stockId:"CHRW"} + ListElement {name:"CA, Inc."; stockId:"CA"} + ListElement {name:"Celgene Corporation"; stockId:"CELG"} + ListElement {name:"Cephalon, Inc."; stockId:"CEPH"} + ListElement {name:"Cerner Corporation"; stockId:"CERN"} + ListElement {name:"Check Point Software Technologies Ltd."; stockId:"CHKP"} + ListElement {name:"Cisco Systems, Inc."; stockId:"CSCO"} + ListElement {name:"Citrix Systems, Inc."; stockId:"CTXS"} + ListElement {name:"Cognizant Technology Solutions Corporation"; stockId:"CTSH"} + ListElement {name:"Comcast Corporation"; stockId:"CMCSA"} + ListElement {name:"Costco Wholesale Corporation"; stockId:"COST"} + ListElement {name:"Ctrip.com International, Ltd."; stockId:"CTRP"} + ListElement {name:"Dell Inc."; stockId:"DELL"} + ListElement {name:"DENTSPLY International Inc."; stockId:"XRAY"} + ListElement {name:"DirecTV"; stockId:"DTV"} + ListElement {name:"Dollar Tree, Inc."; stockId:"DLTR"} + ListElement {name:"eBay Inc."; stockId:"EBAY"} + ListElement {name:"Electronic Arts Inc."; stockId:"ERTS"} + ListElement {name:"Expedia, Inc."; stockId:"EXPE"} + ListElement {name:"Expeditors International of Washington, Inc."; stockId:"EXPD"} + ListElement {name:"Express Scripts, Inc."; stockId:"ESRX"} + ListElement {name:"F5 Networks, Inc."; stockId:"FFIV"} + ListElement {name:"Fastenal Company"; stockId:"FAST"} + ListElement {name:"First Solar, Inc."; stockId:"FSLR"} + ListElement {name:"Fiserv, Inc."; stockId:"FISV"} + ListElement {name:"Flextronics International Ltd."; stockId:"FLEX"} + ListElement {name:"FLIR Systems, Inc."; stockId:"FLIR"} + ListElement {name:"Garmin Ltd."; stockId:"GRMN"} + ListElement {name:"Gilead Sciences, Inc."; stockId:"GILD"} + ListElement {name:"Google Inc."; stockId:"GOOG"} + ListElement {name:"Green Mountain Coffee Roasters, Inc."; stockId:"GMCR"} + ListElement {name:"Henry Schein, Inc."; stockId:"HSIC"} + ListElement {name:"Illumina, Inc."; stockId:"ILMN"} + ListElement {name:"Infosys Technologies"; stockId:"INFY"} + ListElement {name:"Intel Corporation"; stockId:"INTC"} + ListElement {name:"Intuit, Inc."; stockId:"INTU"} + ListElement {name:"Intuitive Surgical Inc."; stockId:"ISRG"} + ListElement {name:"Joy Global Inc."; stockId:"JOYG"} + ListElement {name:"KLA Tencor Corporation"; stockId:"KLAC"} + ListElement {name:"Lam Research Corporation"; stockId:"LRCX"} + ListElement {name:"Liberty Media Corporation, Interactive Series A"; stockId:"LINTA"} + ListElement {name:"Life Technologies Corporation"; stockId:"LIFE"} + ListElement {name:"Linear Technology Corporation"; stockId:"LLTC"} + ListElement {name:"Marvell Technology Group, Ltd."; stockId:"MRVL"} + ListElement {name:"Mattel, Inc."; stockId:"MAT"} + ListElement {name:"Maxim Integrated Products"; stockId:"MXIM"} + ListElement {name:"Microchip Technology Incorporated"; stockId:"MCHP"} + ListElement {name:"Micron Technology, Inc."; stockId:"MU"} + ListElement {name:"Microsoft Corporation"; stockId:"MSFT"} + ListElement {name:"Mylan, Inc."; stockId:"MYL"} + ListElement {name:"NetApp, Inc."; stockId:"NTAP"} + ListElement {name:"Netflix, Inc."; stockId:"NFLX"} + ListElement {name:"News Corporation, Ltd."; stockId:"NWSA"} + ListElement {name:"NII Holdings, Inc."; stockId:"NIHD"} + ListElement {name:"NVIDIA Corporation"; stockId:"NVDA"} + ListElement {name:"O'Reilly Automotive, Inc."; stockId:"ORLY"} + ListElement {name:"Oracle Corporation"; stockId:"ORCL"} + ListElement {name:"PACCAR Inc."; stockId:"PCAR"} + ListElement {name:"Paychex, Inc."; stockId:"PAYX"} + ListElement {name:"Priceline.com, Incorporated"; stockId:"PCLN"} + ListElement {name:"Qiagen N.V."; stockId:"QGEN"} + ListElement {name:"QUALCOMM Incorporated"; stockId:"QCOM"} + ListElement {name:"Research in Motion Limited"; stockId:"RIMM"} + ListElement {name:"Ross Stores Inc."; stockId:"ROST"} + ListElement {name:"SanDisk Corporation"; stockId:"SNDK"} + ListElement {name:"Seagate Technology Holdings"; stockId:"STX"} + ListElement {name:"Sears Holdings Corporation"; stockId:"SHLD"} + ListElement {name:"Sigma-Aldrich Corporation"; stockId:"SIAL"} + ListElement {name:"Staples Inc."; stockId:"SPLS"} + ListElement {name:"Starbucks Corporation"; stockId:"SBUX"} + ListElement {name:"Stericycle, Inc"; stockId:"SRCL"} + ListElement {name:"Symantec Corporation"; stockId:"SYMC"} + ListElement {name:"Teva Pharmaceutical Industries Ltd."; stockId:"TEVA"} + ListElement {name:"Urban Outfitters, Inc."; stockId:"URBN"} + ListElement {name:"VeriSign, Inc."; stockId:"VRSN"} + ListElement {name:"Vertex Pharmaceuticals"; stockId:"VRTX"} + ListElement {name:"Virgin Media, Inc."; stockId:"VMED"} + ListElement {name:"Vodafone Group, plc."; stockId:"VOD"} + ListElement {name:"Warner Chilcott, Ltd."; stockId:"WCRX"} + ListElement {name:"Whole Foods Market, Inc."; stockId:"WFM"} + ListElement {name:"Wynn Resorts Ltd."; stockId:"WYNN"} + ListElement {name:"Xilinx, Inc."; stockId:"XLNX"} + ListElement {name:"Yahoo! Inc."; stockId:"YHOO"} +} diff --git a/examples/qtquick/canvas/contents/TitleBar.qml b/examples/qtquick/canvas/contents/TitleBar.qml new file mode 100644 index 0000000000..28edda2ae7 --- /dev/null +++ b/examples/qtquick/canvas/contents/TitleBar.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: titleBar + property string title: "" + + BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } + + Image { + id: quitButton + anchors.left: parent.left//; anchors.leftMargin: 0 + anchors.verticalCenter: parent.verticalCenter + source: "images/quit.png" + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + } + + Text { + id: categoryText + anchors { + left: quitButton.right; right: parent.right; //leftMargin: 10; rightMargin: 10 + verticalCenter: parent.verticalCenter + } + elide: Text.ElideLeft + text: title + font.bold: true; font.pointSize: 20; color: "White"; style: Text.Raised; styleColor: "Black" + } +} diff --git a/examples/qtquick/canvas/contents/ToolBar.qml b/examples/qtquick/canvas/contents/ToolBar.qml new file mode 100644 index 0000000000..7ae7391ddf --- /dev/null +++ b/examples/qtquick/canvas/contents/ToolBar.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: toolbar + + property variant labels + signal buttonClicked(int index) + + BorderImage { + source: "images/titlebar.sci" + width: parent.width + height: parent.height + 14 + y: -7 + } + + Row { + y: 3 + anchors.horizontalCenter: parent.horizontalCenter + Repeater { + model: toolbar.labels + delegate: + Button { + text: modelData + onClicked: toolbar.buttonClicked(model.index) + } + } + } + +} diff --git a/examples/qtquick/canvas/contents/images/button-pressed.png b/examples/qtquick/canvas/contents/images/button-pressed.png new file mode 100644 index 0000000000..e434d327f2 Binary files /dev/null and b/examples/qtquick/canvas/contents/images/button-pressed.png differ diff --git a/examples/qtquick/canvas/contents/images/button.png b/examples/qtquick/canvas/contents/images/button.png new file mode 100644 index 0000000000..56a63ce641 Binary files /dev/null and b/examples/qtquick/canvas/contents/images/button.png differ diff --git a/examples/qtquick/canvas/contents/images/default.svg b/examples/qtquick/canvas/contents/images/default.svg new file mode 100644 index 0000000000..248199cc4e --- /dev/null +++ b/examples/qtquick/canvas/contents/images/default.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + weather-clear + January 2006 + + + Ryan Collier (pseudo) + + + + + http://www.tango-project.org + + + http://www.pseudocode.org + + + weather + applet + notification + + + + + + Garrett LeSage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/qtquick/canvas/contents/images/gloss.png b/examples/qtquick/canvas/contents/images/gloss.png new file mode 100755 index 0000000000..5d370cd93d Binary files /dev/null and b/examples/qtquick/canvas/contents/images/gloss.png differ diff --git a/examples/qtquick/canvas/contents/images/lineedit.png b/examples/qtquick/canvas/contents/images/lineedit.png new file mode 100755 index 0000000000..2cc38dc35b Binary files /dev/null and b/examples/qtquick/canvas/contents/images/lineedit.png differ diff --git a/examples/qtquick/canvas/contents/images/lineedit.sci b/examples/qtquick/canvas/contents/images/lineedit.sci new file mode 100644 index 0000000000..054bff78be --- /dev/null +++ b/examples/qtquick/canvas/contents/images/lineedit.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 10 +border.bottom: 10 +border.right: 10 +source: lineedit.png diff --git a/examples/qtquick/canvas/contents/images/quit.png b/examples/qtquick/canvas/contents/images/quit.png new file mode 100755 index 0000000000..5bda1b6e0d Binary files /dev/null and b/examples/qtquick/canvas/contents/images/quit.png differ diff --git a/examples/qtquick/canvas/contents/images/stripes.png b/examples/qtquick/canvas/contents/images/stripes.png new file mode 100755 index 0000000000..9f36727ea4 Binary files /dev/null and b/examples/qtquick/canvas/contents/images/stripes.png differ diff --git a/examples/qtquick/canvas/contents/images/titlebar.png b/examples/qtquick/canvas/contents/images/titlebar.png new file mode 100755 index 0000000000..51c90082d0 Binary files /dev/null and b/examples/qtquick/canvas/contents/images/titlebar.png differ diff --git a/examples/qtquick/canvas/contents/images/titlebar.sci b/examples/qtquick/canvas/contents/images/titlebar.sci new file mode 100644 index 0000000000..0418d94cd6 --- /dev/null +++ b/examples/qtquick/canvas/contents/images/titlebar.sci @@ -0,0 +1,5 @@ +border.left: 10 +border.top: 12 +border.bottom: 12 +border.right: 10 +source: titlebar.png diff --git a/examples/qtquick/canvas/contents/images/toolbutton.png b/examples/qtquick/canvas/contents/images/toolbutton.png new file mode 100755 index 0000000000..11310013ee Binary files /dev/null and b/examples/qtquick/canvas/contents/images/toolbutton.png differ diff --git a/examples/qtquick/canvas/contents/images/toolbutton.sci b/examples/qtquick/canvas/contents/images/toolbutton.sci new file mode 100644 index 0000000000..9e4f965307 --- /dev/null +++ b/examples/qtquick/canvas/contents/images/toolbutton.sci @@ -0,0 +1,5 @@ +border.left: 15 +border.top: 4 +border.bottom: 4 +border.right: 15 +source: toolbutton.png diff --git a/examples/qtquick/canvas/contents/qt-logo.png b/examples/qtquick/canvas/contents/qt-logo.png new file mode 100644 index 0000000000..5ab3a1b0c4 Binary files /dev/null and b/examples/qtquick/canvas/contents/qt-logo.png differ diff --git a/examples/qtquick/canvas/quadraticCurveTo/quadraticCurveTo.qml b/examples/qtquick/canvas/quadraticCurveTo/quadraticCurveTo.qml new file mode 100644 index 0000000000..bc3ca0071a --- /dev/null +++ b/examples/qtquick/canvas/quadraticCurveTo/quadraticCurveTo.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Quadratic Curve"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + property string strokeStyle:"steelblue" + property string fillStyle:"yellow" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onAlphaChanged:requestPaint(); + onScaleXChanged:requestPaint(); + onScaleYChanged:requestPaint(); + onRotateChanged:requestPaint(); + Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } + Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.beginPath(); + ctx.moveTo(75,25); + ctx.quadraticCurveTo(25,25,25,62.5); + ctx.quadraticCurveTo(25,100,50,100); + ctx.quadraticCurveTo(50,120,30,125); + ctx.quadraticCurveTo(60,120,65,100); + ctx.quadraticCurveTo(125,100,125,62.5); + ctx.quadraticCurveTo(125,25,75,25); + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + + + ctx.fillStyle="green"; + ctx.font = "Bold 15px"; + + ctx.fillText("QML酷毙了", 30, 60); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qtquick/canvas/roundedrect/roundedrect.qml b/examples/qtquick/canvas/roundedrect/roundedrect.qml new file mode 100644 index 0000000000..fd86c63a3b --- /dev/null +++ b/examples/qtquick/canvas/roundedrect/roundedrect.qml @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Rounded rectangle"; anchors.horizontalCenter:parent.horizontalCenter} + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + property int radius: rCtrl.value + property int rectx: rxCtrl.value + property int recty: ryCtrl.value + property int rectWidth: width - 2*rectx + property int rectHeight: height - 2*recty + property string strokeStyle:"blue" + property string fillStyle:"steelblue" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onRadiusChanged:requestPaint(); + onRectxChanged:requestPaint(); + onRectyChanged:requestPaint(); + onAlphaChanged:requestPaint(); + + onPaint: { + var ctx = getContext("2d"); + ctx.save(); + ctx.clearRect(0,0,canvas.width, canvas.height); + ctx.strokeStyle = canvas.strokeStyle; + ctx.lineWidth = canvas.lineWidth + ctx.fillStyle = canvas.fillStyle + ctx.globalAlpha = canvas.alpha + ctx.beginPath(); + ctx.moveTo(rectx+radius,recty); // top side + ctx.lineTo(rectx+rectWidth-radius,recty); + // draw top right corner + ctx.arcTo(rectx+rectWidth,recty,rectx+rectWidth,recty+radius,radius); + ctx.lineTo(rectx+rectWidth,recty+rectHeight-radius); // right side + // draw bottom right corner + ctx.arcTo(rectx+rectWidth,recty+rectHeight,rectx+rectWidth-radius,recty+rectHeight,radius); + ctx.lineTo(rectx+radius,recty+rectHeight); // bottom side + // draw bottom left corner + ctx.arcTo(rectx,recty+rectHeight,rectx,recty+rectHeight-radius,radius); + ctx.lineTo(rectx,recty+radius); // left side + // draw top left corner + ctx.arcTo(rectx,recty,rectx+radius,recty,radius); + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:rxCtrl; width:300; height:30; min:5; max:30; init:10; name:"rectx"} + Slider {id:ryCtrl; width:300; height:30; min:5; max:30; init:10; name:"recty"} + Slider {id:rCtrl; width:300; height:30; min:10; max:100; init:40; name:"Radius"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qtquick/canvas/smile/smile.qml b/examples/qtquick/canvas/smile/smile.qml new file mode 100644 index 0000000000..28a48a6c81 --- /dev/null +++ b/examples/qtquick/canvas/smile/smile.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Smile with arcs"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + property string strokeStyle:"green" + property string fillStyle:"yellow" + property int lineWidth:lineWidthCtrl.value + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + + onLineWidthChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onAlphaChanged:requestPaint(); + onScaleXChanged:requestPaint(); + onScaleYChanged:requestPaint(); + onRotateChanged:requestPaint(); + + Behavior on scaleX { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite } } + Behavior on scaleY { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + Behavior on rotate { SpringAnimation { spring: 2; damping: 0.2; loops:Animation.Infinite} } + + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.beginPath(); + ctx.moveTo(75 + 50 * Math.cos(0), + 75 - 50 * Math.sin(Math.PI*2)); + ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle + ctx.moveTo(75,70); + ctx.arc(75,70,35,0,Math.PI,false); // Mouth (clockwise) + ctx.moveTo(60,65); + ctx.arc(60,65,5,0,Math.PI*2,true); // Left eye + ctx.moveTo(90 + 5 * Math.cos(0), + 65 - 5 * Math.sin(Math.PI*2)); + ctx.moveTo(90,65); + ctx.arc(90,65,5,0,Math.PI*2,true); // Right eye + ctx.closePath(); + if (canvas.fill) + ctx.fill(); + if (canvas.stroke) + ctx.stroke(); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:lineWidthCtrl; width:300; height:30; min:1; max:10; init:2; name:"Line width"} + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:1; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qtquick/canvas/squircle/squircle.png b/examples/qtquick/canvas/squircle/squircle.png new file mode 100644 index 0000000000..86c69d945f Binary files /dev/null and b/examples/qtquick/canvas/squircle/squircle.png differ diff --git a/examples/qtquick/canvas/squircle/squircle.qml b/examples/qtquick/canvas/squircle/squircle.qml new file mode 100644 index 0000000000..2fc65b67b3 --- /dev/null +++ b/examples/qtquick/canvas/squircle/squircle.qml @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Squircles"; anchors.horizontalCenter:parent.horizontalCenter} + Image { + anchors.horizontalCenter:parent.horizontalCenter + source:"squircle.png" + width:250 + height:25 + } + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.Image + renderStrategy: Canvas.Immediate + + property string strokeStyle:"blue" + property string fillStyle:"steelblue" + property int lineWidth:2 + property int nSize:nCtrl.value + property real radius:rCtrl.value + property bool fill:true + property bool stroke:false + property real px:xCtrl.value + property real py:yCtrl.value + property real alpha:alphaCtrl.value + + onAlphaChanged:requestPaint(); + onRadiusChanged:requestPaint(); + onLineWidthChanged:requestPaint(); + onNSizeChanged:requestPaint(); + onFillChanged:requestPaint(); + onStrokeChanged:requestPaint(); + onPxChanged:requestPaint(); + onPyChanged:requestPaint(); + + + onPaint: squcirle(); + + function squcirle() { + var ctx = canvas.getContext("2d"); + var N = canvas.nSize; + var R = canvas.radius; + + N=Math.abs(N); + var M=N; + if (N>100) M=100; + if (N<0.00000000001) M=0.00000000001; + + ctx.save(); + ctx.globalAlpha =canvas.alpha; + ctx.fillStyle = "gray"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + + ctx.strokeStyle = canvas.strokeStyle; + ctx.fillStyle = canvas.fillStyle; + ctx.lineWidth = canvas.lineWidth; + + ctx.beginPath(); + var i = 0, x, y; + for (i=0; i<(2*R+1); i++){ + x = Math.round(i-R) + canvas.px; + y = Math.round(Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(i-R),M)),1/M)) + canvas.py; + + if (i == 0) + ctx.moveTo(x, y); + else + ctx.lineTo(x, y); + } + + for (i=(2*R); i<(4*R+1); i++){ + x =Math.round(3*R-i)+canvas.px; + y = Math.round(-Math.pow(Math.abs(Math.pow(R,M)-Math.pow(Math.abs(3*R-i),M)),1/M)) + canvas.py; + ctx.lineTo(x, y); + } + ctx.closePath(); + if (canvas.stroke) { + ctx.stroke(); + } + + if (canvas.fill) { + ctx.fill(); + } + + ctx.fillStyle = "yellow"; + ctx.font = "Helvetica 16px"; + ctx.fillText("|X-" + Math.round(canvas.px) + "|^" + N + " + |Y-"+Math.round(canvas.py)+"|^" + N + " = |" + Math.round(R) + "|^" + N, canvas.px - 125, canvas.py); + ctx.restore(); + } + } + + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:nCtrl; width:300; height:30; min:1; max:10; init:4; name:"N"} + Slider {id:rCtrl; width:300; height:30; min:30; max:180; init:100; name:"Radius"} + Slider {id:xCtrl; width:300; height:30; min:50; max:300; init:180; name:"X"} + Slider {id:yCtrl; width:300; height:30; min:30; max:300; init:220; name:"Y"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qtquick/canvas/stockchart/README b/examples/qtquick/canvas/stockchart/README new file mode 100644 index 0000000000..2652866ed6 --- /dev/null +++ b/examples/qtquick/canvas/stockchart/README @@ -0,0 +1,5 @@ +To run: + + make install + QML_IMPORT_PATH=$PWD qmlscene stock.qml + diff --git a/examples/qtquick/canvas/stockchart/com/nokia/StockChartExample/qmldir b/examples/qtquick/canvas/stockchart/com/nokia/StockChartExample/qmldir new file mode 100644 index 0000000000..4c60e556d4 --- /dev/null +++ b/examples/qtquick/canvas/stockchart/com/nokia/StockChartExample/qmldir @@ -0,0 +1 @@ +plugin qmlstockchartexampleplugin diff --git a/examples/qtquick/canvas/stockchart/model.cpp b/examples/qtquick/canvas/stockchart/model.cpp new file mode 100644 index 0000000000..42eb2d592f --- /dev/null +++ b/examples/qtquick/canvas/stockchart/model.cpp @@ -0,0 +1,255 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "model.h" + +#include +#include +#include +#include +#include + +#include +#include + +StockModel::StockModel(QObject *parent) + : QAbstractListModel(parent) + , _startDate(QDate(1995, 4, 25)) + , _endDate(QDate::currentDate()) + , _dataCycle(StockModel::Daily) + , _manager(0) + , _updating(false) +{ + QHash roles; + roles[StockModel::DateRole] = "date"; + roles[StockModel::SectionRole] = "year"; + roles[StockModel::OpenPriceRole] = "openPrice"; + roles[StockModel::ClosePriceRole] = "closePrice"; + roles[StockModel::HighPriceRole] = "highPrice"; + roles[StockModel::LowPriceRole] = "lowPrice"; + roles[StockModel::VolumeRole] = "volume"; + roles[StockModel::AdjustedPriceRole] = "adjustedPrice"; + setRoleNames(roles); + + connect(this, SIGNAL(stockNameChanged()), SLOT(requestData())); + connect(this, SIGNAL(startDateChanged()), SLOT(requestData())); + connect(this, SIGNAL(endDateChanged()), SLOT(requestData())); + connect(this, SIGNAL(dataCycleChanged()), SLOT(requestData())); + + _manager = new QNetworkAccessManager(this); + connect(_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(update(QNetworkReply*))); + +} + +int StockModel::rowCount(const QModelIndex & parent) const { + Q_UNUSED(parent); + return _prices.count(); +} + +StockPrice* StockModel::stockPriceAtIndex(int idx) const +{ + if (idx >=0 && idx < _prices.size()) { + return _prices[idx]; + } + return 0; +} + + +void StockModel::requestData() +{ + if (!_updating) { + _updating = true; + QMetaObject::invokeMethod(this, "doRequest", Qt::QueuedConnection); + } +} + +void StockModel::doRequest() +{ + /* + Fetch stock data from yahoo finance: + url: http://ichart.finance.yahoo.com/table.csv?s=NOK&a=5&b=11&c=2010&d=7&e=23&f=2010&g=d&ignore=.csv + s:stock name/id, a:start day, b:start month, c:start year default: 25 April 1995, oldest c= 1962 + d:end day, e:end month, f:end year, default:today (data only available 3 days before today) + g:data cycle(d daily, w weekly, m monthly, v Dividend) + */ + if (_manager && !_stockName.isEmpty() && _endDate > _startDate) { + QString query("http://ichart.finance.yahoo.com/table.csv?s=%1&a=%2&b=%3&c=%4&d=%5&e=%6&f=%7&g=%8&ignore=.csv"); + query = query.arg(_stockName) + .arg(_startDate.day()).arg(_startDate.month()).arg(_startDate.year()) + .arg(_endDate.day()).arg(_endDate.month()).arg(_endDate.year()) + .arg(dataCycleString()); + + qDebug() << "request stock data:" << query; + QNetworkReply* reply = _manager->get(QNetworkRequest(QUrl(query))); + connect(reply, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(downloadProgress(qint64,qint64))); + } +} + +void StockModel::update(QNetworkReply *reply) +{ + _updating = false; + + if (reply) { + if (reply->error() == QNetworkReply::NoError) { + beginResetModel(); + + foreach (StockPrice* p, _prices) { + p->deleteLater(); + } + + _prices.clear(); + + while (!reply->atEnd()) { + QString line = reply->readLine(); + QStringList fields = line.split(','); + + //data format:Date,Open,High,Low,Close,Volume,Adjusted close price + //example: 2011-06-24,6.03,6.04,5.88,5.88,20465200,5.88 + if (fields.size() == 7) { + StockPrice* price = new StockPrice(this); + price->setDate(QDate::fromString(fields[0], Qt::ISODate)); + price->setOpenPrice(fields[1].toFloat()); + price->setHighPrice(fields[2].toFloat()); + price->setLowPrice(fields[3].toFloat()); + price->setClosePrice(fields[4].toFloat()); + price->setVolume(fields[5].toInt()); + price->setAdjustedPrice(fields[6].toFloat()); + _prices.prepend(price); + } + } + qDebug() << "get stock data successfully, total:" << _prices.count() << "records."; + } else { + qDebug() << "get stock data failed:" << reply->errorString(); + } + reply->deleteLater(); + endResetModel(); + emit dataChanged(QModelIndex(), QModelIndex()); + } +} + +QVariant StockModel::data(const QModelIndex & index, int role) const { + if (index.row() < 0 || index.row() > _prices.count()) + return QVariant(); + + const StockPrice* price = _prices[index.row()]; + if (role == StockModel::DateRole) + return price->date(); + else if (role == StockModel::OpenPriceRole) + return price->openPrice(); + else if (role == StockModel::ClosePriceRole) + return price->closePrice(); + else if (role == StockModel::HighPriceRole) + return price->highPrice(); + else if (role == StockModel::LowPriceRole) + return price->lowPrice(); + else if (role == StockModel::AdjustedPriceRole) + return price->adjustedPrice(); + else if (role == StockModel::VolumeRole) + return price->volume(); + else if (role == StockModel::SectionRole) + return price->date().year(); + return QVariant(); +} + +QString StockModel::stockName() const +{ + return _stockName; +} +void StockModel::setStockName(const QString& name) +{ + if (_stockName != name) { + _stockName = name; + emit stockNameChanged(); + } +} + +QDate StockModel::startDate() const +{ + return _startDate; +} +void StockModel::setStartDate(const QDate& date) +{ + if (_startDate.isValid() && _startDate != date) { + _startDate = date; + emit startDateChanged(); + } +} + +QDate StockModel::endDate() const +{ + return _endDate; +} +void StockModel::setEndDate(const QDate& date) +{ + if (_endDate.isValid() && _endDate != date) { + _endDate = date; + emit endDateChanged(); + } +} + +StockModel::StockDataCycle StockModel::dataCycle() const +{ + return _dataCycle; +} + +QString StockModel::dataCycleString() const +{ + switch (_dataCycle) { + case StockModel::Daily: + return QString('d'); + break; + case StockModel::Weekly: + return QString('w'); + case StockModel::Monthly: + return QString('m'); + case StockModel::Dividend: + return QString('v'); + } + + return QString('d'); +} + + +void StockModel::setDataCycle(StockModel::StockDataCycle cycle) +{ + if (_dataCycle != cycle) { + _dataCycle = cycle; + emit dataCycleChanged(); + } +} diff --git a/examples/qtquick/canvas/stockchart/model.h b/examples/qtquick/canvas/stockchart/model.h new file mode 100644 index 0000000000..95e6f4891c --- /dev/null +++ b/examples/qtquick/canvas/stockchart/model.h @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +class StockPrice : public QObject +{ + Q_OBJECT + Q_PROPERTY(QDate date READ date) + Q_PROPERTY(qreal openPrice READ openPrice) + Q_PROPERTY(qreal closePrice READ closePrice) + Q_PROPERTY(qreal highPrice READ highPrice) + Q_PROPERTY(qreal lowPrice READ lowPrice) + Q_PROPERTY(qint32 volume READ volume) + Q_PROPERTY(qreal adjustedPrice READ adjustedPrice) +public: + + StockPrice(QObject *parent = 0) + : QObject(parent) + , _openPrice(-1) + , _closePrice(-1) + , _highPrice(-1) + , _lowPrice(-1) + , _volume(-1) + , _adjustedPrice(-1) + { + } + QDate date() const {return _date;} + qreal openPrice() const {return _openPrice; } + qreal closePrice() const {return _closePrice;} + qreal highPrice() const {return _highPrice;} + qreal lowPrice() const{return _lowPrice;} + qreal adjustedPrice() const{return _adjustedPrice;} + qint32 volume() const{return _volume;} + + void setDate(const QDate& date){_date = date;} + void setOpenPrice(qreal price){_openPrice = price;} + void setClosePrice(qreal price){_closePrice = price;} + void setHighPrice(qreal price){_highPrice = price;} + void setLowPrice(qreal price){_lowPrice = price;} + void setAdjustedPrice(qreal price) {_adjustedPrice = price;} + void setVolume(qint32 volume) {_volume = volume;} + +private: + QDate _date; + qreal _openPrice; + qreal _closePrice; + qreal _highPrice; + qreal _lowPrice; + qint32 _volume; + qreal _adjustedPrice; +}; + +class QNetworkReply; +class QNetworkAccessManager; +class StockModel : public QAbstractListModel +{ + Q_OBJECT + + Q_PROPERTY(QString stockName READ stockName WRITE setStockName NOTIFY stockNameChanged) + Q_PROPERTY(QDate startDate READ startDate WRITE setStartDate NOTIFY startDateChanged) + Q_PROPERTY(QDate endDate READ endDate WRITE setEndDate NOTIFY endDateChanged) + Q_PROPERTY(StockDataCycle dataCycle READ dataCycle WRITE setDataCycle NOTIFY dataCycleChanged) + + Q_ENUMS(StockDataCycle) +public: + enum StockDataCycle { + Daily, + Weekly, + Monthly, + Dividend + }; + + enum StockModelRoles { + DateRole = Qt::UserRole + 1, + SectionRole, + OpenPriceRole, + ClosePriceRole, + HighPriceRole, + LowPriceRole, + VolumeRole, + AdjustedPriceRole + }; + + StockModel(QObject *parent = 0); + + QString stockName() const; + void setStockName(const QString& name); + + QDate startDate() const; + void setStartDate(const QDate& date); + + QDate endDate() const; + void setEndDate(const QDate& date); + + StockDataCycle dataCycle() const; + void setDataCycle(StockDataCycle cycle); + + int rowCount(const QModelIndex & parent = QModelIndex()) const; + + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + +signals: + void stockNameChanged(); + void startDateChanged(); + void endDateChanged(); + void dataCycleChanged(); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); + +public slots: + void requestData(); + StockPrice* stockPriceAtIndex(int idx) const; +private slots: + void doRequest(); + void update(QNetworkReply* reply); +private: + QString dataCycleString() const; + QList _prices; + QString _stockName; + QDate _startDate; + QDate _endDate; + StockDataCycle _dataCycle; + QNetworkAccessManager* _manager; + bool _updating; +}; + + + + diff --git a/examples/qtquick/canvas/stockchart/plugin.cpp b/examples/qtquick/canvas/stockchart/plugin.cpp new file mode 100644 index 0000000000..af64af4da8 --- /dev/null +++ b/examples/qtquick/canvas/stockchart/plugin.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "model.h" + +class QStockChartExampleQmlPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) + { + Q_ASSERT(uri == QLatin1String("com.nokia.StockChartExample")); + qmlRegisterType(uri, 1, 0, "StockModel"); + qmlRegisterType(uri, 1, 0, "StockPrice"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(qmlstockchartexampleplugin, QStockChartExampleQmlPlugin); diff --git a/examples/qtquick/canvas/stockchart/stock.qml b/examples/qtquick/canvas/stockchart/stock.qml new file mode 100644 index 0000000000..1c95fde2ce --- /dev/null +++ b/examples/qtquick/canvas/stockchart/stock.qml @@ -0,0 +1,726 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import com.nokia.StockChartExample 1.0 +import "../contents" + +Rectangle { + id:container + width: 360; height: 600 + color: "#343434"; + Image { source: "contents/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 1 } + + + TitleBar { + id: titleBar + width: parent.width + anchors.top : container.top + height: 40 + opacity: 0.9 + } + + StockModel { + id:stockModel + dataCycle: StockModel.Daily + function dataCycleName() { + if (dataCycle === StockModel.Weekly) + return "Weekly"; + else if (dataCycle === StockModel.Monthly) + return "Monthly"; + return "Daily"; + } + + onDataChanged: { + if (view.viewType == "chart") { + canvas.requestPaint(); + } + } + onDownloadProgress: { + if (bytesReceived == bytesTotal && bytesTotal != -1) { + progress.opacity = 0; + } else { + progress.opacity = 0.8; + progress.text = "downloading " + stockModel.dataCycleName() + " data ..."+ Math.round(bytesReceived/1000) + " KB"; + } + } + + property string description:""; + } + + Stocks {id:stocks} + + Rectangle { + id: header + width: parent.width + height: 20 + color: "steelblue" + opacity: 0 + Row { + spacing: 2 + Text { + id:t + font.pointSize:15 + horizontalAlignment:Text.AlignHCenter + font.bold: true + font.underline:true + } + Rectangle { + height:20 + width:50 + Text {text:"Stock list"; font.pointSize:15; font.bold: true} + } + } + } + + ListView { + id:stockList + width: parent.width + anchors.bottom: container.bottom + anchors.top : titleBar.bottom + focus: true + keyNavigationWraps: true + spacing:1 + opacity: 1 + model: stocks + + Component.onCompleted: opacity = 0.9; + onOpacityChanged: { + titleBar.title = "Top 100 NASDAQ stocks" + } + + + delegate : Rectangle { + height: 30 + width: view.width + color: { + if (ListView.isCurrentItem) + return focus ? "lightyellow" : "pink"; + return index % 2 == 0 ? "lightblue" : "lightsteelblue" + } + Text { + font.pointSize:20 + text: index + ". " + stockId + " \t(" + name + ")"; + } + MouseArea { + anchors.fill: parent; + onDoubleClicked: { + stockList.opacity = 0; + stockModel.stockName = stockId; + stockModel.description = "NASDAQ:" + stockId + " (" + name + ")"; + view.opacity = 1; + view.viewType = "chart"; + canvas.opacity = 0.7; + } + onClicked: stockList.currentIndex = index + }//mousearea + }//delegate + } + + ListView { + id:view + width: container.width + height: container.height - 50 + anchors.bottom: container.bottom + focus: true + keyNavigationWraps: true + + spacing:1 + opacity: 0 + model: stockModel + highlightFollowsCurrentItem: false + highlightRangeMode: ListView.StrictlyEnforceRange + preferredHighlightBegin:50 + preferredHighlightEnd : height - 50 + highlight: listHighlight + + //header : Text {} + delegate: listDelegate + snapMode: ListView.SnapToItem + + property string viewType : "list" + property int topIndex:indexAt(0,contentY); + property int bottomIndex:indexAt(0, contentY+height); + + onCountChanged: { + + titleBar.title = stockModel.description + " " + Qt.formatDate(stockModel.startDate, "yyyy-MM-dd") + " - " + + Qt.formatDate(stockModel.endDate, "yyyy-MM-dd") + " " + stockModel.dataCycleName() + + " records:" + view.count; + + } + + Component { + id: listDelegate + Rectangle { + height: 20 + width: view.width + border.color: "lightsteelblue" + border.width: 1 + color: { + if (ListView.isCurrentItem) + return focus ? "lightyellow" : "pink"; + + return index % 2 == 0 ? "lightblue" : "lightsteelblue" + } + Text { + font.pointSize:13 + text: index + ". " + Qt.formatDate(date, "yyyy-MM-dd") + + "\t " + Math.round(openPrice*100)/100 + + "\t " + Math.round(highPrice*100)/100 + + "\t " + Math.round(lowPrice*100)/100 + + "\t " + Math.round(closePrice*100)/100 + + "\t " + volume + "\t " + + Math.round(adjustedPrice*100)/100; + } + MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index} + } + } + + Component { + id: chartDelegate + Rectangle { + height: 20 + width: view.width/view.count * canvas.scaleX + border.color: "lightsteelblue" + border.width: 1 + color: { + if (ListView.isCurrentItem) + return focus ? "lightyellow" : "pink"; + + return index % 2 == 0 ? "lightblue" : "lightsteelblue" + } + + Text { + anchors.bottom: parent.bottom + font.pointSize: { + if (parent.width <= 4) + return 1; + if (parent.width <= 50) + return parent.width/4; + return 15; + } + horizontalAlignment:Text.AlignHCenter + verticalAlignment:Text.AlignBottom + text:font.pointSize > 1 ? Qt.formatDate(date, "d/M/yy") : "" + } + MouseArea {anchors.fill: parent; onClicked: view.currentIndex = index} + } + } + + Component { + id:chartHighlight + Rectangle { radius: 5; width:40; height: 20; color: "lightsteelblue" } + } + + Component { + id:listHighlight + Rectangle { radius: 5; width:container.width; height: 20; color: "lightsteelblue" } + } + + + + + onViewTypeChanged : { + if (viewType == "list") { + view.orientation = ListView.Vertical; + view.delegate = listDelegate; +// view.section.property = "year"; +// view.section.criteria = ViewSection.FullString; +// view.section.delegate = sectionHeading; + view.highlight = listHighlight; + view.opacity = 1; + canvas.opacity = 0; + // comment.opacity = 0; + + } else if (viewType == "chart") { + view.orientation = ListView.Horizontal; + view.delegate = chartDelegate; + //comment.opacity = 0.6; + + view.opacity = 1; + view.height = 30 + + canvas.opacity = 0.7; + canvas.requestPaint(); + } else { + viewType = "list"; + } + } + + + onCurrentIndexChanged: { + //header.updateCurrent(stockModel.stockPriceAtIndex(view.currentIndex)); + if (viewType == "chart") { + canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX); + canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX); + + canvas.requestPaint(); + } + } + onContentYChanged: { // keep "current" item visible + topIndex = indexAt(0,contentY); + bottomIndex = indexAt(0, contentY+height); + + if (topIndex != -1 && currentIndex <= topIndex) + currentIndex = topIndex+1; + else if (bottomIndex != -1 && currentIndex >= bottomIndex) + currentIndex = bottomIndex-1; + if (viewType == "chart") + canvas.requestPaint(); + } + + onContentXChanged: { // keep "current" item visible + topIndex = indexAt(contentX,0); + bottomIndex = indexAt(contentX+width, 0); + + if (topIndex != -1 && currentIndex <= topIndex) + currentIndex = topIndex+1; + else if (bottomIndex != -1 && currentIndex >= bottomIndex) + currentIndex = bottomIndex-1; + if (viewType == "chart") + canvas.requestPaint(); + } + + MouseArea { + anchors.fill: parent + onDoubleClicked: { + if (view.viewType == "list") + view.viewType = "chart"; + else + view.viewType = "list"; + } + } + } + + + + Canvas { + id:canvas + anchors.top : titleBar.bottom + anchors.bottom : view.top + width:container.width; + opacity:0 + renderTarget: Canvas.Image + renderStrategy: Canvas.Immediate + property bool running:false + property int frames:first + property int mouseX:0; + property int mouseY:0; + property int mousePressedX:0; + property int mousePressedY:0; + property int movedY:0 + property real scaleX:1.0; + property real scaleY:1.0; + property int first:0; + property int last:view.count - 1; + + onOpacityChanged: { + if (opacity > 0) + requestPaint(); + } + Text { + id:comment + x:100 + y:50 + font.pointSize: 20 + color:"white" + opacity: 0.7 + focus:false + text: stockModel.description + function updateCurrent(price) + { + if (price !== undefined) { + text =stockModel.description + "\n" + + Qt.formatDate(price.date, "yyyy-MM-dd") + " OPEN:" + + Math.round(price.openPrice*100)/100 + " HIGH:" + + Math.round(price.highPrice*100)/100 + " LOW:" + + Math.round(price.lowPrice*100)/100 + " CLOSE:" + + Math.round(price.closePrice*100)/100 + " VOLUME:" + + price.volume; + } + } + } + + Text { + id:priceAxis + x:25 + y:25 + font.pointSize: 15 + color:"yellow" + opacity: 0.7 + focus: false + } + Text { + id:volumeAxis + x:canvas.width - 200 + y:25 + font.pointSize: 15 + color:"yellow" + opacity: 0.7 + } + + Rectangle { + id:progress + x:canvas.width/2 - 100 + y:canvas.height/2 + width:childrenRect.width + height: childrenRect.height + opacity: 0 + color:"white" + property string text; + Text { + text:parent.text + font.pointSize: 20 + } + } + + Button { + id:runButton + text:"Run this chart" + y:0 + x:canvas.width/2 - 50 + opacity: 0.5 + onClicked: { + if (canvas.running) { + canvas.running = false; + canvas.frames = canvas.first; + canvas.requestPaint(); + text = "Run this chart"; + comment.text = stockModel.description; + } else { + text = " Stop running "; + canvas.runChart(); + } + } + } + Button { + id:returnButton + text:"Stocks" + y:0 + anchors.left : runButton.right + anchors.leftMargin : 20 + opacity: 0.5 + onClicked: { + stockList.opacity = 1; + canvas.opacity = 0; + } + } + PinchArea { + anchors.fill: parent + onPinchUpdated : { + var current = pinch.center; + var scale = pinch.scale; + console.log("center:" + pinch.center + " scale:" + pinch.scale); + //canvas.requestPaint(); + } + } + + MouseArea { + anchors.fill: parent + + onDoubleClicked: { + if (stockModel.dataCycle == StockModel.Daily) + stockModel.dataCycle = StockModel.Weekly; + else if (stockModel.dataCycle == StockModel.Weekly) + stockModel.dataCycle = StockModel.Monthly; + else + stockModel.dataCycle = StockModel.Daily; + } + + onPositionChanged: { + if (mouse.modifiers & Qt.ControlModifier) { + if (canvas.mouseX == 0 && canvas.mouseY == 0) { + canvas.mouseX = mouse.x; + canvas.mouseY = mouse.y; + } + } else{ + var w = (view.width/view.count)*canvas.scaleX; + + //canvas.movedY += Math.round((canvas.mousePressedY - mouse.y)/2); + + var movedX = Math.round((canvas.mousePressedX - mouse.x)/w); + if (movedX != 0 || canvas.movedY != 0) { + if (canvas.first + movedX >= 0 && canvas.last + movedX < view.count) { + canvas.first += movedX; + canvas.last += movedX; + } + canvas.requestPaint(); + } + } + } + + onPressed: { + canvas.mousePressedX = mouse.x; + canvas.mousePressedY = mouse.y; + } + + onReleased : { + if (mouse.modifiers & Qt.ControlModifier) { + var sx = mouse.x - canvas.mouseX; + var sy = canvas.mouseY - mouse.y; + + if (Math.abs(sx) < 50) sx = 0; + if (Math.abs(sy) < 50) sy = 0; + + if (sx > 0) + canvas.scaleX *= sx/100 +1; + else + canvas.scaleX *= 1/(-sx/100 + 1); + + if (sy > 0) + canvas.scaleY *= sy/100 +1; + else + canvas.scaleY *= 1/(-sy/100 + 1); + + if (canvas.scaleX < 1) + canvas.scaleX = 1; + + //console.log("scaleX:" + canvas.scaleX + ", scaleY:" + canvas.scaleY); + + canvas.first = Math.round(view.currentIndex - view.currentIndex / canvas.scaleX); + canvas.last = Math.round(view.currentIndex + (view.count - view.currentIndex) / canvas.scaleX); + + canvas.mouseX = 0; + canvas.mouseY = 0; + canvas.mousePressedX = 0; + canvas.mousePressedY = 0; + canvas.requestPaint(); + } + } + } + + function runChart() { + canvas.running = true; + requestPaint(); + } + + function showPriceAt(x) { + var w = (view.width/view.count)*canvas.scaleX; + //header.updateCurrent(stockModel.stockPriceAtIndex(canvas.first + Math.round(x/w))); + //console.log("x:" + x + " w:" + w + " index:" + (canvas.first + Math.round(x/w))); + } + + function drawPrice(ctx, from, to, color, price, points, highest) + { + ctx.globalAlpha = 0.7; + ctx.strokeStyle = color; + ctx.lineWidth = 1; + ctx.beginPath(); + + //price x axis + priceAxis.text = "price:" + Math.round(highest); + ctx.font = "bold 12px sans-serif"; + + ctx.strokeText("price", 25, 25); + for (var j = 1; j < 30; j++) { + var val = (highest * j) / 30; + val = canvas.height * (1 - val/highest); + ctx.beginPath(); + + ctx.moveTo(10, val); + if (j % 5) + ctx.lineTo(15, val); + else + ctx.lineTo(20, val); + ctx.stroke(); + } + + ctx.beginPath(); + ctx.moveTo(10, 0); + ctx.lineTo(10, canvas.height); + ctx.stroke(); + + + var w = canvas.width/points.length; + var end = canvas.running? canvas.frames - canvas.first :points.length; + for (var i = 0; i < end; i++) { + var x = points[i].x; + var y = points[i][price]; + y += canvas.movedY; + + y = canvas.height * (1 - y/highest); + if (i == 0) { + ctx.moveTo(x+w/2, y); + } else { + ctx.lineTo(x+w/2, y); + } + } + ctx.stroke(); + } + + function drawKLine(ctx, from, to, points, highest) + { + ctx.globalAlpha = 0.4; + ctx.lineWidth = 2; + var end = canvas.running? canvas.frames - canvas.first :points.length; + for (var i = 0; i < end; i++) { + var x = points[i].x; + var open = canvas.height * (1 - points[i].open/highest) - canvas.movedY; + var close = canvas.height * (1 - points[i].close/highest) - canvas.movedY; + var high = canvas.height * (1 - points[i].high/highest) - canvas.movedY; + var low = canvas.height * (1 - points[i].low/highest) - canvas.movedY; + + var top, bottom; + if (close <= open) { + ctx.fillStyle = Qt.rgba(1, 0, 0, 1); + ctx.strokeStyle = Qt.rgba(1, 0, 0, 1); + top = close; + bottom = open; + } else { + ctx.fillStyle = Qt.rgba(0, 1, 0, 1); + ctx.strokeStyle = Qt.rgba(0, 1, 0, 1); + top = open; + bottom = close; + } + + var w1, w2; + w1 = canvas.width/points.length; + w2 = w1 > 10 ? w1/2 : w1; + + ctx.fillRect(x + (w1 - w2)/2, top, w2, bottom - top); + ctx.beginPath(); + ctx.moveTo(x+w1/2, high); + ctx.lineTo(x+w1/2, low); + ctx.stroke(); + } + ctx.globalAlpha = 1; + + } + + function drawVolume(ctx, from, to, color, price, points, highest) + { + ctx.fillStyle = color; + ctx.globalAlpha = 0.6; + ctx.strokeStyle = Qt.rgba(0.8, 0.8, 0.8, 1); + ctx.lineWidth = 1; + + //volume x axis + volumeAxis.text = "volume:" + Math.round(highest/(1000*100)) + "M"; + for (var j = 1; j < 30; j++) { + var val = (highest * j) / 30; + val = canvas.height * (1 - val/highest); + ctx.beginPath(); + if (j % 5) + ctx.moveTo(canvas.width - 15, val); + else + ctx.moveTo(canvas.width - 20, val); + ctx.lineTo(canvas.width - 10, val); + ctx.stroke(); + } + + ctx.beginPath(); + ctx.moveTo(canvas.width - 10, 0); + ctx.lineTo(canvas.width - 10, canvas.height); + ctx.stroke(); + + var end = canvas.running? canvas.frames - canvas.first :points.length; + for (var i = 0; i < end; i++) { + var x = points[i].x; + var y = points[i][price]; + y = canvas.height * (1 - y/highest); + ctx.fillRect(x, y, canvas.width/points.length, canvas.height - y); + } + } +/* + onPainted : { + if (canvas.running) { + if (frames >= last) { + canvas.running = false; + canvas.frames = first; + runButton.text = "Run this chart"; + comment.text = stockModel.description; + requestPaint(); + } else { + frames += Math.round(view.count / 100); + if (frames > last) frames = last; + var price = stockModel.stockPriceAtIndex(frames); + if (price) { + comment.updateCurrent(price); + } + + requestPaint(); + } + } + } +*/ + onPaint: { + if (view.currentIndex <= 0) + first = 0; + if (last >= view.count) + last = view.count - 1; + + //console.log("painting... first:" + first + ", last:" + last + " current:" + view.currentIndex); + var ctx = canvas.getContext("2d"); + ctx.save(); + + ctx.globalCompositeOperation = "source-over"; + ctx.lineWidth = 1; + ctx.lineJoin = "round"; + ctx.fillStyle = "rgba(0,0,0,0)"; + + ctx.fillRect(0, 0, canvas.width, canvas.height); + + + + var highestPrice = 500/canvas.scaleY; + var highestValume = 600 * 1000 * 1000/canvas.scaleY; + var points = []; + for (var i = 0; i <= last - first; i++) { + var price = stockModel.stockPriceAtIndex(i + first); + points.push({ + x: i*canvas.width/(last-first+1), + open: price.openPrice, + close: price.closePrice, + high:price.highPrice, + low:price.lowPrice, + volume:price.volume + }); + } + + drawPrice(ctx, first, last, Qt.rgba(1, 0, 0, 1),"high", points, highestPrice); + drawPrice(ctx, first, last, Qt.rgba(0, 1, 0, 1),"low", points, highestPrice); + drawPrice(ctx, first, last, Qt.rgba(0, 0, 1, 1),"open", points, highestPrice); + drawPrice(ctx, first, last, Qt.rgba(0.5, 0.5, 0.5, 1),"close", points, highestPrice); + drawVolume(ctx, first, last, Qt.rgba(0.3, 0.5, 0.7, 1),"volume", points, highestValume); + drawKLine(ctx, first, last, points, highestPrice); + ctx.restore(); + } + } +} diff --git a/examples/qtquick/canvas/stockchart/stockchart.pro b/examples/qtquick/canvas/stockchart/stockchart.pro new file mode 100644 index 0000000000..4006b5dccf --- /dev/null +++ b/examples/qtquick/canvas/stockchart/stockchart.pro @@ -0,0 +1,20 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += declarative network + +DESTDIR = com/nokia/StockChartExample +TARGET = qmlstockchartexampleplugin + +SOURCES += model.cpp plugin.cpp +HEADERS += model.h +qdeclarativesources.files += \ + com/nokia/StockChartExample/qmldir \ + stock.qml + +qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample + +sources.files += stockchart.pro model.h model.cpp plugin.cpp README +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/plugins/com/nokia/StockChartExample + +INSTALLS += qdeclarativesources sources target diff --git a/examples/qtquick/canvas/tiger/tiger.js b/examples/qtquick/canvas/tiger/tiger.js new file mode 100644 index 0000000000..4be0d26c9d --- /dev/null +++ b/examples/qtquick/canvas/tiger/tiger.js @@ -0,0 +1,721 @@ +var tiger = [ + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-122.304 84.285C-122.304 84.285 -122.203 86.179 -123.027 86.16C-123.851 86.141 -140.305 38.066 -160.833 40.309C-160.833 40.309 -143.05 32.956 -122.304 84.285z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-118.774 81.262C-118.774 81.262 -119.323 83.078 -120.092 82.779C-120.86 82.481 -119.977 31.675 -140.043 26.801C-140.043 26.801 -120.82 25.937 -118.774 81.262z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-91.284 123.59C-91.284 123.59 -89.648 124.55 -90.118 125.227C-90.589 125.904 -139.763 113.102 -149.218 131.459C-149.218 131.459 -145.539 112.572 -91.284 123.59z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-94.093 133.801C-94.093 133.801 -92.237 134.197 -92.471 134.988C-92.704 135.779 -143.407 139.121 -146.597 159.522C-146.597 159.522 -149.055 140.437 -94.093 133.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-98.304 128.276C-98.304 128.276 -96.526 128.939 -96.872 129.687C-97.218 130.435 -147.866 126.346 -153.998 146.064C-153.998 146.064 -153.646 126.825 -98.304 128.276z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-109.009 110.072C-109.009 110.072 -107.701 111.446 -108.34 111.967C-108.979 112.488 -152.722 86.634 -166.869 101.676C-166.869 101.676 -158.128 84.533 -109.009 110.072z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-116.554 114.263C-116.554 114.263 -115.098 115.48 -115.674 116.071C-116.25 116.661 -162.638 95.922 -174.992 112.469C-174.992 112.469 -168.247 94.447 -116.554 114.263z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-119.154 118.335C-119.154 118.335 -117.546 119.343 -118.036 120.006C-118.526 120.669 -167.308 106.446 -177.291 124.522C-177.291 124.522 -173.066 105.749 -119.154 118.335z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-108.42 118.949C-108.42 118.949 -107.298 120.48 -107.999 120.915C-108.7 121.35 -148.769 90.102 -164.727 103.207C-164.727 103.207 -153.862 87.326 -108.42 118.949z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-128.2 90C-128.2 90 -127.6 91.8 -128.4 92C-129.2 92.2 -157.8 50.2 -177.001 57.8C-177.001 57.8 -161.8 46 -128.2 90z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-127.505 96.979C-127.505 96.979 -126.53 98.608 -127.269 98.975C-128.007 99.343 -164.992 64.499 -182.101 76.061C-182.101 76.061 -169.804 61.261 -127.505 96.979z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.172, + "path":"M-127.62 101.349C-127.62 101.349 -126.498 102.88 -127.199 103.315C-127.9 103.749 -167.969 72.502 -183.927 85.607C-183.927 85.607 -173.062 69.726 -127.62 101.349z"} + , + {"fill": "#ffffff", "stroke":"#000000", + "path":"M-129.83 103.065C-129.327 109.113 -128.339 115.682 -126.6 118.801C-126.6 118.801 -130.2 131.201 -121.4 144.401C-121.4 144.401 -121.8 151.601 -120.2 154.801C-120.2 154.801 -116.2 163.201 -111.4 164.001C-107.516 164.648 -98.793 167.717 -88.932 169.121C-88.932 169.121 -71.8 183.201 -75 196.001C-75 196.001 -75.4 212.401 -79 214.001C-79 214.001 -67.4 202.801 -77 219.601L-81.4 238.401C-81.4 238.401 -55.8 216.801 -71.4 235.201L-81.4 261.201C-81.4 261.201 -61.8 242.801 -69 251.201L-72.2 260.001C-72.2 260.001 -29 232.801 -59.8 262.401C-59.8 262.401 -51.8 258.801 -47.4 261.601C-47.4 261.601 -40.6 260.401 -41.4 262.001C-41.4 262.001 -62.2 272.401 -65.8 290.801C-65.8 290.801 -57.4 280.801 -60.6 291.601L-60.2 303.201C-60.2 303.201 -56.2 281.601 -56.6 319.201C-56.6 319.201 -37.4 301.201 -49 322.001L-49 338.801C-49 338.801 -33.8 322.401 -40.2 335.201C-40.2 335.201 -30.2 326.401 -34.2 341.601C-34.2 341.601 -35 352.001 -30.6 340.801C-30.6 340.801 -14.6 310.201 -20.6 336.401C-20.6 336.401 -21.4 355.601 -16.6 340.801C-16.6 340.801 -16.2 351.201 -7 358.401C-7 358.401 -8.2 307.601 4.6 343.601L8.6 360.001C8.6 360.001 11.4 350.801 11 345.601C11 345.601 25.8 329.201 19 353.601C19 353.601 34.2 330.801 31 344.001C31 344.001 23.4 360.001 25 364.801C25 364.801 41.8 330.001 43 328.401C43 328.401 41 370.802 51.8 334.801C51.8 334.801 57.4 346.801 54.6 351.201C54.6 351.201 62.6 343.201 61.8 340.001C61.8 340.001 66.4 331.801 69.2 345.401C69.2 345.401 71 354.801 72.6 351.601C72.6 351.601 76.6 375.602 77.8 352.801C77.8 352.801 79.4 339.201 72.2 327.601C72.2 327.601 73 324.401 70.2 320.401C70.2 320.401 83.8 342.001 76.6 313.201C76.6 313.201 87.801 321.201 89.001 321.201C89.001 321.201 75.4 298.001 84.2 302.801C84.2 302.801 79 292.401 97.001 304.401C97.001 304.401 81 288.401 98.601 298.001C98.601 298.001 106.601 304.401 99.001 294.401C99.001 294.401 84.6 278.401 106.601 296.401C106.601 296.401 118.201 312.801 119.001 315.601C119.001 315.601 109.001 286.401 104.601 283.601C104.601 283.601 113.001 247.201 154.201 262.801C154.201 262.801 161.001 280.001 165.401 261.601C165.401 261.601 178.201 255.201 189.401 282.801C189.401 282.801 193.401 269.201 192.601 266.401C192.601 266.401 199.401 267.601 198.601 266.401C198.601 266.401 211.801 270.801 213.001 270.001C213.001 270.001 219.801 276.801 220.201 273.201C220.201 273.201 229.401 276.001 227.401 272.401C227.401 272.401 236.201 288.001 236.601 291.601L239.001 277.601L241.001 280.401C241.001 280.401 242.601 272.801 241.801 271.601C241.001 270.401 261.801 278.401 266.601 299.201L268.601 307.601C268.601 307.601 274.601 292.801 273.001 288.801C273.001 288.801 278.201 289.601 278.601 294.001C278.601 294.001 282.601 270.801 277.801 264.801C277.801 264.801 282.201 264.001 283.401 267.601L283.401 260.401C283.401 260.401 290.601 261.201 290.601 258.801C290.601 258.801 295.001 254.801 297.001 259.601C297.001 259.601 284.601 224.401 303.001 243.601C303.001 243.601 310.201 254.401 306.601 235.601C303.001 216.801 299.001 215.201 303.801 214.801C303.801 214.801 304.601 211.201 302.601 209.601C300.601 208.001 303.801 209.601 303.801 209.601C303.801 209.601 308.601 213.601 303.401 191.601C303.401 191.601 309.801 193.201 297.801 164.001C297.801 164.001 300.601 161.601 296.601 153.201C296.601 153.201 304.601 157.601 307.401 156.001C307.401 156.001 307.001 154.401 303.801 150.401C303.801 150.401 282.201 95.6 302.601 117.601C302.601 117.601 314.451 131.151 308.051 108.351C308.051 108.351 298.94 84.341 299.717 80.045L-129.83 103.065z"} + , + {"fill": "#cc7226", "stroke":"#000000", + "path":"M299.717 80.245C300.345 80.426 302.551 81.55 303.801 83.2C303.801 83.2 310.601 94 305.401 75.6C305.401 75.6 296.201 46.8 305.001 58C305.001 58 311.001 65.2 307.801 51.6C303.936 35.173 301.401 28.8 301.401 28.8C301.401 28.8 313.001 33.6 286.201 -6L295.001 -2.4C295.001 -2.4 275.401 -42 253.801 -47.2L245.801 -53.2C245.801 -53.2 284.201 -91.2 271.401 -128C271.401 -128 264.601 -133.2 255.001 -124C255.001 -124 248.601 -119.2 242.601 -120.8C242.601 -120.8 211.801 -119.6 209.801 -119.6C207.801 -119.6 173.001 -156.8 107.401 -139.2C107.401 -139.2 102.201 -137.2 97.801 -138.4C97.801 -138.4 79.4 -154.4 30.6 -131.6C30.6 -131.6 20.6 -129.6 19 -129.6C17.4 -129.6 14.6 -129.6 6.6 -123.2C-1.4 -116.8 -1.8 -116 -3.8 -114.4C-3.8 -114.4 -20.2 -103.2 -25 -102.4C-25 -102.4 -36.6 -96 -41 -86L-44.6 -84.8C-44.6 -84.8 -46.2 -77.6 -46.6 -76.4C-46.6 -76.4 -51.4 -72.8 -52.2 -67.2C-52.2 -67.2 -61 -61.2 -60.6 -56.8C-60.6 -56.8 -62.2 -51.6 -63 -46.8C-63 -46.8 -70.2 -42 -69.4 -39.2C-69.4 -39.2 -77 -25.2 -75.8 -18.4C-75.8 -18.4 -82.2 -18.8 -85 -16.4C-85 -16.4 -85.8 -11.6 -87.4 -11.2C-87.4 -11.2 -90.2 -10 -87.8 -6C-87.8 -6 -89.4 -3.2 -89.8 -1.6C-89.8 -1.6 -89 1.2 -93.4 6.8C-93.4 6.8 -99.8 25.6 -97.8 30.8C-97.8 30.8 -97.4 35.6 -100.2 37.2C-100.2 37.2 -103.8 36.8 -95.4 48.8C-95.4 48.8 -94.6 50 -97.8 52.4C-97.8 52.4 -115 56 -117.4 72.4C-117.4 72.4 -131 87.2 -131 92.4C-131 94.705 -130.729 97.852 -130.03 102.465C-130.03 102.465 -130.6 110.801 -103 111.601C-75.4 112.401 299.717 80.245 299.717 80.245z"} + , + {"fill": "#cc7226", + "path":"M-115.6 102.6C-140.6 63.2 -126.2 119.601 -126.2 119.601C-117.4 154.001 12.2 116.401 12.2 116.401C12.2 116.401 181.001 86 192.201 82C203.401 78 298.601 84.4 298.601 84.4L293.001 67.6C228.201 21.2 209.001 44.4 195.401 40.4C181.801 36.4 184.201 46 181.001 46.8C177.801 47.6 138.601 22.8 132.201 23.6C125.801 24.4 100.459 0.649 115.401 32.4C131.401 66.4 57 71.6 40.2 60.4C23.4 49.2 47.4 78.8 47.4 78.8C65.8 98.8 31.4 82 31.4 82C-3 69.2 -27 94.8 -30.2 95.6C-33.4 96.4 -38.2 99.6 -39 93.2C-39.8 86.8 -47.31 70.099 -79 96.4C-99 113.001 -112.8 91 -112.8 91L-115.6 102.6z"} + , + {"fill": "#e87f3a", + "path":"M133.51 25.346C127.11 26.146 101.743 2.407 116.71 34.146C133.31 69.346 58.31 73.346 41.51 62.146C24.709 50.946 48.71 80.546 48.71 80.546C67.11 100.546 32.709 83.746 32.709 83.746C-1.691 70.946 -25.691 96.546 -28.891 97.346C-32.091 98.146 -36.891 101.346 -37.691 94.946C-38.491 88.546 -45.87 72.012 -77.691 98.146C-98.927 115.492 -112.418 94.037 -112.418 94.037L-115.618 104.146C-140.618 64.346 -125.546 122.655 -125.546 122.655C-116.745 157.056 13.509 118.146 13.509 118.146C13.509 118.146 182.31 87.746 193.51 83.746C204.71 79.746 299.038 86.073 299.038 86.073L293.51 68.764C228.71 22.364 210.31 46.146 196.71 42.146C183.11 38.146 185.51 47.746 182.31 48.546C179.11 49.346 139.91 24.546 133.51 25.346z"} + , + {"fill": "#ea8c4d", + "path":"M134.819 27.091C128.419 27.891 103.685 3.862 118.019 35.891C134.219 72.092 59.619 75.092 42.819 63.892C26.019 52.692 50.019 82.292 50.019 82.292C68.419 102.292 34.019 85.492 34.019 85.492C-0.381 72.692 -24.382 98.292 -27.582 99.092C-30.782 99.892 -35.582 103.092 -36.382 96.692C-37.182 90.292 -44.43 73.925 -76.382 99.892C-98.855 117.983 -112.036 97.074 -112.036 97.074L-115.636 105.692C-139.436 66.692 -124.891 125.71 -124.891 125.71C-116.091 160.11 14.819 119.892 14.819 119.892C14.819 119.892 183.619 89.492 194.819 85.492C206.019 81.492 299.474 87.746 299.474 87.746L294.02 69.928C229.219 23.528 211.619 47.891 198.019 43.891C184.419 39.891 186.819 49.491 183.619 50.292C180.419 51.092 141.219 26.291 134.819 27.091z"} + , + {"fill": "#ec9961", + "path":"M136.128 28.837C129.728 29.637 104.999 5.605 119.328 37.637C136.128 75.193 60.394 76.482 44.128 65.637C27.328 54.437 51.328 84.037 51.328 84.037C69.728 104.037 35.328 87.237 35.328 87.237C0.928 74.437 -23.072 100.037 -26.272 100.837C-29.472 101.637 -34.272 104.837 -35.072 98.437C-35.872 92.037 -42.989 75.839 -75.073 101.637C-98.782 120.474 -111.655 100.11 -111.655 100.11L-115.655 107.237C-137.455 70.437 -124.236 128.765 -124.236 128.765C-115.436 163.165 16.128 121.637 16.128 121.637C16.128 121.637 184.928 91.237 196.129 87.237C207.329 83.237 299.911 89.419 299.911 89.419L294.529 71.092C229.729 24.691 212.929 49.637 199.329 45.637C185.728 41.637 188.128 51.237 184.928 52.037C181.728 52.837 142.528 28.037 136.128 28.837z"} + , + {"fill": "#eea575", + "path":"M137.438 30.583C131.037 31.383 106.814 7.129 120.637 39.383C137.438 78.583 62.237 78.583 45.437 67.383C28.637 56.183 52.637 85.783 52.637 85.783C71.037 105.783 36.637 88.983 36.637 88.983C2.237 76.183 -21.763 101.783 -24.963 102.583C-28.163 103.383 -32.963 106.583 -33.763 100.183C-34.563 93.783 -41.548 77.752 -73.763 103.383C-98.709 122.965 -111.273 103.146 -111.273 103.146L-115.673 108.783C-135.473 73.982 -123.582 131.819 -123.582 131.819C-114.782 166.22 17.437 123.383 17.437 123.383C17.437 123.383 186.238 92.983 197.438 88.983C208.638 84.983 300.347 91.092 300.347 91.092L295.038 72.255C230.238 25.855 214.238 51.383 200.638 47.383C187.038 43.383 189.438 52.983 186.238 53.783C183.038 54.583 143.838 29.783 137.438 30.583z"} + , + {"fill": "#f1b288", + "path":"M138.747 32.328C132.347 33.128 106.383 9.677 121.947 41.128C141.147 79.928 63.546 80.328 46.746 69.128C29.946 57.928 53.946 87.528 53.946 87.528C72.346 107.528 37.946 90.728 37.946 90.728C3.546 77.928 -20.454 103.528 -23.654 104.328C-26.854 105.128 -31.654 108.328 -32.454 101.928C-33.254 95.528 -40.108 79.665 -72.454 105.128C-98.636 125.456 -110.891 106.183 -110.891 106.183L-115.691 110.328C-133.691 77.128 -122.927 134.874 -122.927 134.874C-114.127 169.274 18.746 125.128 18.746 125.128C18.746 125.128 187.547 94.728 198.747 90.728C209.947 86.728 300.783 92.764 300.783 92.764L295.547 73.419C230.747 27.019 215.547 53.128 201.947 49.128C188.347 45.128 190.747 54.728 187.547 55.528C184.347 56.328 145.147 31.528 138.747 32.328z"} + , + {"fill": "#f3bf9c", + "path":"M140.056 34.073C133.655 34.873 107.313 11.613 123.255 42.873C143.656 82.874 64.855 82.074 48.055 70.874C31.255 59.674 55.255 89.274 55.255 89.274C73.655 109.274 39.255 92.474 39.255 92.474C4.855 79.674 -19.145 105.274 -22.345 106.074C-25.545 106.874 -30.345 110.074 -31.145 103.674C-31.945 97.274 -38.668 81.578 -71.145 106.874C-98.564 127.947 -110.509 109.219 -110.509 109.219L-115.709 111.874C-131.709 81.674 -122.273 137.929 -122.273 137.929C-113.473 172.329 20.055 126.874 20.055 126.874C20.055 126.874 188.856 96.474 200.056 92.474C211.256 88.474 301.22 94.437 301.22 94.437L296.056 74.583C231.256 28.183 216.856 54.874 203.256 50.874C189.656 46.873 192.056 56.474 188.856 57.274C185.656 58.074 146.456 33.273 140.056 34.073z"} + , + {"fill": "#f5ccb0", + "path":"M141.365 35.819C134.965 36.619 107.523 13.944 124.565 44.619C146.565 84.219 66.164 83.819 49.364 72.619C32.564 61.419 56.564 91.019 56.564 91.019C74.964 111.019 40.564 94.219 40.564 94.219C6.164 81.419 -17.836 107.019 -21.036 107.819C-24.236 108.619 -29.036 111.819 -29.836 105.419C-30.636 99.019 -37.227 83.492 -69.836 108.619C-98.491 130.438 -110.127 112.256 -110.127 112.256L-115.727 113.419C-130.128 85.019 -121.618 140.983 -121.618 140.983C-112.818 175.384 21.364 128.619 21.364 128.619C21.364 128.619 190.165 98.219 201.365 94.219C212.565 90.219 301.656 96.11 301.656 96.11L296.565 75.746C231.765 29.346 218.165 56.619 204.565 52.619C190.965 48.619 193.365 58.219 190.165 59.019C186.965 59.819 147.765 35.019 141.365 35.819z"} + , + {"fill": "#f8d8c4", + "path":"M142.674 37.565C136.274 38.365 108.832 15.689 125.874 46.365C147.874 85.965 67.474 85.565 50.674 74.365C33.874 63.165 57.874 92.765 57.874 92.765C76.274 112.765 41.874 95.965 41.874 95.965C7.473 83.165 -16.527 108.765 -19.727 109.565C-22.927 110.365 -27.727 113.565 -28.527 107.165C-29.327 100.765 -35.786 85.405 -68.527 110.365C-98.418 132.929 -109.745 115.293 -109.745 115.293L-115.745 114.965C-129.346 88.564 -120.963 144.038 -120.963 144.038C-112.163 178.438 22.673 130.365 22.673 130.365C22.673 130.365 191.474 99.965 202.674 95.965C213.874 91.965 302.093 97.783 302.093 97.783L297.075 76.91C232.274 30.51 219.474 58.365 205.874 54.365C192.274 50.365 194.674 59.965 191.474 60.765C188.274 61.565 149.074 36.765 142.674 37.565z"} + , + {"fill": "#fae5d7", + "path":"M143.983 39.31C137.583 40.11 110.529 17.223 127.183 48.11C149.183 88.91 68.783 87.31 51.983 76.11C35.183 64.91 59.183 94.51 59.183 94.51C77.583 114.51 43.183 97.71 43.183 97.71C8.783 84.91 -15.217 110.51 -18.417 111.31C-21.618 112.11 -26.418 115.31 -27.218 108.91C-28.018 102.51 -34.346 87.318 -67.218 112.11C-98.345 135.42 -109.363 118.329 -109.363 118.329L-115.764 116.51C-128.764 92.51 -120.309 147.093 -120.309 147.093C-111.509 181.493 23.983 132.11 23.983 132.11C23.983 132.11 192.783 101.71 203.983 97.71C215.183 93.71 302.529 99.456 302.529 99.456L297.583 78.074C232.783 31.673 220.783 60.11 207.183 56.11C193.583 52.11 195.983 61.71 192.783 62.51C189.583 63.31 150.383 38.51 143.983 39.31z"} + , + {"fill": "#fcf2eb", + "path":"M145.292 41.055C138.892 41.855 112.917 18.411 128.492 49.855C149.692 92.656 70.092 89.056 53.292 77.856C36.492 66.656 60.492 96.256 60.492 96.256C78.892 116.256 44.492 99.456 44.492 99.456C10.092 86.656 -13.908 112.256 -17.108 113.056C-20.308 113.856 -25.108 117.056 -25.908 110.656C-26.708 104.256 -32.905 89.232 -65.908 113.856C-98.273 137.911 -108.982 121.365 -108.982 121.365L-115.782 118.056C-128.582 94.856 -119.654 150.147 -119.654 150.147C-110.854 184.547 25.292 133.856 25.292 133.856C25.292 133.856 194.093 103.456 205.293 99.456C216.493 95.456 302.965 101.128 302.965 101.128L298.093 79.237C233.292 32.837 222.093 61.856 208.493 57.856C194.893 53.855 197.293 63.456 194.093 64.256C190.892 65.056 151.692 40.255 145.292 41.055z"} + , + {"fill": "#ffffff", + "path":"M-115.8 119.601C-128.6 97.6 -119 153.201 -119 153.201C-110.2 187.601 26.6 135.601 26.6 135.601C26.6 135.601 195.401 105.2 206.601 101.2C217.801 97.2 303.401 102.8 303.401 102.8L298.601 80.4C233.801 34 223.401 63.6 209.801 59.6C196.201 55.6 198.601 65.2 195.401 66C192.201 66.8 153.001 42 146.601 42.8C140.201 43.6 114.981 19.793 129.801 51.6C152.028 99.307 69.041 89.227 54.6 79.6C37.8 68.4 61.8 98 61.8 98C80.2 118.001 45.8 101.2 45.8 101.2C11.4 88.4 -12.6 114.001 -15.8 114.801C-19 115.601 -23.8 118.801 -24.6 112.401C-25.4 106 -31.465 91.144 -64.6 115.601C-98.2 140.401 -108.6 124.401 -108.6 124.401L-115.8 119.601z"} + , + {"fill": "#000000", + "path":"M-74.2 149.601C-74.2 149.601 -81.4 161.201 -60.6 174.401C-60.6 174.401 -59.2 175.801 -77.2 171.601C-77.2 171.601 -83.4 169.601 -85 159.201C-85 159.201 -89.8 154.801 -94.6 149.201C-99.4 143.601 -74.2 149.601 -74.2 149.601z"} + , + {"fill": "#cccccc", + "path":"M65.8 102C65.8 102 83.498 128.821 82.9 133.601C81.6 144.001 81.4 153.601 84.6 157.601C87.801 161.601 96.601 194.801 96.601 194.801C96.601 194.801 96.201 196.001 108.601 158.001C108.601 158.001 120.201 142.001 100.201 123.601C100.201 123.601 65 94.8 65.8 102z"} + , + {"fill": "#000000", + "path":"M-54.2 176.401C-54.2 176.401 -43 183.601 -57.4 214.801L-51 212.401C-51 212.401 -51.8 223.601 -55 226.001L-47.8 222.801C-47.8 222.801 -43 230.801 -47 235.601C-47 235.601 -30.2 243.601 -31 250.001C-31 250.001 -24.6 242.001 -28.6 235.601C-32.6 229.201 -39.8 233.201 -39 214.801L-47.8 218.001C-47.8 218.001 -42.2 209.201 -42.2 202.801L-50.2 205.201C-50.2 205.201 -34.731 178.623 -45.4 177.201C-51.4 176.401 -54.2 176.401 -54.2 176.401z"} + , + {"fill": "#cccccc", + "path":"M-21.8 193.201C-21.8 193.201 -19 188.801 -21.8 189.601C-24.6 190.401 -55.8 205.201 -61.8 214.801C-61.8 214.801 -27.4 190.401 -21.8 193.201z"} + , + {"fill": "#cccccc", + "path":"M-11.4 201.201C-11.4 201.201 -8.6 196.801 -11.4 197.601C-14.2 198.401 -45.4 213.201 -51.4 222.801C-51.4 222.801 -17 198.401 -11.4 201.201z"} + , + {"fill": "#cccccc", + "path":"M1.8 186.001C1.8 186.001 4.6 181.601 1.8 182.401C-1 183.201 -32.2 198.001 -38.2 207.601C-38.2 207.601 -3.8 183.201 1.8 186.001z"} + , + {"fill": "#cccccc", + "path":"M-21.4 229.601C-21.4 229.601 -21.4 223.601 -24.2 224.401C-27 225.201 -63 242.801 -69 252.401C-69 252.401 -27 226.801 -21.4 229.601z"} + , + {"fill": "#cccccc", + "path":"M-20.2 218.801C-20.2 218.801 -19 214.001 -21.8 214.801C-23.8 214.801 -50.2 226.401 -56.2 236.001C-56.2 236.001 -26.6 214.401 -20.2 218.801z"} + , + {"fill": "#cccccc", + "path":"M-34.6 266.401L-44.6 274.001C-44.6 274.001 -34.2 266.401 -30.6 267.601C-30.6 267.601 -37.4 278.801 -38.2 284.001C-38.2 284.001 -27.8 271.201 -22.2 271.601C-22.2 271.601 -14.6 272.001 -14.6 282.801C-14.6 282.801 -9 272.401 -5.8 272.801C-5.8 272.801 -4.6 279.201 -5.8 286.001C-5.8 286.001 -1.8 278.401 2.2 280.001C2.2 280.001 8.6 278.001 7.8 289.601C7.8 289.601 7.8 300.001 7 302.801C7 302.801 12.6 276.401 15 276.001C15 276.001 23 274.801 27.8 283.601C27.8 283.601 23.8 276.001 28.6 278.001C28.6 278.001 39.4 279.601 42.6 286.401C42.6 286.401 35.8 274.401 41.4 277.601C41.4 277.601 48.2 277.601 49.4 284.001C49.4 284.001 57.8 305.201 59.8 306.801C59.8 306.801 52.2 285.201 53.8 285.201C53.8 285.201 51.8 273.201 57 288.001C57 288.001 53.8 274.001 59.4 274.801C65 275.601 69.4 285.601 77.8 283.201C77.8 283.201 87.401 288.801 89.401 219.601L-34.6 266.401z"} + , + {"fill": "#000000", + "path":"M-29.8 173.601C-29.8 173.601 -15 167.601 25 173.601C25 173.601 32.2 174.001 39 165.201C45.8 156.401 72.6 149.201 79 151.201L88.601 157.601L89.401 158.801C89.401 158.801 101.801 169.201 102.201 176.801C102.601 184.401 87.801 232.401 78.2 248.401C68.6 264.401 59 276.801 39.8 274.401C39.8 274.401 19 270.401 -6.6 274.401C-6.6 274.401 -35.8 272.801 -38.6 264.801C-41.4 256.801 -27.4 241.601 -27.4 241.601C-27.4 241.601 -23 233.201 -24.2 218.801C-25.4 204.401 -25 176.401 -29.8 173.601z"} + , + {"fill": "#e5668c", + "path":"M-7.8 175.601C0.6 194.001 -29 259.201 -29 259.201C-31 260.801 -16.34 266.846 -6.2 264.401C4.746 261.763 45 266.001 45 266.001C68.6 250.401 81.4 206.001 81.4 206.001C81.4 206.001 91.801 182.001 74.2 178.801C56.6 175.601 -7.8 175.601 -7.8 175.601z"} + , + {"fill": "#b23259", + "path":"M-9.831 206.497C-6.505 193.707 -4.921 181.906 -7.8 175.601C-7.8 175.601 54.6 182.001 65.8 161.201C70.041 153.326 84.801 184.001 84.4 193.601C84.4 193.601 21.4 208.001 6.6 196.801L-9.831 206.497z"} + , + {"fill": "#a5264c", + "path":"M-5.4 222.801C-5.4 222.801 -3.4 230.001 -5.8 234.001C-5.8 234.001 -7.4 234.801 -8.6 235.201C-8.6 235.201 -7.4 238.801 -1.4 240.401C-1.4 240.401 0.6 244.801 3 245.201C5.4 245.601 10.2 251.201 14.2 250.001C18.2 248.801 29.4 244.801 29.4 244.801C29.4 244.801 35 241.601 43.8 245.201C43.8 245.201 46.175 244.399 46.6 240.401C47.1 235.701 50.2 232.001 52.2 230.001C54.2 228.001 63.8 215.201 62.6 214.801C61.4 214.401 -5.4 222.801 -5.4 222.801z"} + , + {"fill": "#ff727f", "stroke":"#000000", + "path":"M-9.8 174.401C-9.8 174.401 -12.6 196.801 -9.4 205.201C-6.2 213.601 -7 215.601 -7.8 219.601C-8.6 223.601 -4.2 233.601 1.4 239.601L13.4 241.201C13.4 241.201 28.6 237.601 37.8 240.401C37.8 240.401 46.794 241.744 50.2 226.801C50.2 226.801 55 220.401 62.2 217.601C69.4 214.801 76.6 173.201 72.6 165.201C68.6 157.201 54.2 152.801 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-8.2 249.201C-8.2 249.201 -9 247.201 -13.4 246.801C-13.4 246.801 -35.8 243.201 -44.2 230.801C-44.2 230.801 -51 225.201 -46.6 236.801C-46.6 236.801 -36.2 257.201 -29.4 260.001C-29.4 260.001 -13 264.001 -8.2 249.201z"} + , + {"fill": "#cc3f4c", + "path":"M71.742 185.229C72.401 177.323 74.354 168.709 72.6 165.201C66.154 152.307 49.181 157.695 38.2 168.401C22.2 184.001 20.2 167.201 -9.8 174.401C-9.8 174.401 -11.545 188.364 -10.705 198.376C-10.705 198.376 26.6 186.801 27.4 192.401C27.4 192.401 29 189.201 38.2 189.201C47.4 189.201 70.142 188.029 71.742 185.229z"} + , + {"stroke":"#a51926", "width":2, + "path":"M28.6 175.201C28.6 175.201 33.4 180.001 29.8 189.601C29.8 189.601 15.4 205.601 17.4 219.601"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-19.4 260.001C-19.4 260.001 -23.8 247.201 -15 254.001C-15 254.001 -10.2 256.001 -11.4 257.601C-12.6 259.201 -18.2 263.201 -19.4 260.001z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-14.36 261.201C-14.36 261.201 -17.88 250.961 -10.84 256.401C-10.84 256.401 -6.419 258.849 -7.96 259.281C-12.52 260.561 -7.96 263.121 -14.36 261.201z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-9.56 261.201C-9.56 261.201 -13.08 250.961 -6.04 256.401C-6.04 256.401 -1.665 258.711 -3.16 259.281C-6.52 260.561 -3.16 263.121 -9.56 261.201z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-2.96 261.401C-2.96 261.401 -6.48 251.161 0.56 256.601C0.56 256.601 4.943 258.933 3.441 259.481C0.48 260.561 3.441 263.321 -2.96 261.401z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M3.52 261.321C3.52 261.321 0 251.081 7.041 256.521C7.041 256.521 10.881 258.121 9.921 259.401C8.961 260.681 9.921 263.241 3.52 261.321z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M10.2 262.001C10.2 262.001 5.4 249.601 14.6 256.001C14.6 256.001 19.4 258.001 18.2 259.601C17 261.201 18.2 264.401 10.2 262.001z"} + , + {"stroke":"#a5264c", "width":2, + "path":"M-18.2 244.801C-18.2 244.801 -5 242.001 1 245.201C1 245.201 7 246.401 8.2 246.001C9.4 245.601 12.6 245.201 12.6 245.201"} + , + {"stroke":"#a5264c", "width":2, + "path":"M15.8 253.601C15.8 253.601 27.8 240.001 39.8 244.401C46.816 246.974 45.8 243.601 46.6 240.801C47.4 238.001 47.6 233.801 52.6 230.801"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M33 237.601C33 237.601 29 226.801 26.2 239.601C23.4 252.401 20.2 256.001 18.6 258.801C18.6 258.801 18.6 264.001 27 263.601C27 263.601 37.8 263.201 38.2 260.401C38.6 257.601 37 246.001 33 237.601z"} + , + {"stroke":"#a5264c", "width":2, + "path":"M47 244.801C47 244.801 50.6 242.401 53 243.601"} + , + {"stroke":"#a5264c", "width":2, + "path":"M53.5 228.401C53.5 228.401 56.4 223.501 61.2 222.701"} + , + {"fill": "#b2b2b2", + "path":"M-25.8 265.201C-25.8 265.201 -7.8 268.401 -3.4 266.801C-3.4 266.801 5.4 266.801 -3 268.801C-3 268.801 -15.8 268.801 -23.8 267.601C-23.8 267.601 -35.4 262.001 -25.8 265.201z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-11.8 172.001C-11.8 172.001 5.8 172.001 7.8 172.801C7.8 172.801 15 203.601 11.4 211.201C11.4 211.201 10.2 214.001 7.4 208.401C7.4 208.401 -11 175.601 -14.2 173.601C-17.4 171.601 -13 172.001 -11.8 172.001z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-88.9 169.301C-88.9 169.301 -80 171.001 -67.4 173.601C-67.4 173.601 -62.6 196.001 -59.4 200.801C-56.2 205.601 -59.8 205.601 -63.4 202.801C-67 200.001 -81.8 186.001 -83.8 181.601C-85.8 177.201 -88.9 169.301 -88.9 169.301z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-67.039 173.818C-67.039 173.818 -61.239 175.366 -60.23 177.581C-59.222 179.795 -61.432 183.092 -61.432 183.092C-61.432 183.092 -62.432 186.397 -63.634 184.235C-64.836 182.072 -67.708 174.412 -67.039 173.818z"} + , + {"fill": "#000000", + "path":"M-67 173.601C-67 173.601 -63.4 178.801 -59.8 178.801C-56.2 178.801 -55.818 178.388 -53 179.001C-48.4 180.001 -48.8 178.001 -42.2 179.201C-39.56 179.681 -37 178.801 -34.2 180.001C-31.4 181.201 -28.2 180.401 -27 178.401C-25.8 176.401 -21 172.201 -21 172.201C-21 172.201 -33.8 174.001 -36.6 174.801C-36.6 174.801 -59 176.001 -67 173.601z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-22.4 173.801C-22.4 173.801 -28.85 177.301 -29.25 179.701C-29.65 182.101 -24 185.801 -24 185.801C-24 185.801 -21.25 190.401 -20.65 188.001C-20.05 185.601 -21.6 174.201 -22.4 173.801z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-59.885 179.265C-59.885 179.265 -52.878 190.453 -52.661 179.242C-52.661 179.242 -52.104 177.984 -53.864 177.962C-59.939 177.886 -58.418 173.784 -59.885 179.265z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-52.707 179.514C-52.707 179.514 -44.786 190.701 -45.422 179.421C-45.422 179.421 -45.415 179.089 -47.168 178.936C-51.915 178.522 -51.57 174.004 -52.707 179.514z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-45.494 179.522C-45.494 179.522 -37.534 190.15 -38.203 180.484C-38.203 180.484 -38.084 179.251 -39.738 178.95C-43.63 178.244 -43.841 174.995 -45.494 179.522z"} + , + {"fill": "#ffffcc", "stroke":"#000000", "width":0.5, + "path":"M-38.618 179.602C-38.618 179.602 -30.718 191.163 -30.37 181.382C-30.37 181.382 -28.726 180.004 -30.472 179.782C-36.29 179.042 -35.492 174.588 -38.618 179.602z"} + , + {"fill": "#e5e5b2", + "path":"M-74.792 183.132L-82.45 181.601C-85.05 176.601 -87.15 170.451 -87.15 170.451C-87.15 170.451 -80.8 171.451 -68.3 174.251C-68.3 174.251 -67.424 177.569 -65.952 183.364L-74.792 183.132z"} + , + {"fill": "#e5e5b2", + "path":"M-9.724 178.47C-11.39 175.964 -12.707 174.206 -13.357 173.8C-16.37 171.917 -12.227 172.294 -11.098 172.294C-11.098 172.294 5.473 172.294 7.356 173.047C7.356 173.047 7.88 175.289 8.564 178.68C8.564 178.68 -1.524 176.67 -9.724 178.47z"} + , + {"fill": "#cc7226", + "path":"M43.88 40.321C71.601 44.281 97.121 8.641 98.881 -1.04C100.641 -10.72 90.521 -22.6 90.521 -22.6C91.841 -25.68 87.001 -39.76 81.721 -49C76.441 -58.24 60.54 -57.266 43 -58.24C27.16 -59.12 8.68 -35.8 7.36 -34.04C6.04 -32.28 12.2 6.001 13.52 11.721C14.84 17.441 12.2 43.841 12.2 43.841C46.44 34.741 16.16 36.361 43.88 40.321z"} + , + {"fill": "#ea8e51", + "path":"M8.088 -33.392C6.792 -31.664 12.84 5.921 14.136 11.537C15.432 17.153 12.84 43.073 12.84 43.073C45.512 34.193 16.728 35.729 43.944 39.617C71.161 43.505 96.217 8.513 97.945 -0.992C99.673 -10.496 89.737 -22.16 89.737 -22.16C91.033 -25.184 86.281 -39.008 81.097 -48.08C75.913 -57.152 60.302 -56.195 43.08 -57.152C27.528 -58.016 9.384 -35.12 8.088 -33.392z"} + , + {"fill": "#efaa7c", + "path":"M8.816 -32.744C7.544 -31.048 13.48 5.841 14.752 11.353C16.024 16.865 13.48 42.305 13.48 42.305C44.884 33.145 17.296 35.097 44.008 38.913C70.721 42.729 95.313 8.385 97.009 -0.944C98.705 -10.272 88.953 -21.72 88.953 -21.72C90.225 -24.688 85.561 -38.256 80.473 -47.16C75.385 -56.064 60.063 -55.125 43.16 -56.064C27.896 -56.912 10.088 -34.44 8.816 -32.744z"} + , + {"fill": "#f4c6a8", + "path":"M9.544 -32.096C8.296 -30.432 14.12 5.761 15.368 11.169C16.616 16.577 14.12 41.537 14.12 41.537C43.556 32.497 17.864 34.465 44.072 38.209C70.281 41.953 94.409 8.257 96.073 -0.895C97.737 -10.048 88.169 -21.28 88.169 -21.28C89.417 -24.192 84.841 -37.504 79.849 -46.24C74.857 -54.976 59.824 -54.055 43.24 -54.976C28.264 -55.808 10.792 -33.76 9.544 -32.096z"} + , + {"fill": "#f9e2d3", + "path":"M10.272 -31.448C9.048 -29.816 14.76 5.681 15.984 10.985C17.208 16.289 14.76 40.769 14.76 40.769C42.628 31.849 18.432 33.833 44.136 37.505C69.841 41.177 93.505 8.129 95.137 -0.848C96.769 -9.824 87.385 -20.84 87.385 -20.84C88.609 -23.696 84.121 -36.752 79.225 -45.32C74.329 -53.888 59.585 -52.985 43.32 -53.888C28.632 -54.704 11.496 -33.08 10.272 -31.448z"} + , + {"fill": "#ffffff", + "path":"M44.2 36.8C69.4 40.4 92.601 8 94.201 -0.8C95.801 -9.6 86.601 -20.4 86.601 -20.4C87.801 -23.2 83.4 -36 78.6 -44.4C73.8 -52.8 59.346 -51.914 43.4 -52.8C29 -53.6 12.2 -32.4 11 -30.8C9.8 -29.2 15.4 5.6 16.6 10.8C17.8 16 15.4 40 15.4 40C40.9 31.4 19 33.2 44.2 36.8z"} + , + {"fill": "#cccccc", + "path":"M90.601 2.8C90.601 2.8 62.8 10.4 51.2 8.8C51.2 8.8 35.4 2.2 26.6 24C26.6 24 23 31.2 21 33.2C19 35.2 90.601 2.8 90.601 2.8z"} + , + {"fill": "#000000", + "path":"M94.401 0.6C94.401 0.6 65.4 12.8 55.4 12.4C55.4 12.4 39 7.8 30.6 22.4C30.6 22.4 22.2 31.6 19 33.2C19 33.2 18.6 34.8 25 30.8L35.4 36C35.4 36 50.2 45.6 59.8 29.6C59.8 29.6 63.8 18.4 63.8 16.4C63.8 14.4 85 8.8 86.601 8.4C88.201 8 94.801 3.8 94.401 0.6z"} + , + {"fill": "#99cc32", + "path":"M47 36.514C40.128 36.514 31.755 32.649 31.755 26.4C31.755 20.152 40.128 13.887 47 13.887C53.874 13.887 59.446 18.952 59.446 25.2C59.446 31.449 53.874 36.514 47 36.514z"} + , + {"fill": "#659900", + "path":"M43.377 19.83C38.531 20.552 33.442 22.055 33.514 21.839C35.054 17.22 41.415 13.887 47 13.887C51.296 13.887 55.084 15.865 57.32 18.875C57.32 18.875 52.004 18.545 43.377 19.83z"} + , + {"fill": "#ffffff", + "path":"M55.4 19.6C55.4 19.6 51 16.4 51 18.6C51 18.6 54.6 23 55.4 19.6z"} + , + {"fill": "#000000", + "path":"M45.4 27.726C42.901 27.726 40.875 25.7 40.875 23.2C40.875 20.701 42.901 18.675 45.4 18.675C47.9 18.675 49.926 20.701 49.926 23.2C49.926 25.7 47.9 27.726 45.4 27.726z"} + , + {"fill": "#cc7226", + "path":"M-58.6 14.4C-58.6 14.4 -61.8 -6.8 -59.4 -11.2C-59.4 -11.2 -48.6 -21.2 -49 -24.8C-49 -24.8 -49.4 -42.8 -50.6 -43.6C-51.8 -44.4 -59.4 -50.4 -65.4 -44C-65.4 -44 -75.8 -26 -75 -19.6L-75 -17.6C-75 -17.6 -82.6 -18 -84.2 -16C-84.2 -16 -85.4 -10.8 -86.6 -10.4C-86.6 -10.4 -89.4 -8 -87.4 -5.2C-87.4 -5.2 -89.4 -2.8 -89 1.2L-81.4 5.2C-81.4 5.2 -79.4 19.6 -68.6 24.8C-63.764 27.129 -60.6 20.4 -58.6 14.4z"} + , + {"fill": "#ffffff", + "path":"M-59.6 12.56C-59.6 12.56 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.48 -40.36 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.96 -59.6 12.56z"} + , + {"fill": "#eb955c", + "path":"M-51.05 -42.61C-52.14 -43.47 -59.63 -49.24 -65.48 -43C-65.48 -43 -75.62 -25.45 -74.84 -19.21L-74.84 -17.26C-74.84 -17.26 -82.25 -17.65 -83.81 -15.7C-83.81 -15.7 -84.98 -10.63 -86.15 -10.24C-86.15 -10.24 -88.88 -7.9 -86.93 -5.17C-86.93 -5.17 -88.88 -2.83 -88.49 1.07L-81.08 4.97C-81.08 4.97 -79.13 19.01 -68.6 24.08C-63.886 26.35 -60.8 19.79 -58.85 13.94C-58.85 13.94 -61.97 -6.73 -59.63 -11.02C-59.63 -11.02 -49.1 -20.77 -49.49 -24.28C-49.49 -24.28 -49.88 -41.83 -51.05 -42.61z"} + , + {"fill": "#f2b892", + "path":"M-51.5 -41.62C-52.48 -42.54 -59.86 -48.08 -65.56 -42C-65.56 -42 -75.44 -24.9 -74.68 -18.82L-74.68 -16.92C-74.68 -16.92 -81.9 -17.3 -83.42 -15.4C-83.42 -15.4 -84.56 -10.46 -85.7 -10.08C-85.7 -10.08 -88.36 -7.8 -86.46 -5.14C-86.46 -5.14 -88.36 -2.86 -87.98 0.94L-80.76 4.74C-80.76 4.74 -78.86 18.42 -68.6 23.36C-64.006 25.572 -61 19.18 -59.1 13.48C-59.1 13.48 -62.14 -6.66 -59.86 -10.84C-59.86 -10.84 -49.6 -20.34 -49.98 -23.76C-49.98 -23.76 -50.36 -40.86 -51.5 -41.62z"} + , + {"fill": "#f8dcc8", + "path":"M-51.95 -40.63C-52.82 -41.61 -60.09 -46.92 -65.64 -41C-65.64 -41 -75.26 -24.35 -74.52 -18.43L-74.52 -16.58C-74.52 -16.58 -81.55 -16.95 -83.03 -15.1C-83.03 -15.1 -84.14 -10.29 -85.25 -9.92C-85.25 -9.92 -87.84 -7.7 -85.99 -5.11C-85.99 -5.11 -87.84 -2.89 -87.47 0.81L-80.44 4.51C-80.44 4.51 -78.59 17.83 -68.6 22.64C-64.127 24.794 -61.2 18.57 -59.35 13.02C-59.35 13.02 -62.31 -6.59 -60.09 -10.66C-60.09 -10.66 -50.1 -19.91 -50.47 -23.24C-50.47 -23.24 -50.84 -39.89 -51.95 -40.63z"} + , + {"fill": "#ffffff", + "path":"M-59.6 12.46C-59.6 12.46 -62.48 -6.52 -60.32 -10.48C-60.32 -10.48 -50.6 -19.48 -50.96 -22.72C-50.96 -22.72 -51.32 -38.92 -52.4 -39.64C-53.16 -40.68 -60.32 -45.76 -65.72 -40C-65.72 -40 -75.08 -23.8 -74.36 -18.04L-74.36 -16.24C-74.36 -16.24 -81.2 -16.6 -82.64 -14.8C-82.64 -14.8 -83.72 -10.12 -84.8 -9.76C-84.8 -9.76 -87.32 -7.6 -85.52 -5.08C-85.52 -5.08 -87.32 -2.92 -86.96 0.68L-80.12 4.28C-80.12 4.28 -78.32 17.24 -68.6 21.92C-64.248 24.015 -61.4 17.86 -59.6 12.46z"} + , + {"fill": "#cccccc", + "path":"M-62.7 6.2C-62.7 6.2 -84.3 -4 -85.2 -4.8C-85.2 -4.8 -76.1 3.4 -75.3 3.4C-74.5 3.4 -62.7 6.2 -62.7 6.2z"} + , + {"fill": "#000000", + "path":"M-79.8 0C-79.8 0 -61.4 3.6 -61.4 8C-61.4 10.912 -61.643 24.331 -67 22.8C-75.4 20.4 -71.8 6 -79.8 0z"} + , + {"fill": "#99cc32", + "path":"M-71.4 3.8C-71.4 3.8 -62.422 5.274 -61.4 8C-60.8 9.6 -60.137 17.908 -65.6 19C-70.152 19.911 -72.382 9.69 -71.4 3.8z"} + , + {"fill": "#000000", + "path":"M14.595 46.349C14.098 44.607 15.409 44.738 17.2 44.2C19.2 43.6 31.4 39.8 32.2 37.2C33 34.6 46.2 39 46.2 39C48 39.8 52.4 42.4 52.4 42.4C57.2 43.6 63.8 44 63.8 44C66.2 45 69.6 47.8 69.6 47.8C84.2 58 96.601 50.8 96.601 50.8C116.601 44.2 110.601 27 110.601 27C107.601 18 110.801 14.6 110.801 14.6C111.001 10.8 118.201 17.2 118.201 17.2C120.801 21.4 121.601 26.4 121.601 26.4C129.601 37.6 126.201 19.8 126.201 19.8C126.401 18.8 123.601 15.2 123.601 14C123.601 12.8 121.801 9.4 121.801 9.4C118.801 6 121.201 -1 121.201 -1C123.001 -14.8 120.801 -13 120.801 -13C119.601 -14.8 110.401 -4.8 110.401 -4.8C108.201 -1.4 102.201 0.2 102.201 0.2C99.401 2 96.001 0.6 96.001 0.6C93.401 0.2 87.801 7.2 87.801 7.2C90.601 7 93.001 11.4 95.401 11.6C97.801 11.8 99.601 9.2 101.201 8.6C102.801 8 105.601 13.8 105.601 13.8C106.001 16.4 100.401 21.2 100.401 21.2C100.001 25.8 98.401 24.2 98.401 24.2C95.401 23.6 94.201 27.4 93.201 32C92.201 36.6 88.001 37 88.001 37C86.401 44.4 85.2 41.4 85.2 41.4C85 35.8 79 41.6 79 41.6C77.8 43.6 73.2 41.4 73.2 41.4C66.4 39.4 68.8 37.4 68.8 37.4C70.6 35.2 81.8 37.4 81.8 37.4C84 35.8 76 31.8 76 31.8C75.4 30 76.4 25.6 76.4 25.6C77.6 22.4 84.4 16.8 84.4 16.8C93.801 15.6 91.001 14 91.001 14C84.801 8.8 79 16.4 79 16.4C76.8 22.6 59.4 37.6 59.4 37.6C54.6 41 57.2 34.2 53.2 37.6C49.2 41 28.6 32 28.6 32C17.038 30.807 14.306 46.549 10.777 43.429C10.777 43.429 16.195 51.949 14.595 46.349z"} + , + {"fill": "#000000", + "path":"M209.401 -120C209.401 -120 183.801 -112 181.001 -93.2C181.001 -93.2 178.601 -70.4 199.001 -52.8C199.001 -52.8 199.401 -46.4 201.401 -43.2C201.401 -43.2 199.801 -38.4 218.601 -46L245.801 -54.4C245.801 -54.4 252.201 -56.8 257.401 -65.6C262.601 -74.4 277.801 -93.2 274.201 -118.4C274.201 -118.4 275.401 -129.6 269.401 -130C269.401 -130 261.001 -131.6 253.801 -124C253.801 -124 247.001 -120.8 244.601 -121.2L209.401 -120z"} + , + {"fill": "#000000", + "path":"M264.022 -120.99C264.022 -120.99 266.122 -129.92 261.282 -125.08C261.282 -125.08 254.242 -119.36 246.761 -119.36C246.761 -119.36 232.241 -117.16 227.841 -103.96C227.841 -103.96 223.881 -77.12 231.801 -71.4C231.801 -71.4 236.641 -63.92 243.681 -70.52C250.722 -77.12 266.222 -107.35 264.022 -120.99z"} + , + {"fill": "#323232", + "path":"M263.648 -120.632C263.648 -120.632 265.738 -129.376 260.986 -124.624C260.986 -124.624 254.074 -119.008 246.729 -119.008C246.729 -119.008 232.473 -116.848 228.153 -103.888C228.153 -103.888 224.265 -77.536 232.041 -71.92C232.041 -71.92 236.793 -64.576 243.705 -71.056C250.618 -77.536 265.808 -107.24 263.648 -120.632z"} + , + {"fill": "#666666", + "path":"M263.274 -120.274C263.274 -120.274 265.354 -128.832 260.69 -124.168C260.69 -124.168 253.906 -118.656 246.697 -118.656C246.697 -118.656 232.705 -116.536 228.465 -103.816C228.465 -103.816 224.649 -77.952 232.281 -72.44C232.281 -72.44 236.945 -65.232 243.729 -71.592C250.514 -77.952 265.394 -107.13 263.274 -120.274z"} + , + {"fill": "#999999", + "path":"M262.9 -119.916C262.9 -119.916 264.97 -128.288 260.394 -123.712C260.394 -123.712 253.738 -118.304 246.665 -118.304C246.665 -118.304 232.937 -116.224 228.777 -103.744C228.777 -103.744 225.033 -78.368 232.521 -72.96C232.521 -72.96 237.097 -65.888 243.753 -72.128C250.41 -78.368 264.98 -107.02 262.9 -119.916z"} + , + {"fill": "#cccccc", + "path":"M262.526 -119.558C262.526 -119.558 264.586 -127.744 260.098 -123.256C260.098 -123.256 253.569 -117.952 246.633 -117.952C246.633 -117.952 233.169 -115.912 229.089 -103.672C229.089 -103.672 225.417 -78.784 232.761 -73.48C232.761 -73.48 237.249 -66.544 243.777 -72.664C250.305 -78.784 264.566 -106.91 262.526 -119.558z"} + , + {"fill": "#ffffff", + "path":"M262.151 -119.2C262.151 -119.2 264.201 -127.2 259.801 -122.8C259.801 -122.8 253.401 -117.6 246.601 -117.6C246.601 -117.6 233.401 -115.6 229.401 -103.6C229.401 -103.6 225.801 -79.2 233.001 -74C233.001 -74 237.401 -67.2 243.801 -73.2C250.201 -79.2 264.151 -106.8 262.151 -119.2z"} + , + {"fill": "#992600", + "path":"M50.6 84C50.6 84 30.2 64.8 22.2 64C22.2 64 -12.2 60 -27 78C-27 78 -9.4 57.6 18.2 63.2C18.2 63.2 -3.4 58.8 -15.8 62C-15.8 62 -32.6 62 -42.2 76L-45 80.8C-45 80.8 -41 66 -22.6 60C-22.6 60 0.2 55.2 11 60C11 60 -10.6 53.2 -20.6 55.2C-20.6 55.2 -51 52.8 -63.8 79.2C-63.8 79.2 -59.8 64.8 -45 57.6C-45 57.6 -31.4 48.8 -11 51.6C-11 51.6 3.4 54.8 8.6 57.2C13.8 59.6 12.6 56.8 4.2 52C4.2 52 -1.4 42 -15.4 42.4C-15.4 42.4 -58.2 46 -68.6 58C-68.6 58 -55 46.8 -44.6 44C-44.6 44 -22.2 36 -13.8 36.8C-13.8 36.8 11 37.8 18.6 33.8C18.6 33.8 7.4 38.8 10.6 42C13.8 45.2 20.6 52.8 20.6 54C20.6 55.2 44.8 77.3 48.4 81.7L50.6 84z"} + , + {"fill": "#cccccc", + "path":"M189 278C189 278 173.5 241.5 161 232C161 232 187 248 190.5 266C190.5 266 190.5 276 189 278z"} + , + {"fill": "#cccccc", + "path":"M236 285.5C236 285.5 209.5 230.5 191 206.5C191 206.5 234.5 244 239.5 270.5L240 276L237 273.5C237 273.5 236.5 282.5 236 285.5z"} + , + {"fill": "#cccccc", + "path":"M292.5 237C292.5 237 230 177.5 228.5 175C228.5 175 289 241 292 248.5C292 248.5 290 239.5 292.5 237z"} + , + {"fill": "#cccccc", + "path":"M104 280.5C104 280.5 123.5 228.5 142.5 251C142.5 251 157.5 261 157 264C157 264 153 257.5 135 258C135 258 116 255 104 280.5z"} + , + {"fill": "#cccccc", + "path":"M294.5 153C294.5 153 249.5 124.5 242 123C230.193 120.639 291.5 152 296.5 162.5C296.5 162.5 298.5 160 294.5 153z"} + , + {"fill": "#000000", + "path":"M143.801 259.601C143.801 259.601 164.201 257.601 171.001 250.801L175.401 254.401L193.001 216.001L196.601 221.201C196.601 221.201 211.001 206.401 210.201 198.401C209.401 190.401 223.001 204.401 223.001 204.401C223.001 204.401 222.201 192.801 229.401 199.601C229.401 199.601 227.001 184.001 235.401 192.001C235.401 192.001 224.864 161.844 247.401 187.601C253.001 194.001 248.601 187.201 248.601 187.201C248.601 187.201 222.601 139.201 244.201 153.601C244.201 153.601 246.201 130.801 245.001 126.401C243.801 122.001 241.801 99.6 237.001 94.4C232.201 89.2 237.401 87.6 243.001 92.8C243.001 92.8 231.801 68.8 245.001 80.8C245.001 80.8 241.401 65.6 237.001 62.8C237.001 62.8 231.401 45.6 246.601 56.4C246.601 56.4 242.201 44 239.001 40.8C239.001 40.8 227.401 13.2 234.601 18L239.001 21.6C239.001 21.6 232.201 7.6 238.601 12C245.001 16.4 245.001 16 245.001 16C245.001 16 223.801 -17.2 244.201 0.4C244.201 0.4 236.042 -13.518 232.601 -20.4C232.601 -20.4 213.801 -40.8 228.201 -34.4L233.001 -32.8C233.001 -32.8 224.201 -42.8 216.201 -44.4C208.201 -46 218.601 -52.4 225.001 -50.4C231.401 -48.4 247.001 -40.8 247.001 -40.8C247.001 -40.8 259.801 -22 263.801 -21.6C263.801 -21.6 243.801 -29.2 249.801 -21.2C249.801 -21.2 264.201 -7.2 257.001 -7.6C257.001 -7.6 251.001 -0.4 255.801 8.4C255.801 8.4 237.342 -9.991 252.201 15.6L259.001 32C259.001 32 234.601 7.2 245.801 29.2C245.801 29.2 263.001 52.8 265.001 53.2C267.001 53.6 271.401 62.4 271.401 62.4L267.001 60.4L272.201 69.2C272.201 69.2 261.001 57.2 267.001 70.4L272.601 84.8C272.601 84.8 252.201 62.8 265.801 92.4C265.801 92.4 249.401 87.2 258.201 104.4C258.201 104.4 256.601 120.401 257.001 125.601C257.401 130.801 258.601 159.201 254.201 167.201C249.801 175.201 260.201 194.401 262.201 198.401C264.201 202.401 267.801 213.201 259.001 204.001C250.201 194.801 254.601 200.401 256.601 209.201C258.601 218.001 264.601 233.601 263.801 239.201C263.801 239.201 262.601 240.401 259.401 236.801C259.401 236.801 244.601 214.001 246.201 228.401C246.201 228.401 245.001 236.401 241.801 245.201C241.801 245.201 238.601 256.001 238.601 247.201C238.601 247.201 235.401 230.401 232.601 238.001C229.801 245.601 226.201 251.601 223.401 254.001C220.601 256.401 215.401 233.601 214.201 244.001C214.201 244.001 202.201 231.601 197.401 248.001L185.801 264.401C185.801 264.401 185.401 252.001 184.201 258.001C184.201 258.001 154.201 264.001 143.801 259.601z"} + , + {"fill": "#000000", + "path":"M109.401 -97.2C109.401 -97.2 97.801 -105.2 93.801 -104.8C89.801 -104.4 121.401 -113.6 162.601 -86C162.601 -86 167.401 -83.2 171.001 -83.6C171.001 -83.6 174.201 -81.2 171.401 -77.6C171.401 -77.6 162.601 -68 173.801 -56.8C173.801 -56.8 192.201 -50 186.601 -58.8C186.601 -58.8 197.401 -54.8 199.801 -50.8C202.201 -46.8 201.001 -50.8 201.001 -50.8C201.001 -50.8 194.601 -58 188.601 -63.2C188.601 -63.2 183.401 -65.2 180.601 -73.6C177.801 -82 175.401 -92 179.801 -95.2C179.801 -95.2 175.801 -90.8 176.601 -94.8C177.401 -98.8 181.001 -102.4 182.601 -102.8C184.201 -103.2 200.601 -119 207.401 -119.4C207.401 -119.4 198.201 -118 195.201 -119C192.201 -120 165.601 -131.4 159.601 -132.6C159.601 -132.6 142.801 -139.2 154.801 -137.2C154.801 -137.2 190.601 -133.4 208.801 -120.2C208.801 -120.2 201.601 -128.6 183.201 -135.6C183.201 -135.6 161.001 -148.2 125.801 -143.2C125.801 -143.2 108.001 -140 100.201 -138.2C100.201 -138.2 97.601 -138.8 97.001 -139.2C96.401 -139.6 84.6 -148.6 57 -141.6C57 -141.6 40 -137 31.4 -132.2C31.4 -132.2 16.2 -131 12.6 -127.8C12.6 -127.8 -6 -113.2 -8 -112.4C-10 -111.6 -21.4 -104 -22.2 -103.6C-22.2 -103.6 2.4 -110.2 4.8 -112.6C7.2 -115 24.6 -117.6 27 -116.2C29.4 -114.8 37.8 -115.4 28.2 -114.8C28.2 -114.8 103.801 -100 104.601 -98C105.401 -96 109.401 -97.2 109.401 -97.2z"} + , + {"fill": "#cc7226", + "path":"M180.801 -106.4C180.801 -106.4 170.601 -113.8 168.601 -113.8C166.601 -113.8 154.201 -124 150.001 -123.6C145.801 -123.2 133.601 -133.2 106.201 -125C106.201 -125 105.601 -127 109.201 -127.8C109.201 -127.8 115.601 -130 116.001 -130.6C116.001 -130.6 136.201 -134.8 143.401 -131.2C143.401 -131.2 152.601 -128.6 158.801 -122.4C158.801 -122.4 170.001 -119.2 173.201 -120.2C173.201 -120.2 182.001 -118 182.401 -116.2C182.401 -116.2 188.201 -113.2 186.401 -110.6C186.401 -110.6 186.801 -109 180.801 -106.4z"} + , + {"fill": "#cc7226", + "path":"M168.33 -108.509C169.137 -107.877 170.156 -107.779 170.761 -106.97C170.995 -106.656 170.706 -106.33 170.391 -106.233C169.348 -105.916 168.292 -106.486 167.15 -105.898C166.748 -105.691 166.106 -105.873 165.553 -106.022C163.921 -106.463 162.092 -106.488 160.401 -105.8C158.416 -106.929 156.056 -106.345 153.975 -107.346C153.917 -107.373 153.695 -107.027 153.621 -107.054C150.575 -108.199 146.832 -107.916 144.401 -110.2C141.973 -110.612 139.616 -111.074 137.188 -111.754C135.37 -112.263 133.961 -113.252 132.341 -114.084C130.964 -114.792 129.507 -115.314 127.973 -115.686C126.11 -116.138 124.279 -116.026 122.386 -116.546C122.293 -116.571 122.101 -116.227 122.019 -116.254C121.695 -116.362 121.405 -116.945 121.234 -116.892C119.553 -116.37 118.065 -117.342 116.401 -117C115.223 -118.224 113.495 -117.979 111.949 -118.421C108.985 -119.269 105.831 -117.999 102.801 -119C106.914 -120.842 111.601 -119.61 115.663 -121.679C117.991 -122.865 120.653 -121.763 123.223 -122.523C123.71 -122.667 124.401 -122.869 124.801 -122.2C124.935 -122.335 125.117 -122.574 125.175 -122.546C127.625 -121.389 129.94 -120.115 132.422 -119.049C132.763 -118.903 133.295 -119.135 133.547 -118.933C135.067 -117.717 137.01 -117.82 138.401 -116.6C140.099 -117.102 141.892 -116.722 143.621 -117.346C143.698 -117.373 143.932 -117.032 143.965 -117.054C145.095 -117.802 146.25 -117.531 147.142 -117.227C147.48 -117.112 148.143 -116.865 148.448 -116.791C149.574 -116.515 150.43 -116.035 151.609 -115.852C151.723 -115.834 151.908 -116.174 151.98 -116.146C153.103 -115.708 154.145 -115.764 154.801 -114.6C154.936 -114.735 155.101 -114.973 155.183 -114.946C156.21 -114.608 156.859 -113.853 157.96 -113.612C158.445 -113.506 159.057 -112.88 159.633 -112.704C162.025 -111.973 163.868 -110.444 166.062 -109.549C166.821 -109.239 167.697 -109.005 168.33 -108.509z"} + , + {"fill": "#cc7226", + "path":"M91.696 -122.739C89.178 -124.464 86.81 -125.57 84.368 -127.356C84.187 -127.489 83.827 -127.319 83.625 -127.441C82.618 -128.05 81.73 -128.631 80.748 -129.327C80.209 -129.709 79.388 -129.698 78.88 -129.956C76.336 -131.248 73.707 -131.806 71.2 -133C71.882 -133.638 73.004 -133.394 73.6 -134.2C73.795 -133.92 74.033 -133.636 74.386 -133.827C76.064 -134.731 77.914 -134.884 79.59 -134.794C81.294 -134.702 83.014 -134.397 84.789 -134.125C85.096 -134.078 85.295 -133.555 85.618 -133.458C87.846 -132.795 90.235 -133.32 92.354 -132.482C93.945 -131.853 95.515 -131.03 96.754 -129.755C97.006 -129.495 96.681 -129.194 96.401 -129C96.789 -129.109 97.062 -128.903 97.173 -128.59C97.257 -128.351 97.257 -128.049 97.173 -127.81C97.061 -127.498 96.782 -127.397 96.408 -127.346C95.001 -127.156 96.773 -128.536 96.073 -128.088C94.8 -127.274 95.546 -125.868 94.801 -124.6C94.521 -124.794 94.291 -125.012 94.401 -125.4C94.635 -124.878 94.033 -124.588 93.865 -124.272C93.48 -123.547 92.581 -122.132 91.696 -122.739z"} + , + {"fill": "#cc7226", + "path":"M59.198 -115.391C56.044 -116.185 52.994 -116.07 49.978 -117.346C49.911 -117.374 49.688 -117.027 49.624 -117.054C48.258 -117.648 47.34 -118.614 46.264 -119.66C45.351 -120.548 43.693 -120.161 42.419 -120.648C42.095 -120.772 41.892 -121.284 41.591 -121.323C40.372 -121.48 39.445 -122.429 38.4 -123C40.736 -123.795 43.147 -123.764 45.609 -124.148C45.722 -124.166 45.867 -123.845 46 -123.845C46.136 -123.845 46.266 -124.066 46.4 -124.2C46.595 -123.92 46.897 -123.594 47.154 -123.848C47.702 -124.388 48.258 -124.198 48.798 -124.158C48.942 -124.148 49.067 -123.845 49.2 -123.845C49.336 -123.845 49.467 -124.156 49.6 -124.156C49.736 -124.155 49.867 -123.845 50 -123.845C50.136 -123.845 50.266 -124.066 50.4 -124.2C51.092 -123.418 51.977 -123.972 52.799 -123.793C53.837 -123.566 54.104 -122.418 55.178 -122.12C59.893 -120.816 64.03 -118.671 68.393 -116.584C68.7 -116.437 68.91 -116.189 68.8 -115.8C69.067 -115.8 69.38 -115.888 69.57 -115.756C70.628 -115.024 71.669 -114.476 72.366 -113.378C72.582 -113.039 72.253 -112.632 72.02 -112.684C67.591 -113.679 63.585 -114.287 59.198 -115.391z"} + , + {"fill": "#cc7226", + "path":"M45.338 -71.179C43.746 -72.398 43.162 -74.429 42.034 -76.221C41.82 -76.561 42.094 -76.875 42.411 -76.964C42.971 -77.123 43.514 -76.645 43.923 -76.443C45.668 -75.581 47.203 -74.339 49.2 -74.2C51.19 -71.966 55.45 -71.581 55.457 -68.2C55.458 -67.341 54.03 -68.259 53.6 -67.4C51.149 -68.403 48.76 -68.3 46.38 -69.767C45.763 -70.148 46.093 -70.601 45.338 -71.179z"} + , + {"fill": "#cc7226", + "path":"M17.8 -123.756C17.935 -123.755 24.966 -123.522 24.949 -123.408C24.904 -123.099 17.174 -122.05 16.81 -122.22C16.646 -122.296 9.134 -119.866 9 -120C9.268 -120.135 17.534 -123.756 17.8 -123.756z"} + , + {"fill": "#000000", + "path":"M33.2 -114C33.2 -114 18.4 -112.2 14 -111C9.6 -109.8 -9 -102.2 -12 -100.2C-12 -100.2 -25.4 -94.8 -42.4 -74.8C-42.4 -74.8 -34.8 -78.2 -32.6 -81C-32.6 -81 -19 -93.6 -19.2 -91C-19.2 -91 -7 -99.6 -7.6 -97.4C-7.6 -97.4 16.8 -108.6 14.8 -105.4C14.8 -105.4 36.4 -110 35.4 -108C35.4 -108 54.2 -103.6 51.4 -103.4C51.4 -103.4 45.6 -102.2 52 -98.6C52 -98.6 48.6 -94.2 43.2 -98.2C37.8 -102.2 40.8 -100 35.8 -99C35.8 -99 33.2 -98.2 28.6 -102.2C28.6 -102.2 23 -106.8 14.2 -103.2C14.2 -103.2 -16.4 -90.6 -18.4 -90C-18.4 -90 -22 -87.2 -24.4 -83.6C-24.4 -83.6 -30.2 -79.2 -33.2 -77.8C-33.2 -77.8 -46 -66.2 -47.2 -64.8C-47.2 -64.8 -50.6 -59.6 -51.4 -59.2C-51.4 -59.2 -45 -63 -43 -65C-43 -65 -29 -75 -23.6 -75.8C-23.6 -75.8 -19.2 -78.8 -18.4 -80.2C-18.4 -80.2 -4 -89.4 0.2 -89.4C0.2 -89.4 9.4 -84.2 11.8 -91.2C11.8 -91.2 17.6 -93 23.2 -91.8C23.2 -91.8 26.4 -94.4 25.6 -96.6C25.6 -96.6 27.2 -98.4 28.2 -94.6C28.2 -94.6 31.6 -91 36.4 -93C36.4 -93 40.4 -93.2 38.4 -90.8C38.4 -90.8 34 -87 22.2 -86.8C22.2 -86.8 9.8 -86.2 -6.6 -78.6C-6.6 -78.6 -36.4 -68.2 -45.6 -57.8C-45.6 -57.8 -52 -49 -57.4 -47.8C-57.4 -47.8 -63.2 -47 -69.2 -39.6C-69.2 -39.6 -59.4 -45.4 -50.4 -45.4C-50.4 -45.4 -46.4 -47.8 -50.2 -44.2C-50.2 -44.2 -53.8 -36.6 -52.2 -31.2C-52.2 -31.2 -52.8 -26 -53.6 -24.4C-53.6 -24.4 -61.4 -11.6 -61.4 -9.2C-61.4 -6.8 -60.2 3 -59.8 3.6C-59.4 4.2 -60.8 2 -57 4.4C-53.2 6.8 -50.4 8.4 -49.6 11.2C-48.8 14 -51.6 5.8 -51.8 4C-52 2.2 -56.2 -5 -55.4 -7.4C-55.4 -7.4 -54.4 -6.4 -53.6 -5C-53.6 -5 -54.2 -5.6 -53.6 -9.2C-53.6 -9.2 -52.8 -14.4 -51.4 -17.6C-50 -20.8 -48 -24.6 -47.6 -25.4C-47.2 -26.2 -47.2 -32 -45.8 -29.4L-42.4 -26.8C-42.4 -26.8 -45.2 -29.4 -43 -31.6C-43 -31.6 -44 -37.2 -42.2 -39.8C-42.2 -39.8 -35.2 -48.2 -33.6 -49.2C-32 -50.2 -33.4 -49.8 -33.4 -49.8C-33.4 -49.8 -27.4 -54 -33.2 -52.4C-33.2 -52.4 -37.2 -50.8 -40.2 -50.8C-40.2 -50.8 -47.8 -48.8 -43.8 -53C-39.8 -57.2 -29.8 -62.6 -26 -62.4L-25.2 -60.8L-14 -63.2L-15.2 -62.4C-15.2 -62.4 -15.4 -62.6 -11.2 -63C-7 -63.4 -1.2 -62 0.2 -63.8C1.6 -65.6 5 -66.6 4.6 -65.2C4.2 -63.8 4 -61.8 4 -61.8C4 -61.8 9 -67.6 8.4 -65.4C7.8 -63.2 -0.4 -58 -1.8 -51.8L8.6 -60L12.2 -63C12.2 -63 15.8 -60.8 16 -62.4C16.2 -64 20.8 -69.8 22 -69.6C23.2 -69.4 25.2 -72.2 25 -69.6C24.8 -67 32.4 -61.6 32.4 -61.6C32.4 -61.6 35.6 -63.4 37 -62C38.4 -60.6 42.6 -81.8 42.6 -81.8L67.6 -92.4L111.201 -95.8L94.201 -102.6L33.2 -114z"} + , + {"stroke":"#4c0000", "width":2, + "path":"M51.4 85C51.4 85 36.4 68.2 28 65.6C28 65.6 14.6 58.8 -10 66.6"} + , + {"stroke":"#4c0000", "width":2, + "path":"M24.8 64.2C24.8 64.2 -0.4 56.2 -15.8 60.4C-15.8 60.4 -34.2 62.4 -42.6 76.2"} + , + {"stroke":"#4c0000", "width":2, + "path":"M21.2 63C21.2 63 4.2 55.8 -10.6 53.6C-10.6 53.6 -27.2 51 -43.8 58.2C-43.8 58.2 -56 64.2 -61.4 74.4"} + , + {"stroke":"#4c0000", "width":2, + "path":"M22.2 63.4C22.2 63.4 6.8 52.4 5.8 51C5.8 51 -1.2 40 -14.2 39.6C-14.2 39.6 -35.6 40.4 -52.8 48.4"} + , + {"fill": "#000000", + "path":"M20.895 54.407C22.437 55.87 49.4 84.8 49.4 84.8C84.6 121.401 56.6 87.2 56.6 87.2C49 82.4 39.8 63.6 39.8 63.6C38.6 60.8 53.8 70.8 53.8 70.8C57.8 71.6 71.4 90.8 71.4 90.8C64.6 88.4 69.4 95.6 69.4 95.6C72.2 97.6 92.601 113.201 92.601 113.201C96.201 117.201 100.201 118.801 100.201 118.801C114.201 113.601 107.801 126.801 107.801 126.801C110.201 133.601 115.801 122.001 115.801 122.001C127.001 105.2 110.601 107.601 110.601 107.601C80.6 110.401 73.8 94.4 73.8 94.4C71.4 92 80.2 94.4 80.2 94.4C88.601 96.4 73 82 73 82C75.4 82 84.6 88.8 84.6 88.8C95.001 98 97.001 96 97.001 96C115.001 87.2 125.401 94.8 125.401 94.8C127.401 96.4 121.801 103.2 123.401 108.401C125.001 113.601 129.801 126.001 129.801 126.001C127.401 127.601 127.801 138.401 127.801 138.401C144.601 161.601 135.001 159.601 135.001 159.601C119.401 159.201 134.201 166.801 134.201 166.801C137.401 168.801 146.201 176.001 146.201 176.001C143.401 174.801 141.801 180.001 141.801 180.001C146.601 184.001 143.801 188.801 143.801 188.801C137.801 190.001 136.601 194.001 136.601 194.001C143.401 202.001 133.401 202.401 133.401 202.401C137.001 206.801 132.201 218.801 132.201 218.801C127.401 218.801 121.001 224.401 121.001 224.401C123.401 229.201 113.001 234.801 113.001 234.801C104.601 236.401 107.401 243.201 107.401 243.201C99.401 249.201 97.001 265.201 97.001 265.201C96.201 275.601 93.801 278.801 99.001 276.801C104.201 274.801 103.401 262.401 103.401 262.401C98.601 246.801 141.401 230.801 141.401 230.801C145.401 229.201 146.201 224.001 146.201 224.001C148.201 224.401 157.001 232.001 157.001 232.001C164.601 243.201 165.001 234.001 165.001 234.001C166.201 230.401 164.601 224.401 164.601 224.401C170.601 202.801 156.601 196.401 156.601 196.401C146.601 162.801 160.601 171.201 160.601 171.201C163.401 176.801 174.201 182.001 174.201 182.001L177.801 179.601C176.201 174.801 184.601 168.801 184.601 168.801C187.401 175.201 193.401 167.201 193.401 167.201C197.001 142.801 209.401 157.201 209.401 157.201C213.401 158.401 214.601 151.601 214.601 151.601C218.201 141.201 214.601 127.601 214.601 127.601C218.201 127.201 227.801 133.201 227.801 133.201C230.601 129.601 221.401 112.801 225.401 115.201C229.401 117.601 233.801 119.201 233.801 119.201C234.601 117.201 224.601 104.801 224.601 104.801C220.201 102 215.001 81.6 215.001 81.6C222.201 85.2 212.201 70 212.201 70C212.201 66.8 218.201 55.6 218.201 55.6C217.401 48.8 218.201 49.2 218.201 49.2C221.001 50.4 229.001 52 222.201 45.6C215.401 39.2 223.001 34.4 223.001 34.4C227.401 31.6 213.801 32 213.801 32C208.601 27.6 209.001 23.6 209.001 23.6C217.001 25.6 202.601 11.2 200.201 7.6C197.801 4 207.401 -1.2 207.401 -1.2C220.601 -4.8 209.001 -8 209.001 -8C189.401 -7.6 200.201 -18.4 200.201 -18.4C206.201 -18 204.601 -20.4 204.601 -20.4C199.401 -21.6 189.801 -28 189.801 -28C185.801 -31.6 189.401 -30.8 189.401 -30.8C206.201 -29.6 177.401 -40.8 177.401 -40.8C185.401 -40.8 167.401 -51.2 167.401 -51.2C165.401 -52.8 162.201 -60.4 162.201 -60.4C156.201 -65.6 151.401 -72.4 151.401 -72.4C151.001 -76.8 146.201 -81.6 146.201 -81.6C134.601 -95.2 129.001 -94.8 129.001 -94.8C114.201 -98.4 109.001 -97.6 109.001 -97.6L56.2 -93.2C29.8 -80.4 37.6 -59.4 37.6 -59.4C44 -51 53.2 -54.8 53.2 -54.8C57.8 -61 69.4 -58.8 69.4 -58.8C89.801 -55.6 87.201 -59.2 87.201 -59.2C84.801 -63.8 68.6 -70 68.4 -70.6C68.2 -71.2 59.4 -74.6 59.4 -74.6C56.4 -75.8 52 -85 52 -85C48.8 -88.4 64.6 -82.6 64.6 -82.6C63.4 -81.6 70.8 -77.6 70.8 -77.6C88.201 -78.6 98.801 -67.8 98.801 -67.8C109.601 -51.2 109.801 -59.4 109.801 -59.4C112.601 -68.8 100.801 -90 100.801 -90C101.201 -92 109.401 -85.4 109.401 -85.4C110.801 -87.4 111.601 -81.6 111.601 -81.6C111.801 -79.2 115.601 -71.2 115.601 -71.2C118.401 -58.2 122.001 -65.6 122.001 -65.6L126.601 -56.2C128.001 -53.6 122.001 -46 122.001 -46C121.801 -43.2 122.601 -43.4 117.001 -35.8C111.401 -28.2 114.801 -23.8 114.801 -23.8C113.401 -17.2 122.201 -17.6 122.201 -17.6C124.801 -15.4 128.201 -15.4 128.201 -15.4C130.001 -13.4 132.401 -14 132.401 -14C134.001 -17.8 140.201 -15.8 140.201 -15.8C141.601 -18.2 149.801 -18.6 149.801 -18.6C150.801 -21.2 151.201 -22.8 154.601 -23.4C158.001 -24 133.401 -67 133.401 -67C139.801 -67.8 131.601 -80.2 131.601 -80.2C129.401 -86.8 140.801 -72.2 143.001 -70.8C145.201 -69.4 146.201 -67.2 144.601 -67.4C143.001 -67.6 141.201 -65.4 142.601 -65.2C144.001 -65 157.001 -50 160.401 -39.8C163.801 -29.6 169.801 -25.6 176.001 -19.6C182.201 -13.6 181.401 10.6 181.401 10.6C181.001 19.4 187.001 30 187.001 30C189.001 33.8 184.801 52 184.801 52C182.801 54.2 184.201 55 184.201 55C185.201 56.2 192.001 69.4 192.001 69.4C190.201 69.2 193.801 72.8 193.801 72.8C199.001 78.8 192.601 75.8 192.601 75.8C186.601 74.2 193.601 84 193.601 84C194.801 85.8 185.801 81.2 185.801 81.2C176.601 80.6 188.201 87.8 188.201 87.8C196.801 95 185.401 90.6 185.401 90.6C180.801 88.8 184.001 95.6 184.001 95.6C187.201 97.2 204.401 104.2 204.401 104.2C204.801 108.001 201.801 113.001 201.801 113.001C202.201 117.001 200.001 120.401 200.001 120.401C198.801 128.601 198.201 129.401 198.201 129.401C194.001 129.601 186.601 143.401 186.601 143.401C184.801 146.001 174.601 158.001 174.601 158.001C172.601 165.001 154.601 157.801 154.601 157.801C148.001 161.201 150.001 157.801 150.001 157.801C149.601 155.601 154.401 149.601 154.401 149.601C161.401 147.001 158.801 136.201 158.801 136.201C162.801 134.801 151.601 132.001 151.801 130.801C152.001 129.601 157.801 128.201 157.801 128.201C165.801 126.201 161.401 123.801 161.401 123.801C160.801 119.801 163.801 114.201 163.801 114.201C175.401 113.401 163.801 97.2 163.801 97.2C153.001 89.6 152.001 83.8 152.001 83.8C164.601 75.6 156.401 63.2 156.601 59.6C156.801 56 158.001 34.4 158.001 34.4C156.001 28.2 153.001 14.6 153.001 14.6C155.201 9.4 162.601 -3.2 162.601 -3.2C165.401 -7.4 174.201 -12.2 172.001 -15.2C169.801 -18.2 162.001 -16.4 162.001 -16.4C154.201 -17.8 154.801 -12.6 154.801 -12.6C153.201 -11.6 152.401 -6.6 152.401 -6.6C151.68 1.333 142.801 7.6 142.801 7.6C131.601 13.8 140.801 17.8 140.801 17.8C146.801 24.4 137.001 24.6 137.001 24.6C126.001 22.8 134.201 33 134.201 33C145.001 45.8 142.001 48.6 142.001 48.6C131.801 49.6 144.401 58.8 144.401 58.8C144.401 58.8 143.601 56.8 143.801 58.6C144.001 60.4 147.001 64.6 147.801 66.6C148.601 68.6 144.601 68.8 144.601 68.8C145.201 78.4 129.801 74.2 129.801 74.2C129.801 74.2 129.801 74.2 128.201 74.4C126.601 74.6 115.401 73.8 109.601 71.6C103.801 69.4 97.001 69.4 97.001 69.4C97.001 69.4 93.001 71.2 85.4 71C77.8 70.8 69.8 73.6 69.8 73.6C65.4 73.2 74 68.8 74.2 69C74.4 69.2 80 63.6 72 64.2C50.203 65.835 39.4 55.6 39.4 55.6C37.4 54.2 34.8 51.4 34.8 51.4C24.8 49.4 36.2 63.8 36.2 63.8C37.4 65.2 36 66.2 36 66.2C35.2 64.6 27.4 59.2 27.4 59.2C24.589 58.227 23.226 56.893 20.895 54.407z"} + , + {"fill": "#4c0000", + "path":"M-3 42.8C-3 42.8 8.6 48.4 11.2 51.2C13.8 54 27.8 65.4 27.8 65.4C27.8 65.4 22.4 63.4 19.8 61.6C17.2 59.8 6.4 51.6 6.4 51.6C6.4 51.6 2.6 45.6 -3 42.8z"} + , + {"fill": "#99cc32", + "path":"M-61.009 11.603C-60.672 11.455 -61.196 8.743 -61.4 8.2C-62.422 5.474 -71.4 4 -71.4 4C-71.627 5.365 -71.682 6.961 -71.576 8.599C-71.576 8.599 -66.708 14.118 -61.009 11.603z"} + , + {"fill": "#659900", + "path":"M-61.009 11.403C-61.458 11.561 -61.024 8.669 -61.2 8.2C-62.222 5.474 -71.4 3.9 -71.4 3.9C-71.627 5.265 -71.682 6.861 -71.576 8.499C-71.576 8.499 -67.308 13.618 -61.009 11.403z"} + , + {"fill": "#000000", + "path":"M-65.4 11.546C-66.025 11.546 -66.531 10.406 -66.531 9C-66.531 7.595 -66.025 6.455 -65.4 6.455C-64.775 6.455 -64.268 7.595 -64.268 9C-64.268 10.406 -64.775 11.546 -65.4 11.546z"} + , + {"fill": "#000000", + "path":"M-65.4 9z"} + , + {"fill": "#000000", + "path":"M-111 109.601C-111 109.601 -116.6 119.601 -91.8 113.601C-91.8 113.601 -77.8 112.401 -75.4 110.001C-74.2 110.801 -65.834 113.734 -63 114.401C-56.2 116.001 -47.8 106 -47.8 106C-47.8 106 -43.2 95.5 -40.4 95.5C-37.6 95.5 -40.8 97.1 -40.8 97.1C-40.8 97.1 -47.4 107.201 -47 108.801C-47 108.801 -52.2 128.801 -68.2 129.601C-68.2 129.601 -84.35 130.551 -83 136.401C-83 136.401 -74.2 134.001 -71.8 136.401C-71.8 136.401 -61 136.001 -69 142.401L-75.8 154.001C-75.8 154.001 -75.66 157.919 -85.8 154.401C-95.6 151.001 -105.9 138.101 -105.9 138.101C-105.9 138.101 -121.85 123.551 -111 109.601z"} + , + {"fill": "#e59999", + "path":"M-112.2 113.601C-112.2 113.601 -114.2 123.201 -77.4 112.801C-77.4 112.801 -73 112.801 -70.6 113.601C-68.2 114.401 -56.2 117.201 -54.2 116.001C-54.2 116.001 -61.4 129.601 -73 128.001C-73 128.001 -86.2 129.601 -85.8 134.401C-85.8 134.401 -81.8 141.601 -77 144.001C-77 144.001 -74.2 146.401 -74.6 149.601C-75 152.801 -77.8 154.401 -79.8 155.201C-81.8 156.001 -85 152.801 -86.6 152.801C-88.2 152.801 -96.6 146.401 -101 141.601C-105.4 136.801 -113.8 124.801 -113.4 122.001C-113 119.201 -112.2 113.601 -112.2 113.601z"} + , + {"fill": "#b26565", + "path":"M-109 131.051C-106.4 135.001 -103.2 139.201 -101 141.601C-96.6 146.401 -88.2 152.801 -86.6 152.801C-85 152.801 -81.8 156.001 -79.8 155.201C-77.8 154.401 -75 152.801 -74.6 149.601C-74.2 146.401 -77 144.001 -77 144.001C-80.066 142.468 -82.806 138.976 -84.385 136.653C-84.385 136.653 -84.2 139.201 -89.4 138.401C-94.6 137.601 -99.8 134.801 -101.4 131.601C-103 128.401 -105.4 126.001 -103.8 129.601C-102.2 133.201 -99.8 136.801 -98.2 137.201C-96.6 137.601 -97 138.801 -99.4 138.401C-101.8 138.001 -104.6 137.601 -109 132.401z"} + , + {"fill": "#992600", + "path":"M-111.6 110.001C-111.6 110.001 -109.8 96.4 -108.6 92.4C-108.6 92.4 -109.4 85.6 -107 81.4C-104.6 77.2 -102.6 71 -99.6 65.6C-96.6 60.2 -96.4 56.2 -92.4 54.6C-88.4 53 -82.4 44.4 -79.6 43.4C-76.8 42.4 -77 43.2 -77 43.2C-77 43.2 -70.2 28.4 -56.6 32.4C-56.6 32.4 -72.8 29.6 -57 20.2C-57 20.2 -61.8 21.3 -58.5 14.3C-56.299 9.632 -56.8 16.4 -67.8 28.2C-67.8 28.2 -72.8 36.8 -78 39.8C-83.2 42.8 -95.2 49.8 -96.4 53.6C-97.6 57.4 -100.8 63.2 -102.8 64.8C-104.8 66.4 -107.6 70.6 -108 74C-108 74 -109.2 78 -110.6 79.2C-112 80.4 -112.2 83.6 -112.2 85.6C-112.2 87.6 -114.2 90.4 -114 92.8C-114 92.8 -113.2 111.801 -113.6 113.801L-111.6 110.001z"} + , + {"fill": "#ffffff", + "path":"M-120.2 114.601C-120.2 114.601 -122.2 113.201 -126.6 119.201C-126.6 119.201 -119.3 152.201 -119.3 153.601C-119.3 153.601 -118.2 151.501 -119.5 144.301C-120.8 137.101 -121.7 124.401 -121.7 124.401L-120.2 114.601z"} + , + {"fill": "#992600", + "path":"M-98.6 54C-98.6 54 -116.2 57.2 -115.8 86.4L-116.6 111.201C-116.6 111.201 -117.8 85.6 -119 84C-120.2 82.4 -116.2 71.2 -119.4 77.2C-119.4 77.2 -133.4 91.2 -125.4 112.401C-125.4 112.401 -123.9 115.701 -126.9 111.101C-126.9 111.101 -131.5 98.5 -130.4 92.1C-130.4 92.1 -130.2 89.9 -128.3 87.1C-128.3 87.1 -119.7 75.4 -117 73.1C-117 73.1 -115.2 58.7 -99.8 53.5C-99.8 53.5 -94.1 51.2 -98.6 54z"} + , + {"fill": "#000000", + "path":"M40.8 -12.2C41.46 -12.554 41.451 -13.524 42.031 -13.697C43.18 -14.041 43.344 -15.108 43.862 -15.892C44.735 -17.211 44.928 -18.744 45.51 -20.235C45.782 -20.935 45.809 -21.89 45.496 -22.55C44.322 -25.031 43.62 -27.48 42.178 -29.906C41.91 -30.356 41.648 -31.15 41.447 -31.748C40.984 -33.132 39.727 -34.123 38.867 -35.443C38.579 -35.884 39.104 -36.809 38.388 -36.893C37.491 -36.998 36.042 -37.578 35.809 -36.552C35.221 -33.965 36.232 -31.442 37.2 -29C36.418 -28.308 36.752 -27.387 36.904 -26.62C37.614 -23.014 36.416 -19.662 35.655 -16.188C35.632 -16.084 35.974 -15.886 35.946 -15.824C34.724 -13.138 33.272 -10.693 31.453 -8.312C30.695 -7.32 29.823 -6.404 29.326 -5.341C28.958 -4.554 28.55 -3.588 28.8 -2.6C25.365 0.18 23.115 4.025 20.504 7.871C20.042 8.551 20.333 9.76 20.884 10.029C21.697 10.427 22.653 9.403 23.123 8.557C23.512 7.859 23.865 7.209 24.356 6.566C24.489 6.391 24.31 5.972 24.445 5.851C27.078 3.504 28.747 0.568 31.2 -1.8C33.15 -2.129 34.687 -3.127 36.435 -4.14C36.743 -4.319 37.267 -4.07 37.557 -4.265C39.31 -5.442 39.308 -7.478 39.414 -9.388C39.464 -10.272 39.66 -11.589 40.8 -12.2z"} + , + {"fill": "#000000", + "path":"M31.959 -16.666C32.083 -16.743 31.928 -17.166 32.037 -17.382C32.199 -17.706 32.602 -17.894 32.764 -18.218C32.873 -18.434 32.71 -18.814 32.846 -18.956C35.179 -21.403 35.436 -24.427 34.4 -27.4C35.424 -28.02 35.485 -29.282 35.06 -30.129C34.207 -31.829 34.014 -33.755 33.039 -35.298C32.237 -36.567 30.659 -37.811 29.288 -36.508C28.867 -36.108 28.546 -35.321 28.824 -34.609C28.888 -34.446 29.173 -34.3 29.146 -34.218C29.039 -33.894 28.493 -33.67 28.487 -33.398C28.457 -31.902 27.503 -30.391 28.133 -29.062C28.905 -27.433 29.724 -25.576 30.4 -23.8C29.166 -21.684 30.199 -19.235 28.446 -17.358C28.31 -17.212 28.319 -16.826 28.441 -16.624C28.733 -16.138 29.139 -15.732 29.625 -15.44C29.827 -15.319 30.175 -15.317 30.375 -15.441C30.953 -15.803 31.351 -16.29 31.959 -16.666z"} + , + {"fill": "#000000", + "path":"M94.771 -26.977C96.16 -25.185 96.45 -22.39 94.401 -21C94.951 -17.691 98.302 -19.67 100.401 -20.2C100.292 -20.588 100.519 -20.932 100.802 -20.937C101.859 -20.952 102.539 -21.984 103.601 -21.8C104.035 -23.357 105.673 -24.059 106.317 -25.439C108.043 -29.134 107.452 -33.407 104.868 -36.653C104.666 -36.907 104.883 -37.424 104.759 -37.786C104.003 -39.997 101.935 -40.312 100.001 -41C98.824 -44.875 98.163 -48.906 96.401 -52.6C94.787 -52.85 94.089 -54.589 92.752 -55.309C91.419 -56.028 90.851 -54.449 90.892 -53.403C90.899 -53.198 91.351 -52.974 91.181 -52.609C91.105 -52.445 90.845 -52.334 90.845 -52.2C90.846 -52.065 91.067 -51.934 91.201 -51.8C90.283 -50.98 88.86 -50.503 88.565 -49.358C87.611 -45.648 90.184 -42.523 91.852 -39.322C92.443 -38.187 91.707 -36.916 90.947 -35.708C90.509 -35.013 90.617 -33.886 90.893 -33.03C91.645 -30.699 93.236 -28.96 94.771 -26.977z"} + , + {"fill": "#000000", + "path":"M57.611 -8.591C56.124 -6.74 52.712 -4.171 55.629 -2.243C55.823 -2.114 56.193 -2.11 56.366 -2.244C58.387 -3.809 60.39 -4.712 62.826 -5.294C62.95 -5.323 63.224 -4.856 63.593 -5.017C65.206 -5.72 67.216 -5.662 68.4 -7C72.167 -6.776 75.732 -7.892 79.123 -9.2C80.284 -9.648 81.554 -10.207 82.755 -10.709C84.131 -11.285 85.335 -12.213 86.447 -13.354C86.58 -13.49 86.934 -13.4 87.201 -13.4C87.161 -14.263 88.123 -14.39 88.37 -15.012C88.462 -15.244 88.312 -15.64 88.445 -15.742C90.583 -17.372 91.503 -19.39 90.334 -21.767C90.049 -22.345 89.8 -22.963 89.234 -23.439C88.149 -24.35 87.047 -23.496 86 -23.8C85.841 -23.172 85.112 -23.344 84.726 -23.146C83.867 -22.707 82.534 -23.292 81.675 -22.854C80.313 -22.159 79.072 -21.99 77.65 -21.613C77.338 -21.531 76.56 -21.627 76.4 -21C76.266 -21.134 76.118 -21.368 76.012 -21.346C74.104 -20.95 72.844 -20.736 71.543 -19.044C71.44 -18.911 70.998 -19.09 70.839 -18.955C69.882 -18.147 69.477 -16.913 68.376 -16.241C68.175 -16.118 67.823 -16.286 67.629 -16.157C66.983 -15.726 66.616 -15.085 65.974 -14.638C65.645 -14.409 65.245 -14.734 65.277 -14.99C65.522 -16.937 66.175 -18.724 65.6 -20.6C67.677 -23.12 70.194 -25.069 72 -27.8C72.015 -29.966 72.707 -32.112 72.594 -34.189C72.584 -34.382 72.296 -35.115 72.17 -35.462C71.858 -36.316 72.764 -37.382 71.92 -38.106C70.516 -39.309 69.224 -38.433 68.4 -37C66.562 -36.61 64.496 -35.917 62.918 -37.151C61.911 -37.938 61.333 -38.844 60.534 -39.9C59.549 -41.202 59.884 -42.638 59.954 -44.202C59.96 -44.33 59.645 -44.466 59.645 -44.6C59.646 -44.735 59.866 -44.866 60 -45C59.294 -45.626 59.019 -46.684 58 -47C58.305 -48.092 57.629 -48.976 56.758 -49.278C54.763 -49.969 53.086 -48.057 51.194 -47.984C50.68 -47.965 50.213 -49.003 49.564 -49.328C49.132 -49.544 48.428 -49.577 48.066 -49.311C47.378 -48.807 46.789 -48.693 46.031 -48.488C44.414 -48.052 43.136 -46.958 41.656 -46.103C40.171 -45.246 39.216 -43.809 38.136 -42.489C37.195 -41.337 37.059 -38.923 38.479 -38.423C40.322 -37.773 41.626 -40.476 43.592 -40.15C43.904 -40.099 44.11 -39.788 44 -39.4C44.389 -39.291 44.607 -39.52 44.8 -39.8C45.658 -38.781 46.822 -38.444 47.76 -37.571C48.73 -36.667 50.476 -37.085 51.491 -36.088C53.02 -34.586 52.461 -31.905 54.4 -30.6C53.814 -29.287 53.207 -28.01 52.872 -26.583C52.59 -25.377 53.584 -24.18 54.795 -24.271C56.053 -24.365 56.315 -25.124 56.8 -26.2C57.067 -25.933 57.536 -25.636 57.495 -25.42C57.038 -23.033 56.011 -21.04 55.553 -18.609C55.494 -18.292 55.189 -18.09 54.8 -18.2C54.332 -14.051 50.28 -11.657 47.735 -8.492C47.332 -7.99 47.328 -6.741 47.737 -6.338C49.14 -4.951 51.1 -6.497 52.8 -7C53.013 -8.206 53.872 -9.148 55.204 -9.092C55.46 -9.082 55.695 -9.624 56.019 -9.754C56.367 -9.892 56.869 -9.668 57.155 -9.866C58.884 -11.061 60.292 -12.167 62.03 -13.356C62.222 -13.487 62.566 -13.328 62.782 -13.436C63.107 -13.598 63.294 -13.985 63.617 -14.17C63.965 -14.37 64.207 -14.08 64.4 -13.8C63.754 -13.451 63.75 -12.494 63.168 -12.292C62.393 -12.024 61.832 -11.511 61.158 -11.064C60.866 -10.871 60.207 -11.119 60.103 -10.94C59.505 -9.912 58.321 -9.474 57.611 -8.591z"} + , + {"fill": "#000000", + "path":"M2.2 -58C2.2 -58 -7.038 -60.872 -18.2 -35.2C-18.2 -35.2 -20.6 -30 -23 -28C-25.4 -26 -36.6 -22.4 -38.6 -18.4L-49 -2.4C-49 -2.4 -34.2 -18.4 -31 -20.8C-31 -20.8 -23 -29.2 -26.2 -22.4C-26.2 -22.4 -40.2 -11.6 -39 -2.4C-39 -2.4 -44.6 12 -45.4 14C-45.4 14 -29.4 -18 -27 -19.2C-24.6 -20.4 -23.4 -20.4 -24.6 -16.8C-25.8 -13.2 -26.2 3.2 -29 5.2C-29 5.2 -21 -15.2 -21.8 -18.4C-21.8 -18.4 -18.6 -22 -16.2 -16.8L-17.4 -0.8L-13 11.2C-13 11.2 -15.4 0 -13.8 -15.6C-13.8 -15.6 -15.8 -26 -11.8 -20.4C-7.8 -14.8 1.8 -8.8 1.8 -4C1.8 -4 -3.4 -21.6 -12.6 -26.4L-16.6 -20.4L-17.8 -22.4C-17.8 -22.4 -21.4 -23.2 -17 -30C-12.6 -36.8 -13 -37.6 -13 -37.6C-13 -37.6 -6.6 -30.4 -5 -30.4C-5 -30.4 8.2 -38 9.4 -13.6C9.4 -13.6 16.2 -28 7 -34.8C7 -34.8 -7.8 -36.8 -6.6 -42L0.6 -54.4C4.2 -59.6 2.6 -56.8 2.6 -56.8z"} + , + {"fill": "#000000", + "path":"M-17.8 -41.6C-17.8 -41.6 -30.6 -41.6 -33.8 -36.4L-41 -26.8C-41 -26.8 -23.8 -36.8 -19.8 -38C-15.8 -39.2 -17.8 -41.6 -17.8 -41.6z"} + , + {"fill": "#000000", + "path":"M-57.8 -35.2C-57.8 -35.2 -59.8 -34 -60.2 -31.2C-60.6 -28.4 -63 -28 -62.2 -25.2C-61.4 -22.4 -59.4 -20 -59.4 -24C-59.4 -28 -57.8 -30 -57 -31.2C-56.2 -32.4 -54.6 -36.8 -57.8 -35.2z"} + , + {"fill": "#000000", + "path":"M-66.6 26C-66.6 26 -75 22 -78.2 18.4C-81.4 14.8 -80.948 19.966 -85.8 19.6C-91.647 19.159 -90.6 3.2 -90.6 3.2L-94.6 10.8C-94.6 10.8 -95.8 25.2 -87.8 22.8C-83.893 21.628 -82.6 23.2 -84.2 24C-85.8 24.8 -78.6 25.2 -81.4 26.8C-84.2 28.4 -69.8 23.2 -72.2 33.6L-66.6 26z"} + , + {"fill": "#000000", + "path":"M-79.2 40.4C-79.2 40.4 -94.6 44.8 -98.2 35.2C-98.2 35.2 -103 37.6 -100.8 40.6C-98.6 43.6 -97.4 44 -97.4 44C-97.4 44 -92 45.2 -92.6 46C-93.2 46.8 -95.6 50.2 -95.6 50.2C-95.6 50.2 -85.4 44.2 -79.2 40.4z"} + , + {"fill": "#ffffff", + "path":"M149.201 118.601C148.774 120.735 147.103 121.536 145.201 122.201C143.284 121.243 140.686 118.137 138.801 120.201C138.327 119.721 137.548 119.661 137.204 118.999C136.739 118.101 137.011 117.055 136.669 116.257C136.124 114.985 135.415 113.619 135.601 112.201C137.407 111.489 138.002 109.583 137.528 107.82C137.459 107.563 137.03 107.366 137.23 107.017C137.416 106.694 137.734 106.467 138.001 106.2C137.866 106.335 137.721 106.568 137.61 106.548C137 106.442 137.124 105.805 137.254 105.418C137.839 103.672 139.853 103.408 141.201 104.6C141.457 104.035 141.966 104.229 142.401 104.2C142.351 103.621 142.759 103.094 142.957 102.674C143.475 101.576 145.104 102.682 145.901 102.07C146.977 101.245 148.04 100.546 149.118 101.149C150.927 102.162 152.636 103.374 153.835 105.115C154.41 105.949 154.65 107.23 154.592 108.188C154.554 108.835 153.173 108.483 152.83 109.412C152.185 111.16 154.016 111.679 154.772 113.017C154.97 113.366 154.706 113.67 154.391 113.768C153.98 113.896 153.196 113.707 153.334 114.16C154.306 117.353 151.55 118.031 149.201 118.601z"} + , + {"fill": "#ffffff", + "path":"M139.6 138.201C139.593 136.463 137.992 134.707 139.201 133.001C139.336 133.135 139.467 133.356 139.601 133.356C139.736 133.356 139.867 133.135 140.001 133.001C141.496 135.217 145.148 136.145 145.006 138.991C144.984 139.438 143.897 140.356 144.801 141.001C142.988 142.349 142.933 144.719 142.001 146.601C140.763 146.315 139.551 145.952 138.401 145.401C138.753 143.915 138.636 142.231 139.456 140.911C139.89 140.213 139.603 139.134 139.6 138.201z"} + , + {"fill": "#cccccc", + "path":"M-26.6 129.201C-26.6 129.201 -43.458 139.337 -29.4 124.001C-20.6 114.401 -10.6 108.801 -10.6 108.801C-10.6 108.801 -0.2 104.4 3.4 103.2C7 102 22.2 96.8 25.4 96.4C28.6 96 38.2 92 45 96C51.8 100 59.8 104.4 59.8 104.4C59.8 104.4 43.4 96 39.8 98.4C36.2 100.8 29 100.4 23 103.6C23 103.6 8.2 108.001 5 110.001C1.8 112.001 -8.6 123.601 -10.2 122.801C-11.8 122.001 -9.8 121.601 -8.6 118.801C-7.4 116.001 -9.4 114.401 -17.4 120.801C-25.4 127.201 -26.6 129.201 -26.6 129.201z"} + , + {"fill": "#000000", + "path":"M-19.195 123.234C-19.195 123.234 -17.785 110.194 -9.307 111.859C-9.307 111.859 -1.081 107.689 1.641 105.721C1.641 105.721 9.78 104.019 11.09 103.402C29.569 94.702 44.288 99.221 44.835 98.101C45.381 96.982 65.006 104.099 68.615 108.185C69.006 108.628 58.384 102.588 48.686 100.697C40.413 99.083 18.811 100.944 7.905 106.48C4.932 107.989 -4.013 113.773 -6.544 113.662C-9.075 113.55 -19.195 123.234 -19.195 123.234z"} + , + {"fill": "#cccccc", + "path":"M-23 148.801C-23 148.801 -38.2 146.401 -21.4 144.801C-21.4 144.801 -3.4 142.801 0.6 137.601C0.6 137.601 14.2 128.401 17 128.001C19.8 127.601 49.8 120.401 50.2 118.001C50.6 115.601 56.2 115.601 57.8 116.401C59.4 117.201 58.6 118.401 55.8 119.201C53 120.001 21.8 136.401 15.4 137.601C9 138.801 -2.6 146.401 -7.4 147.601C-12.2 148.801 -23 148.801 -23 148.801z"} + , + {"fill": "#000000", + "path":"M-3.48 141.403C-3.48 141.403 -12.062 140.574 -3.461 139.755C-3.461 139.755 5.355 136.331 7.403 133.668C7.403 133.668 14.367 128.957 15.8 128.753C17.234 128.548 31.194 124.861 31.399 123.633C31.604 122.404 65.67 109.823 70.09 113.013C73.001 115.114 63.1 113.437 53.466 117.847C52.111 118.467 18.258 133.054 14.981 133.668C11.704 134.283 5.765 138.174 3.307 138.788C0.85 139.403 -3.48 141.403 -3.48 141.403z"} + , + {"fill": "#000000", + "path":"M-11.4 143.601C-11.4 143.601 -6.2 143.201 -7.4 144.801C-8.6 146.401 -11 145.601 -11 145.601L-11.4 143.601z"} + , + {"fill": "#000000", + "path":"M-18.6 145.201C-18.6 145.201 -13.4 144.801 -14.6 146.401C-15.8 148.001 -18.2 147.201 -18.2 147.201L-18.6 145.201z"} + , + {"fill": "#000000", + "path":"M-29 146.801C-29 146.801 -23.8 146.401 -25 148.001C-26.2 149.601 -28.6 148.801 -28.6 148.801L-29 146.801z"} + , + {"fill": "#000000", + "path":"M-36.6 147.601C-36.6 147.601 -31.4 147.201 -32.6 148.801C-33.8 150.401 -36.2 149.601 -36.2 149.601L-36.6 147.601z"} + , + {"fill": "#000000", + "path":"M1.8 108.001C1.8 108.001 6.2 108.001 5 109.601C3.8 111.201 0.6 110.801 0.6 110.801L1.8 108.001z"} + , + {"fill": "#000000", + "path":"M-8.2 113.601C-8.2 113.601 -1.694 111.46 -4.2 114.801C-5.4 116.401 -7.8 115.601 -7.8 115.601L-8.2 113.601z"} + , + {"fill": "#000000", + "path":"M-19.4 118.401C-19.4 118.401 -14.2 118.001 -15.4 119.601C-16.6 121.201 -19 120.401 -19 120.401L-19.4 118.401z"} + , + {"fill": "#000000", + "path":"M-27 124.401C-27 124.401 -21.8 124.001 -23 125.601C-24.2 127.201 -26.6 126.401 -26.6 126.401L-27 124.401z"} + , + {"fill": "#000000", + "path":"M-33.8 129.201C-33.8 129.201 -28.6 128.801 -29.8 130.401C-31 132.001 -33.4 131.201 -33.4 131.201L-33.8 129.201z"} + , + {"fill": "#000000", + "path":"M5.282 135.598C5.282 135.598 12.203 135.066 10.606 137.195C9.009 139.325 5.814 138.26 5.814 138.26L5.282 135.598z"} + , + {"fill": "#000000", + "path":"M15.682 130.798C15.682 130.798 22.603 130.266 21.006 132.395C19.409 134.525 16.214 133.46 16.214 133.46L15.682 130.798z"} + , + {"fill": "#000000", + "path":"M26.482 126.398C26.482 126.398 33.403 125.866 31.806 127.995C30.209 130.125 27.014 129.06 27.014 129.06L26.482 126.398z"} + , + {"fill": "#000000", + "path":"M36.882 121.598C36.882 121.598 43.803 121.066 42.206 123.195C40.609 125.325 37.414 124.26 37.414 124.26L36.882 121.598z"} + , + {"fill": "#000000", + "path":"M9.282 103.598C9.282 103.598 16.203 103.066 14.606 105.195C13.009 107.325 9.014 107.06 9.014 107.06L9.282 103.598z"} + , + {"fill": "#000000", + "path":"M19.282 100.398C19.282 100.398 26.203 99.866 24.606 101.995C23.009 104.125 18.614 103.86 18.614 103.86L19.282 100.398z"} + , + {"fill": "#000000", + "path":"M-3.4 140.401C-3.4 140.401 1.8 140.001 0.6 141.601C-0.6 143.201 -3 142.401 -3 142.401L-3.4 140.401z"} + , + {"fill": "#992600", + "path":"M-76.6 41.2C-76.6 41.2 -81 50 -81.4 53.2C-81.4 53.2 -80.6 44.4 -79.4 42.4C-78.2 40.4 -76.6 41.2 -76.6 41.2z"} + , + {"fill": "#992600", + "path":"M-95 55.2C-95 55.2 -98.2 69.6 -97.8 72.4C-97.8 72.4 -99 60.8 -98.6 59.6C-98.2 58.4 -95 55.2 -95 55.2z"} + , + {"fill": "#cccccc", + "path":"M-74.2 -19.4L-74.4 -16.2L-76.6 -16C-76.6 -16 -62.4 -3.4 -61.8 4.2C-61.8 4.2 -61 -4 -74.2 -19.4z"} + , + {"fill": "#000000", + "path":"M-70.216 -18.135C-70.647 -18.551 -70.428 -19.296 -70.836 -19.556C-71.645 -20.072 -69.538 -20.129 -69.766 -20.845C-70.149 -22.051 -69.962 -22.072 -70.084 -23.348C-70.141 -23.946 -69.553 -25.486 -69.168 -25.926C-67.722 -27.578 -69.046 -30.51 -67.406 -32.061C-67.102 -32.35 -66.726 -32.902 -66.441 -33.32C-65.782 -34.283 -64.598 -34.771 -63.648 -35.599C-63.33 -35.875 -63.531 -36.702 -62.962 -36.61C-62.248 -36.495 -61.007 -36.625 -61.052 -35.784C-61.165 -33.664 -62.494 -31.944 -63.774 -30.276C-63.323 -29.572 -63.781 -28.937 -64.065 -28.38C-65.4 -25.76 -65.211 -22.919 -65.385 -20.079C-65.39 -19.994 -65.697 -19.916 -65.689 -19.863C-65.336 -17.528 -64.752 -15.329 -63.873 -13.1C-63.507 -12.17 -63.036 -11.275 -62.886 -10.348C-62.775 -9.662 -62.672 -8.829 -63.08 -8.124C-61.045 -5.234 -62.354 -2.583 -61.185 0.948C-60.978 1.573 -59.286 3.487 -59.749 3.326C-62.262 2.455 -62.374 2.057 -62.551 1.304C-62.697 0.681 -63.027 -0.696 -63.264 -1.298C-63.328 -1.462 -63.499 -3.346 -63.577 -3.468C-65.09 -5.85 -63.732 -5.674 -65.102 -8.032C-66.53 -8.712 -67.496 -9.816 -68.619 -10.978C-68.817 -11.182 -67.674 -11.906 -67.855 -12.119C-68.947 -13.408 -70.1 -14.175 -69.764 -15.668C-69.609 -16.358 -69.472 -17.415 -70.216 -18.135z"} + , + {"fill": "#000000", + "path":"M-73.8 -16.4C-73.8 -16.4 -73.4 -9.6 -71 -8C-68.6 -6.4 -69.8 -7.2 -73 -8.4C-76.2 -9.6 -75 -10.4 -75 -10.4C-75 -10.4 -77.8 -10 -75.4 -8C-73 -6 -69.4 -3.6 -71 -3.6C-72.6 -3.6 -80.2 -7.6 -80.2 -10.4C-80.2 -13.2 -81.2 -17.3 -81.2 -17.3C-81.2 -17.3 -80.1 -18.1 -75.3 -18C-75.3 -18 -73.9 -17.3 -73.8 -16.4z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-74.6 2.2C-74.6 2.2 -83.12 -0.591 -101.6 2.8C-101.6 2.8 -92.569 0.722 -73.8 3C-63.5 4.25 -74.6 2.2 -74.6 2.2z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-72.502 2.129C-72.502 2.129 -80.748 -1.389 -99.453 0.392C-99.453 0.392 -90.275 -0.897 -71.774 2.995C-61.62 5.131 -72.502 2.129 -72.502 2.129z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-70.714 2.222C-70.714 2.222 -78.676 -1.899 -97.461 -1.514C-97.461 -1.514 -88.213 -2.118 -70.052 3.14C-60.086 6.025 -70.714 2.222 -70.714 2.222z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-69.444 2.445C-69.444 2.445 -76.268 -1.862 -93.142 -2.96C-93.142 -2.96 -84.803 -2.79 -68.922 3.319C-60.206 6.672 -69.444 2.445 -69.444 2.445z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M45.84 12.961C45.84 12.961 44.91 13.605 45.124 12.424C45.339 11.243 73.547 -1.927 77.161 -1.677C77.161 -1.677 46.913 11.529 45.84 12.961z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M42.446 13.6C42.446 13.6 41.57 14.315 41.691 13.121C41.812 11.927 68.899 -3.418 72.521 -3.452C72.521 -3.452 43.404 12.089 42.446 13.6z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M39.16 14.975C39.16 14.975 38.332 15.747 38.374 14.547C38.416 13.348 58.233 -2.149 68.045 -4.023C68.045 -4.023 50.015 4.104 39.16 14.975z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M36.284 16.838C36.284 16.838 35.539 17.532 35.577 16.453C35.615 15.373 53.449 1.426 62.28 -0.26C62.28 -0.26 46.054 7.054 36.284 16.838z"} + , + {"fill": "#cccccc", + "path":"M4.6 164.801C4.6 164.801 -10.6 162.401 6.2 160.801C6.2 160.801 24.2 158.801 28.2 153.601C28.2 153.601 41.8 144.401 44.6 144.001C47.4 143.601 63.8 140.001 64.2 137.601C64.6 135.201 70.6 132.801 72.2 133.601C73.8 134.401 73.8 143.601 71 144.401C68.2 145.201 49.4 152.401 43 153.601C36.6 154.801 25 162.401 20.2 163.601C15.4 164.801 4.6 164.801 4.6 164.801z"} + , + {"fill": "#000000", + "path":"M77.6 127.401C77.6 127.401 74.6 129.001 73.4 131.601C73.4 131.601 67 142.201 52.8 145.401C52.8 145.401 29.8 154.401 22 156.401C22 156.401 8.6 161.401 1.2 160.601C1.2 160.601 -5.8 160.801 0.4 162.401C0.4 162.401 20.6 160.401 24 158.601C24 158.601 39.6 153.401 42.6 150.801C45.6 148.201 63.8 143.201 66 141.201C68.2 139.201 78 130.801 77.6 127.401z"} + , + {"fill": "#000000", + "path":"M18.882 158.911C18.882 158.911 24.111 158.685 22.958 160.234C21.805 161.784 19.357 160.91 19.357 160.91L18.882 158.911z"} + , + {"fill": "#000000", + "path":"M11.68 160.263C11.68 160.263 16.908 160.037 15.756 161.586C14.603 163.136 12.155 162.263 12.155 162.263L11.68 160.263z"} + , + {"fill": "#000000", + "path":"M1.251 161.511C1.251 161.511 6.48 161.284 5.327 162.834C4.174 164.383 1.726 163.51 1.726 163.51L1.251 161.511z"} + , + {"fill": "#000000", + "path":"M-6.383 162.055C-6.383 162.055 -1.154 161.829 -2.307 163.378C-3.46 164.928 -5.908 164.054 -5.908 164.054L-6.383 162.055z"} + , + {"fill": "#000000", + "path":"M35.415 151.513C35.415 151.513 42.375 151.212 40.84 153.274C39.306 155.336 36.047 154.174 36.047 154.174L35.415 151.513z"} + , + {"fill": "#000000", + "path":"M45.73 147.088C45.73 147.088 51.689 143.787 51.155 148.849C50.885 151.405 46.362 149.749 46.362 149.749L45.73 147.088z"} + , + {"fill": "#000000", + "path":"M54.862 144.274C54.862 144.274 62.021 140.573 60.287 146.035C59.509 148.485 55.493 146.935 55.493 146.935L54.862 144.274z"} + , + {"fill": "#000000", + "path":"M64.376 139.449C64.376 139.449 68.735 134.548 69.801 141.21C70.207 143.748 65.008 142.11 65.008 142.11L64.376 139.449z"} + , + {"fill": "#000000", + "path":"M26.834 155.997C26.834 155.997 32.062 155.77 30.91 157.32C29.757 158.869 27.308 157.996 27.308 157.996L26.834 155.997z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M62.434 34.603C62.434 34.603 61.708 35.268 61.707 34.197C61.707 33.127 79.191 19.863 88.034 18.479C88.034 18.479 71.935 25.208 62.434 34.603z"} + , + {"fill": "#000000", + "path":"M65.4 98.4C65.4 98.4 87.401 120.801 96.601 124.401C96.601 124.401 105.801 135.601 101.801 161.601C101.801 161.601 98.601 169.201 95.401 148.401C95.401 148.401 98.601 123.201 87.401 139.201C87.401 139.201 79 129.301 85.4 129.601C85.4 129.601 88.601 131.601 89.001 130.001C89.401 128.401 81.4 114.801 64.2 100.4C47 86 65.4 98.4 65.4 98.4z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M7 137.201C7 137.201 6.8 135.401 8.6 136.201C10.4 137.001 104.601 143.201 136.201 167.201C136.201 167.201 91.001 144.001 7 137.201z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M17.4 132.801C17.4 132.801 17.2 131.001 19 131.801C20.8 132.601 157.401 131.601 181.001 164.001C181.001 164.001 159.001 138.801 17.4 132.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M29 128.801C29 128.801 28.8 127.001 30.6 127.801C32.4 128.601 205.801 115.601 229.401 148.001C229.401 148.001 219.801 122.401 29 128.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M39 124.001C39 124.001 38.8 122.201 40.6 123.001C42.4 123.801 164.601 85.2 188.201 117.601C188.201 117.601 174.801 93 39 124.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-19 146.801C-19 146.801 -19.2 145.001 -17.4 145.801C-15.6 146.601 2.2 148.801 4.2 187.601C4.2 187.601 -3 145.601 -19 146.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-27.8 148.401C-27.8 148.401 -28 146.601 -26.2 147.401C-24.4 148.201 -10.2 143.601 -13 182.401C-13 182.401 -11.8 147.201 -27.8 148.401z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-35.8 148.801C-35.8 148.801 -36 147.001 -34.2 147.801C-32.4 148.601 -17 149.201 -29.4 171.601C-29.4 171.601 -19.8 147.601 -35.8 148.801z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M11.526 104.465C11.526 104.465 11.082 106.464 12.631 105.247C28.699 92.622 61.141 33.72 116.826 28.086C116.826 28.086 78.518 15.976 11.526 104.465z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M22.726 102.665C22.726 102.665 21.363 101.472 23.231 100.847C25.099 100.222 137.541 27.72 176.826 35.686C176.826 35.686 149.719 28.176 22.726 102.665z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M1.885 108.767C1.885 108.767 1.376 110.366 3.087 109.39C12.062 104.27 15.677 47.059 59.254 45.804C59.254 45.804 26.843 31.09 1.885 108.767z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-18.038 119.793C-18.038 119.793 -19.115 121.079 -17.162 120.825C-6.916 119.493 14.489 78.222 58.928 83.301C58.928 83.301 26.962 68.955 -18.038 119.793z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-6.8 113.667C-6.8 113.667 -7.611 115.136 -5.742 114.511C4.057 111.237 17.141 66.625 61.729 63.078C61.729 63.078 27.603 55.135 -6.8 113.667z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-25.078 124.912C-25.078 124.912 -25.951 125.954 -24.369 125.748C-16.07 124.669 1.268 91.24 37.264 95.354C37.264 95.354 11.371 83.734 -25.078 124.912z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-32.677 130.821C-32.677 130.821 -33.682 131.866 -32.091 131.748C-27.923 131.439 2.715 98.36 21.183 113.862C21.183 113.862 9.168 95.139 -32.677 130.821z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M36.855 98.898C36.855 98.898 35.654 97.543 37.586 97.158C39.518 96.774 160.221 39.061 198.184 51.927C198.184 51.927 172.243 41.053 36.855 98.898z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M3.4 163.201C3.4 163.201 3.2 161.401 5 162.201C6.8 163.001 22.2 163.601 9.8 186.001C9.8 186.001 19.4 162.001 3.4 163.201z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M13.8 161.601C13.8 161.601 13.6 159.801 15.4 160.601C17.2 161.401 35 163.601 37 202.401C37 202.401 29.8 160.401 13.8 161.601z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M20.6 160.001C20.6 160.001 20.4 158.201 22.2 159.001C24 159.801 48.6 163.201 72.2 195.601C72.2 195.601 36.6 158.801 20.6 160.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M28.225 157.972C28.225 157.972 27.788 156.214 29.678 156.768C31.568 157.322 52.002 155.423 90.099 189.599C90.099 189.599 43.924 154.656 28.225 157.972z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M38.625 153.572C38.625 153.572 38.188 151.814 40.078 152.368C41.968 152.922 76.802 157.423 128.499 192.399C128.499 192.399 54.324 150.256 38.625 153.572z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-1.8 142.001C-1.8 142.001 -2 140.201 -0.2 141.001C1.6 141.801 55 144.401 85.4 171.201C85.4 171.201 50.499 146.426 -1.8 142.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M-11.8 146.001C-11.8 146.001 -12 144.201 -10.2 145.001C-8.4 145.801 16.2 149.201 39.8 181.601C39.8 181.601 4.2 144.801 -11.8 146.001z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M49.503 148.962C49.503 148.962 48.938 147.241 50.864 147.655C52.79 148.068 87.86 150.004 141.981 181.098C141.981 181.098 64.317 146.704 49.503 148.962z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M57.903 146.562C57.903 146.562 57.338 144.841 59.264 145.255C61.19 145.668 96.26 147.604 150.381 178.698C150.381 178.698 73.317 143.904 57.903 146.562z"} + , + {"fill": "#ffffff", "stroke":"#000000", "width":0.1, + "path":"M67.503 141.562C67.503 141.562 66.938 139.841 68.864 140.255C70.79 140.668 113.86 145.004 203.582 179.298C203.582 179.298 82.917 138.904 67.503 141.562z"} + , + {"fill": "#000000", + "path":"M-43.8 148.401C-43.8 148.401 -38.6 148.001 -39.8 149.601C-41 151.201 -43.4 150.401 -43.4 150.401L-43.8 148.401z"} + , + {"fill": "#000000", + "path":"M-13 162.401C-13 162.401 -7.8 162.001 -9 163.601C-10.2 165.201 -12.6 164.401 -12.6 164.401L-13 162.401z"} + , + {"fill": "#000000", + "path":"M-21.8 162.001C-21.8 162.001 -16.6 161.601 -17.8 163.201C-19 164.801 -21.4 164.001 -21.4 164.001L-21.8 162.001z"} + , + {"fill": "#000000", + "path":"M-117.169 150.182C-117.169 150.182 -112.124 151.505 -113.782 152.624C-115.439 153.744 -117.446 152.202 -117.446 152.202L-117.169 150.182z"} + , + {"fill": "#000000", + "path":"M-115.169 140.582C-115.169 140.582 -110.124 141.905 -111.782 143.024C-113.439 144.144 -115.446 142.602 -115.446 142.602L-115.169 140.582z"} + , + {"fill": "#000000", + "path":"M-122.369 136.182C-122.369 136.182 -117.324 137.505 -118.982 138.624C-120.639 139.744 -122.646 138.202 -122.646 138.202L-122.369 136.182z"} + , + {"fill": "#cccccc", + "path":"M-42.6 211.201C-42.6 211.201 -44.2 211.201 -48.2 213.201C-50.2 213.201 -61.4 216.801 -67 226.801C-67 226.801 -54.6 217.201 -42.6 211.201z"} + , + {"fill": "#cccccc", + "path":"M45.116 303.847C45.257 304.105 45.312 304.525 45.604 304.542C46.262 304.582 47.495 304.883 47.37 304.247C46.522 299.941 45.648 295.004 41.515 293.197C40.876 292.918 39.434 293.331 39.36 294.215C39.233 295.739 39.116 297.088 39.425 298.554C39.725 299.975 41.883 299.985 42.8 298.601C43.736 300.273 44.168 302.116 45.116 303.847z"} + , + {"fill": "#cccccc", + "path":"M34.038 308.581C34.786 309.994 34.659 311.853 36.074 312.416C36.814 312.71 38.664 311.735 38.246 310.661C37.444 308.6 37.056 306.361 35.667 304.55C35.467 304.288 35.707 303.755 35.547 303.427C34.953 302.207 33.808 301.472 32.4 301.801C31.285 304.004 32.433 306.133 33.955 307.842C34.091 307.994 33.925 308.37 34.038 308.581z"} + , + {"fill": "#cccccc", + "path":"M-5.564 303.391C-5.672 303.014 -5.71 302.551 -5.545 302.23C-5.014 301.197 -4.221 300.075 -4.558 299.053C-4.906 297.997 -6.022 298.179 -6.672 298.748C-7.807 299.742 -7.856 301.568 -8.547 302.927C-8.743 303.313 -8.692 303.886 -9.133 304.277C-9.607 304.698 -10.047 306.222 -9.951 306.793C-9.898 307.106 -10.081 317.014 -9.859 316.751C-9.24 316.018 -6.19 306.284 -6.121 305.392C-6.064 304.661 -5.332 304.196 -5.564 303.391z"} + , + {"fill": "#cccccc", + "path":"M-31.202 296.599C-28.568 294.1 -25.778 291.139 -26.22 287.427C-26.336 286.451 -28.111 286.978 -28.298 287.824C-29.1 291.449 -31.139 294.11 -33.707 296.502C-35.903 298.549 -37.765 304.893 -38 305.401C-34.303 300.145 -32.046 297.399 -31.202 296.599z"} + , + {"fill": "#cccccc", + "path":"M-44.776 290.635C-44.253 290.265 -44.555 289.774 -44.338 289.442C-43.385 287.984 -42.084 286.738 -42.066 285C-42.063 284.723 -42.441 284.414 -42.776 284.638C-43.053 284.822 -43.395 284.952 -43.503 285.082C-45.533 287.531 -46.933 290.202 -48.376 293.014C-48.559 293.371 -49.703 297.862 -49.39 297.973C-49.151 298.058 -47.431 293.877 -47.221 293.763C-45.958 293.077 -45.946 291.462 -44.776 290.635z"} + , + {"fill": "#cccccc", + "path":"M-28.043 310.179C-27.599 309.31 -26.023 308.108 -26.136 307.219C-26.254 306.291 -25.786 304.848 -26.698 305.536C-27.955 306.484 -31.404 307.833 -31.674 313.641C-31.7 314.212 -28.726 311.519 -28.043 310.179z"} + , + {"fill": "#cccccc", + "path":"M-13.6 293.001C-13.2 292.333 -12.492 292.806 -12.033 292.543C-11.385 292.171 -10.774 291.613 -10.482 290.964C-9.512 288.815 -7.743 286.995 -7.6 284.601C-9.091 283.196 -9.77 285.236 -10.4 286.201C-11.723 284.554 -12.722 286.428 -14.022 286.947C-14.092 286.975 -14.305 286.628 -14.38 286.655C-15.557 287.095 -16.237 288.176 -17.235 288.957C-17.406 289.091 -17.811 288.911 -17.958 289.047C-18.61 289.65 -19.583 289.975 -19.863 290.657C-20.973 293.364 -24.113 295.459 -26 303.001C-25.619 303.91 -21.488 296.359 -21.001 295.661C-20.165 294.465 -20.047 297.322 -18.771 296.656C-18.72 296.629 -18.534 296.867 -18.4 297.001C-18.206 296.721 -17.988 296.492 -17.6 296.601C-17.6 296.201 -17.734 295.645 -17.533 295.486C-16.296 294.509 -16.38 293.441 -15.6 292.201C-15.142 292.99 -14.081 292.271 -13.6 293.001z"} + , + {"fill": "#cccccc", + "path":"M46.2 347.401C46.2 347.401 53.6 327.001 49.2 315.801C49.2 315.801 60.6 337.401 56 348.601C56 348.601 55.6 338.201 51.6 333.201C51.6 333.201 47.6 346.001 46.2 347.401z"} + , + {"fill": "#cccccc", + "path":"M31.4 344.801C31.4 344.801 36.8 336.001 28.8 317.601C28.8 317.601 28 338.001 21.2 349.001C21.2 349.001 35.4 328.801 31.4 344.801z"} + , + {"fill": "#cccccc", + "path":"M21.4 342.801C21.4 342.801 21.2 322.801 21.6 319.801C21.6 319.801 17.8 336.401 7.6 346.001C7.6 346.001 22 334.001 21.4 342.801z"} + , + {"fill": "#cccccc", + "path":"M11.8 310.801C11.8 310.801 17.8 324.401 7.8 342.801C7.8 342.801 14.2 330.601 9.4 323.601C9.4 323.601 12 320.201 11.8 310.801z"} + , + {"fill": "#cccccc", + "path":"M-7.4 342.401C-7.4 342.401 -8.4 326.801 -6.6 324.601C-6.6 324.601 -6.4 318.201 -6.8 317.201C-6.8 317.201 -2.8 311.001 -2.6 318.401C-2.6 318.401 -1.2 326.201 1.6 330.801C1.6 330.801 5.2 336.201 5 342.601C5 342.601 -5 312.401 -7.4 342.401z"} + , + {"fill": "#cccccc", + "path":"M-11 314.801C-11 314.801 -17.6 325.601 -19.4 344.601C-19.4 344.601 -20.8 338.401 -17 324.001C-17 324.001 -12.8 308.601 -11 314.801z"} + , + {"fill": "#cccccc", + "path":"M-32.8 334.601C-32.8 334.601 -27.8 329.201 -26.4 324.201C-26.4 324.201 -22.8 308.401 -29.2 317.001C-29.2 317.001 -29 325.001 -37.2 332.401C-37.2 332.401 -32.4 330.001 -32.8 334.601z"} + , + {"fill": "#cccccc", + "path":"M-38.6 329.601C-38.6 329.601 -35.2 312.201 -34.4 311.401C-34.4 311.401 -32.6 308.001 -35.4 311.201C-35.4 311.201 -44.2 330.401 -48.2 337.001C-48.2 337.001 -40.2 327.801 -38.6 329.601z"} + , + {"fill": "#cccccc", + "path":"M-44.4 313.001C-44.4 313.001 -32.8 290.601 -54.6 316.401C-54.6 316.401 -43.6 306.601 -44.4 313.001z"} + , + {"fill": "#cccccc", + "path":"M-59.8 298.401C-59.8 298.401 -55 279.601 -52.4 279.801C-52.4 279.801 -44.2 270.801 -50.8 281.401C-50.8 281.401 -56.8 291.001 -56.2 300.801C-56.2 300.801 -56.8 291.201 -59.8 298.401z"} + , + {"fill": "#cccccc", + "path":"M270.5 287C270.5 287 258.5 277 256 273.5C256 273.5 269.5 292 269.5 299C269.5 299 272 291.5 270.5 287z"} + , + {"fill": "#cccccc", + "path":"M276 265C276 265 255 250 251.5 242.5C251.5 242.5 278 272 278 276.5C278 276.5 278.5 267.5 276 265z"} + , + {"fill": "#cccccc", + "path":"M293 111C293 111 281 103 279.5 105C279.5 105 290 111.5 292.5 120C292.5 120 291 111 293 111z"} + , + {"fill": "#cccccc", + "path":"M301.5 191.5L284 179.5C284 179.5 303 196.5 303.5 200.5L301.5 191.5z"} + , + {"stroke":"#000000", + "path":"M-89.25 169L-67.25 173.75"} + , + {"stroke":"#000000", + "path":"M-39 331C-39 331 -39.5 327.5 -48.5 338"} + , + {"stroke":"#000000", + "path":"M-33.5 336C-33.5 336 -31.5 329.5 -38 334"} + , + {"stroke":"#000000", + "path":"M20.5 344.5C20.5 344.5 22 333.5 10.5 346.5"} +]; \ No newline at end of file diff --git a/examples/qtquick/canvas/tiger/tiger.qml b/examples/qtquick/canvas/tiger/tiger.qml new file mode 100644 index 0000000000..2eb1bb2106 --- /dev/null +++ b/examples/qtquick/canvas/tiger/tiger.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../contents" +import "tiger.js" as Tiger +Item { + id:container + width:360 + height:600 + + Column { + spacing:5 + anchors.fill:parent + Text { font.pointSize:25; text:"Tiger with SVG path"; anchors.horizontalCenter:parent.horizontalCenter} + + Canvas { + id:canvas + width:360 + height:360 + smooth:true + renderTarget:Canvas.FramebufferObject + renderStrategy: Canvas.Cooperative + property string strokeStyle:"steelblue" + property string fillStyle:"yellow" + property bool fill:true + property bool stroke:true + property real alpha:alphaCtrl.value + property real scaleX : scaleXCtrl.value + property real scaleY : scaleYCtrl.value + property real rotate : rotateCtrl.value + property int frame:0 + + onFillChanged: requestPaint(); + onStrokeChanged: requestPaint(); + onAlphaChanged: requestPaint(); + onScaleXChanged: requestPaint(); + onScaleYChanged: requestPaint(); + onRotateChanged: requestPaint(); + + onPainted : { + canvas.frame++; + if (canvas.frame < Tiger.tiger.length) + requestPaint(); + } + onPaint: { + var ctx = canvas.getContext('2d'); + ctx.save(); + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.globalAlpha = canvas.alpha; + ctx.scale(canvas.scaleX, canvas.scaleY); + ctx.rotate(canvas.rotate); + ctx.globalCompositeOperation = "source-over"; + ctx.translate(canvas.width/2, canvas.height/2); + ctx.strokeStyle = Qt.rgba(.3, .3, .3,1); + ctx.lineWidth = 1; + + + for (var i = 0; i < canvas.frame && i < Tiger.tiger.length; i++) { + if (Tiger.tiger[i].width != undefined) + ctx.lineWidth = Tiger.tiger[i].width; + + if (Tiger.tiger[i].path != undefined) + ctx.path = Tiger.tiger[i].path; + + if (Tiger.tiger[i].fill != undefined) { + ctx.fillStyle = Tiger.tiger[i].fill; + ctx.fill(); + } + + if (Tiger.tiger[i].stroke != undefined) { + ctx.strokeStyle = Tiger.tiger[i].stroke; + ctx.stroke(); + } + } + ctx.restore(); + } + } + Rectangle { + id:controls + width:360 + height:160 + Column { + spacing:3 + Slider {id:scaleXCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleX"} + Slider {id:scaleYCtrl; width:300; height:30; min:0.1; max:10; init:0.5; name:"ScaleY"} + Slider {id:rotateCtrl; width:300; height:30; min:0; max:Math.PI*2; init:0; name:"Rotate"} + Slider {id:alphaCtrl; width:300; height:30; min:0; max:1; init:1; name:"Alpha"} + } + } + } +} diff --git a/examples/qtquick/canvas/twitterfriends/TwitterUser.qml b/examples/qtquick/canvas/twitterfriends/TwitterUser.qml new file mode 100644 index 0000000000..8b906216ef --- /dev/null +++ b/examples/qtquick/canvas/twitterfriends/TwitterUser.qml @@ -0,0 +1,294 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id:twitterUser + property variant friends : []; + property string name : ""; + property string twitterId : ""; + property string image : ""; + property string url : ""; + property string desc : ""; + width : 0; + height : 0; + property int posX:0; + property int posY:0; + property bool hasFocus : false; + property variant canvas; + property variant manager; + property variant linkColor; + property bool selected : false; + + Rectangle { + id:twitterStatus + x:twitterUser.width + y:twitterUser.height + width:250 + height:60 + opacity: 0 + border.color:"steelblue" + border.width:3 + Column { + spacing:2 + Text {color:"steelblue"; font.pointSize:15; width:250; height:30; text:twitterUser.name; wrapMode: Text.WrapAnywhere} + Text {color:"steelblue"; font.pointSize:8; width:250; height:30; text:twitterUser.url; wrapMode: Text.WrapAnywhere} + } + } + + function moved() { + twitterUser.posX = twitterUser.x; + twitterUser.posY = twitterUser.y; + twitterUser.canvas.requestPaint(); + } + + onXChanged: moved(); + onYChanged: moved(); + + MouseArea { + anchors.fill:parent + drag.target : twitterUser + drag.axis : Drag.XandYAxis + + onClicked: { + if (!twitterUser.selected) { + twitterUser.selected = true; + twitterStatus.opacity = 1; + twitterStatus.visible = true; + } else { + twitterUser.selected = false; + twitterStatus.opacity = 0; + } + } + + onDoubleClicked : { + twitterStatus.opacity = 0; + twitterUser.selected = false; + twitterUser.hasFocus = true; + twitterUser.canvas.twitterName = twitterUser.name; + twitterUser.canvas.twitterId = twitterUser.twitterId; + twitterUser.canvas.loading = true; + twitterUser.createFriends(); + } + } + + function show(ctx, layoutChanged) { + var w = canvas.width; + var h = canvas.height; + if (twitterUser.hasFocus) { + twitterUser.width = 60 + twitterUser.height = 60 + twitterUser.posX = w/2; + twitterUser.posY = h/2; + } else { + twitterUser.width = 40 + twitterUser.height = 40 + } + + + if (twitterUser.hasFocus) { + if (layoutChanged) + twitterUser.layoutFriends(); + twitterUser.linkFriends(ctx); + twitterUser.showFriends(ctx); + ctx.shadowOffsetX = 5; + ctx.shadowOffsetY = 5; + ctx.shadowBlur = 7; + ctx.shadowColor = "blue"; + ctx.globalAlpha = 1; + } else { + ctx.shadowOffsetX = 5; + ctx.shadowOffsetY = 5; + ctx.shadowBlur = 7; + ctx.shadowColor = twitterUser.linkColor; + ctx.globalAlpha = 0.6; + } + + if (twitterUser.canvas.isImageLoaded(twitterUser.image)) { + ctx.drawImage(twitterUser.image, twitterUser.posX, twitterUser.posY, twitterUser.width, twitterUser.height); + } +// ctx.font = "15px"; +// var nameSize = ctx.measureText(twitterUser.name).width; +// ctx.fillText(twitterUser.name, twitterUser.posX + nameSize/2 - twitterUser.width/2, twitterUser.posY + twitterUser.height/2 + 10); + } + function dump() { + console.log("name:" + twitterUser.name + + " x:" + twitterUser.posX + + " y:" + twitterUser.posY + + " width:" + twitterUser.width + + " height:" + twitterUser.height + + " id:" + twitterUser.twitterId + + " image:" + twitterUser.image + + " url:" + twitterUser.url + "\n" + twitterUser.desc); + } + + function layoutFriends() { + var w = canvas.width; + var h = canvas.height; + for (var i=0; i < twitterUser.friends.length; i++) { + var friend = manager.getById(twitterUser.friends[i]); + if (friend) { + friend.x = Math.random() *w; + friend.y = Math.random() *h; + } + } + } + + function showFriends(ctx) { + var w = canvas.width; + var h = canvas.height; + for (var i=0; i < twitterUser.friends.length && i < 15; i++) { + var friend = manager.getById(twitterUser.friends[i]); + if (friend && twitterUser.canvas.isImageLoaded(friend.image)) { + friend.hasFocus = false; + friend.show(ctx, false); + } + } + } + + function linkFriends(ctx) { + var w = canvas.width; + var h = canvas.height; + for (var i=0; i < twitterUser.friends.length && i < 15; i++) { + var friend = manager.getById(twitterUser.friends[i]); + if (friend && twitterUser.canvas.isImageLoaded(friend.image)) { + if (!friend.linkColor) + friend.linkColor = Qt.rgba( ((Math.random() * 200) +55)/255 + , ((Math.random() * 200) +55)/255 + , ((Math.random() * 200) +55)/255, 0.8); + ctx.strokeStyle = friend.linkColor; + ctx.lineWidth = 8; + ctx.beginPath(); + ctx.moveTo(twitterUser.posX + twitterUser.width/2, twitterUser.posY + twitterUser.height/2); + ctx.lineTo(friend.x + friend.width/2, friend.y + friend.height/2); + ctx.stroke(); + } + } + } + + + function create(url) { + var x = new XMLHttpRequest; + x.open("GET", url); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + var user = eval('(' + x.responseText +')')[0]; + twitterUser.name = user.name; + twitterUser.twitterId = user.id; + twitterUser.image = user.profile_image_url; + twitterUser.canvas.loadImage(twitterUser.image); + twitterUser.url = user.url; + twitterUser.desc = user.description; + twitterUser.createFriends(); + } + } + x.send(); + } + + function createByName(name) { + if (twitterUser.name === "" && twitterUser.twitterId === "") { + twitterUser.name = name; + var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&screen_name=" + name; + twitterUser.create(userUrl); + } + } + + function createById(id) { + if (twitterUser.name === "" && twitterUser.twitterId === "") { + twitterUser.twitterId = id; + var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=" + id; + twitterUser.create(userUrl); + } + } + + function createFriends() { + if (twitterUser.friends.length === 0) { + var x = new XMLHttpRequest; + var friendsUrl = "https://api.twitter.com/1/friends/ids.json?cursor=-1&stringify_ids=true&user_id=" + twitterUser.twitterId; + x.open("GET", friendsUrl); + + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + twitterUser.friends = eval('(' + x.responseText +')').ids; + var doRequest = false; + var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id="; + + for (var i=0; i + + view.qml + + + diff --git a/examples/qtquick/modelviews/abstractitemmodel/main.cpp b/examples/qtquick/modelviews/abstractitemmodel/main.cpp new file mode 100644 index 0000000000..b6ca2df26e --- /dev/null +++ b/examples/qtquick/modelviews/abstractitemmodel/main.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "model.h" + +#include +#include +#include +#include +#include +#include + +//![0] +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + AnimalModel model; + model.addAnimal(Animal("Wolf", "Medium")); + model.addAnimal(Animal("Polar bear", "Large")); + model.addAnimal(Animal("Quoll", "Small")); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + QDeclarativeContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", &model); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/qtquick/modelviews/abstractitemmodel/model.cpp b/examples/qtquick/modelviews/abstractitemmodel/model.cpp new file mode 100644 index 0000000000..8f7649c0d4 --- /dev/null +++ b/examples/qtquick/modelviews/abstractitemmodel/model.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "model.h" + +Animal::Animal(const QString &type, const QString &size) + : m_type(type), m_size(size) +{ +} + +QString Animal::type() const +{ + return m_type; +} + +QString Animal::size() const +{ + return m_size; +} + +//![0] +AnimalModel::AnimalModel(QObject *parent) + : QAbstractListModel(parent) +{ + QHash roles; + roles[TypeRole] = "type"; + roles[SizeRole] = "size"; + setRoleNames(roles); +} +//![0] + +void AnimalModel::addAnimal(const Animal &animal) +{ + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + m_animals << animal; + endInsertRows(); +} + +int AnimalModel::rowCount(const QModelIndex & parent) const { + return m_animals.count(); +} + +QVariant AnimalModel::data(const QModelIndex & index, int role) const { + if (index.row() < 0 || index.row() >= m_animals.count()) + return QVariant(); + + const Animal &animal = m_animals[index.row()]; + if (role == TypeRole) + return animal.type(); + else if (role == SizeRole) + return animal.size(); + return QVariant(); +} + diff --git a/examples/qtquick/modelviews/abstractitemmodel/model.h b/examples/qtquick/modelviews/abstractitemmodel/model.h new file mode 100644 index 0000000000..1378c4487e --- /dev/null +++ b/examples/qtquick/modelviews/abstractitemmodel/model.h @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include + +//![0] +class Animal +{ +public: + Animal(const QString &type, const QString &size); +//![0] + + QString type() const; + QString size() const; + +private: + QString m_type; + QString m_size; +//![1] +}; + +class AnimalModel : public QAbstractListModel +{ + Q_OBJECT +public: + enum AnimalRoles { + TypeRole = Qt::UserRole + 1, + SizeRole + }; + + AnimalModel(QObject *parent = 0); +//![1] + + void addAnimal(const Animal &animal); + + int rowCount(const QModelIndex & parent = QModelIndex()) const; + + QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; + +private: + QList m_animals; +//![2] +}; +//![2] + + diff --git a/examples/qtquick/modelviews/abstractitemmodel/view.qml b/examples/qtquick/modelviews/abstractitemmodel/view.qml new file mode 100644 index 0000000000..64f5871d4b --- /dev/null +++ b/examples/qtquick/modelviews/abstractitemmodel/view.qml @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +//![0] +ListView { + width: 200; height: 250 + + model: myModel + delegate: Text { text: "Animal: " + type + ", " + size } +} +//![0] + diff --git a/examples/qtquick/modelviews/gridview/gridview-example.qml b/examples/qtquick/modelviews/gridview/gridview-example.qml new file mode 100644 index 0000000000..ea3bb5cec9 --- /dev/null +++ b/examples/qtquick/modelviews/gridview/gridview-example.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 300; height: 400 + color: "white" + + ListModel { + id: appModel + ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } + ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } + ListElement { name: "Camera"; icon: "pics/Camera_48.png" } + ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } + ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } + ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } + ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } + } + + Component { + id: appDelegate + + Item { + width: 100; height: 100 + + Image { + id: myIcon + y: 20; anchors.horizontalCenter: parent.horizontalCenter + source: icon + } + Text { + anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } + text: name + } + MouseArea { + anchors.fill: parent + onClicked: parent.GridView.view.currentIndex = index + } + } + } + + Component { + id: appHighlight + Rectangle { width: 80; height: 80; color: "lightsteelblue" } + } + + GridView { + anchors.fill: parent + cellWidth: 100; cellHeight: 100 + highlight: appHighlight + focus: true + model: appModel + delegate: appDelegate + } +} diff --git a/examples/qtquick/modelviews/gridview/pics/AddressBook_48.png b/examples/qtquick/modelviews/gridview/pics/AddressBook_48.png new file mode 100644 index 0000000000..1ab7c8eec1 Binary files /dev/null and b/examples/qtquick/modelviews/gridview/pics/AddressBook_48.png differ diff --git a/examples/qtquick/modelviews/gridview/pics/AudioPlayer_48.png b/examples/qtquick/modelviews/gridview/pics/AudioPlayer_48.png new file mode 100644 index 0000000000..f4b8689f87 Binary files /dev/null and b/examples/qtquick/modelviews/gridview/pics/AudioPlayer_48.png differ diff --git a/examples/qtquick/modelviews/gridview/pics/Camera_48.png b/examples/qtquick/modelviews/gridview/pics/Camera_48.png new file mode 100644 index 0000000000..c76b524945 Binary files /dev/null and b/examples/qtquick/modelviews/gridview/pics/Camera_48.png differ diff --git a/examples/qtquick/modelviews/gridview/pics/DateBook_48.png b/examples/qtquick/modelviews/gridview/pics/DateBook_48.png new file mode 100644 index 0000000000..58f5787fb8 Binary files /dev/null and b/examples/qtquick/modelviews/gridview/pics/DateBook_48.png differ diff --git a/examples/qtquick/modelviews/gridview/pics/EMail_48.png b/examples/qtquick/modelviews/gridview/pics/EMail_48.png new file mode 100644 index 0000000000..d6d84a61be Binary files /dev/null and b/examples/qtquick/modelviews/gridview/pics/EMail_48.png differ diff --git a/examples/qtquick/modelviews/gridview/pics/TodoList_48.png b/examples/qtquick/modelviews/gridview/pics/TodoList_48.png new file mode 100644 index 0000000000..0988448d9b Binary files /dev/null and b/examples/qtquick/modelviews/gridview/pics/TodoList_48.png differ diff --git a/examples/qtquick/modelviews/gridview/pics/VideoPlayer_48.png b/examples/qtquick/modelviews/gridview/pics/VideoPlayer_48.png new file mode 100644 index 0000000000..52638c50a7 Binary files /dev/null and b/examples/qtquick/modelviews/gridview/pics/VideoPlayer_48.png differ diff --git a/examples/qtquick/modelviews/listview/content/PetsModel.qml b/examples/qtquick/modelviews/listview/content/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/qtquick/modelviews/listview/content/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/qtquick/modelviews/listview/content/PressAndHoldButton.qml b/examples/qtquick/modelviews/listview/content/PressAndHoldButton.qml new file mode 100644 index 0000000000..b20d8f64f1 --- /dev/null +++ b/examples/qtquick/modelviews/listview/content/PressAndHoldButton.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: container + + property int repeatDelay: 300 + property int repeatDuration: 75 + property bool pressed: false + + signal clicked + + scale: pressed ? 0.9 : 1 + + function release() { + autoRepeatClicks.stop() + container.pressed = false + } + + SequentialAnimation on pressed { + id: autoRepeatClicks + running: false + + PropertyAction { target: container; property: "pressed"; value: true } + ScriptAction { script: container.clicked() } + PauseAnimation { duration: repeatDelay } + + SequentialAnimation { + loops: Animation.Infinite + ScriptAction { script: container.clicked() } + PauseAnimation { duration: repeatDuration } + } + } + + MouseArea { + anchors.fill: parent + + onPressed: autoRepeatClicks.start() + onReleased: container.release() + onCanceled: container.release() + } +} + diff --git a/examples/qtquick/modelviews/listview/content/RecipesModel.qml b/examples/qtquick/modelviews/listview/content/RecipesModel.qml new file mode 100644 index 0000000000..86210ba436 --- /dev/null +++ b/examples/qtquick/modelviews/listview/content/RecipesModel.qml @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + title: "Pancakes" + picture: "content/pics/pancakes.jpg" + ingredients: " +
            +
          • 1 cup (150g) self-raising flour +
          • 1 tbs caster sugar +
          • 3/4 cup (185ml) milk +
          • 1 egg +
          + " + method: " +
            +
          1. Sift flour and sugar together into a bowl. Add a pinch of salt. +
          2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. +
          3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. +
          4. Turn over and cook other side until golden. +
          + " + } + ListElement { + title: "Fruit Salad" + picture: "content/pics/fruit-salad.jpg" + ingredients: "* Seasonal Fruit" + method: "* Chop fruit and place in a bowl." + } + ListElement { + title: "Vegetable Soup" + picture: "content/pics/vegetable-soup.jpg" + ingredients: " +
            +
          • 1 onion +
          • 1 turnip +
          • 1 potato +
          • 1 carrot +
          • 1 head of celery +
          • 1 1/2 litres of water +
          + " + method: " +
            +
          1. Chop vegetables. +
          2. Boil in water until vegetables soften. +
          3. Season with salt and pepper to taste. +
          + " + } + ListElement { + title: "Hamburger" + picture: "content/pics/hamburger.jpg" + ingredients: " +
            +
          • 500g minced beef +
          • Seasoning +
          • lettuce, tomato, onion, cheese +
          • 1 hamburger bun for each burger +
          + " + method: " +
            +
          1. Mix the beef, together with seasoning, in a food processor. +
          2. Shape the beef into burgers. +
          3. Grill the burgers for about 5 mins on each side (until cooked through) +
          4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. +
          + " + } + ListElement { + title: "Lemonade" + picture: "content/pics/lemonade.jpg" + ingredients: " +
            +
          • 1 cup Lemon Juice +
          • 1 cup Sugar +
          • 6 Cups of Water (2 cups warm water, 4 cups cold water) +
          + " + method: " +
            +
          1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. +
          2. Pour in lemon juice, stir again, and add 4 cups of cold water. +
          3. Chill or serve over ice cubes. +
          + " + } +} diff --git a/examples/qtquick/modelviews/listview/content/TextButton.qml b/examples/qtquick/modelviews/listview/content/TextButton.qml new file mode 100644 index 0000000000..980ee21553 --- /dev/null +++ b/examples/qtquick/modelviews/listview/content/TextButton.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property alias text: label.text + + signal clicked + + width: label.width + 20; height: label.height + 6 + smooth: true + radius: 10 + + gradient: Gradient { + GradientStop { id: gradientStop; position: 0.0; color: palette.light } + GradientStop { position: 1.0; color: palette.button } + } + + SystemPalette { id: palette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { container.clicked() } + } + + Text { + id: label + anchors.centerIn: parent + } + + states: State { + name: "pressed" + when: mouseArea.pressed + PropertyChanges { target: gradientStop; color: palette.dark } + } +} + diff --git a/examples/qtquick/modelviews/listview/content/ToggleButton.qml b/examples/qtquick/modelviews/listview/content/ToggleButton.qml new file mode 100644 index 0000000000..0754d9849b --- /dev/null +++ b/examples/qtquick/modelviews/listview/content/ToggleButton.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + property alias label: text.text + property bool active: false + signal toggled + width: 149 + height: 30 + radius: 3 + color: active ? "green" : "lightgray" + border.width: 1 + Text { id: text; anchors.centerIn: parent; font.pixelSize: 14 } + MouseArea { + anchors.fill: parent + onClicked: { active = !active; root.toggled() } + } +} diff --git a/examples/qtquick/modelviews/listview/content/pics/arrow-down.png b/examples/qtquick/modelviews/listview/content/pics/arrow-down.png new file mode 100644 index 0000000000..29d1d4439a Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/arrow-down.png differ diff --git a/examples/qtquick/modelviews/listview/content/pics/arrow-up.png b/examples/qtquick/modelviews/listview/content/pics/arrow-up.png new file mode 100644 index 0000000000..e437312217 Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/arrow-up.png differ diff --git a/examples/qtquick/modelviews/listview/content/pics/fruit-salad.jpg b/examples/qtquick/modelviews/listview/content/pics/fruit-salad.jpg new file mode 100644 index 0000000000..da5a6b10a2 Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/fruit-salad.jpg differ diff --git a/examples/qtquick/modelviews/listview/content/pics/hamburger.jpg b/examples/qtquick/modelviews/listview/content/pics/hamburger.jpg new file mode 100644 index 0000000000..d0a15be1bf Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/hamburger.jpg differ diff --git a/examples/qtquick/modelviews/listview/content/pics/lemonade.jpg b/examples/qtquick/modelviews/listview/content/pics/lemonade.jpg new file mode 100644 index 0000000000..db445c9ac8 Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/lemonade.jpg differ diff --git a/examples/qtquick/modelviews/listview/content/pics/list-delete.png b/examples/qtquick/modelviews/listview/content/pics/list-delete.png new file mode 100644 index 0000000000..df2a147d24 Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/list-delete.png differ diff --git a/examples/qtquick/modelviews/listview/content/pics/minus-sign.png b/examples/qtquick/modelviews/listview/content/pics/minus-sign.png new file mode 100644 index 0000000000..d6f233d739 Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/minus-sign.png differ diff --git a/examples/qtquick/modelviews/listview/content/pics/moreDown.png b/examples/qtquick/modelviews/listview/content/pics/moreDown.png new file mode 100644 index 0000000000..31a35d5c20 Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/moreDown.png differ diff --git a/examples/qtquick/modelviews/listview/content/pics/moreUp.png b/examples/qtquick/modelviews/listview/content/pics/moreUp.png new file mode 100644 index 0000000000..fefb9c9098 Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/moreUp.png differ diff --git a/examples/qtquick/modelviews/listview/content/pics/pancakes.jpg b/examples/qtquick/modelviews/listview/content/pics/pancakes.jpg new file mode 100644 index 0000000000..60c439638e Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/pancakes.jpg differ diff --git a/examples/qtquick/modelviews/listview/content/pics/plus-sign.png b/examples/qtquick/modelviews/listview/content/pics/plus-sign.png new file mode 100644 index 0000000000..40df1134f8 Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/plus-sign.png differ diff --git a/examples/qtquick/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/qtquick/modelviews/listview/content/pics/vegetable-soup.jpg new file mode 100644 index 0000000000..9dce332041 Binary files /dev/null and b/examples/qtquick/modelviews/listview/content/pics/vegetable-soup.jpg differ diff --git a/examples/qtquick/modelviews/listview/dynamiclist.qml b/examples/qtquick/modelviews/listview/dynamiclist.qml new file mode 100644 index 0000000000..ee7c6329bc --- /dev/null +++ b/examples/qtquick/modelviews/listview/dynamiclist.qml @@ -0,0 +1,203 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import "content" + +// This example shows how items can be dynamically added to and removed from +// a ListModel, and how these list modifications can be animated. + +Rectangle { + id: container + width: 500; height: 400 + color: "#343434" + + // The model: + ListModel { + id: fruitModel + + ListElement { + name: "Apple"; cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Banana"; cost: 1.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Seedless" } + ] + } + ListElement { + name: "Cumquat"; cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Durian"; cost: 9.95 + attributes: [ + ListElement { description: "Tropical" }, + ListElement { description: "Smelly" } + ] + } + } + + // The delegate for each fruit in the model: + Component { + id: listDelegate + + Item { + id: delegateItem + width: listView.width; height: 55 + clip: true + + Row { + anchors.verticalCenter: parent.verticalCenter + spacing: 10 + + Column { + Image { + source: "content/pics/arrow-up.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) } + } + Image { source: "content/pics/arrow-down.png" + MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) } + } + } + + Column { + anchors.verticalCenter: parent.verticalCenter + + Text { + text: name + font.pixelSize: 15 + color: "white" + } + Row { + spacing: 5 + Repeater { + model: attributes + Text { text: description; color: "White" } + } + } + } + } + + Row { + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + spacing: 10 + + PressAndHoldButton { + anchors.verticalCenter: parent.verticalCenter + source: "content/pics/plus-sign.png" + onClicked: fruitModel.setProperty(index, "cost", cost + 0.25) + } + + Text { + id: costText + anchors.verticalCenter: parent.verticalCenter + text: '$' + Number(cost).toFixed(2) + font.pixelSize: 15 + color: "white" + font.bold: true + } + + PressAndHoldButton { + anchors.verticalCenter: parent.verticalCenter + source: "content/pics/minus-sign.png" + onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) + } + + Image { + source: "content/pics/list-delete.png" + MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } + } + } + + // Animate adding and removing of items: + + ListView.onAdd: SequentialAnimation { + PropertyAction { target: delegateItem; property: "height"; value: 0 } + NumberAnimation { target: delegateItem; property: "height"; to: 55; duration: 250; easing.type: Easing.InOutQuad } + } + + ListView.onRemove: SequentialAnimation { + PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true } + NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad } + + // Make sure delayRemove is set back to false so that the item can be destroyed + PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false } + } + } + } + + // The view: + ListView { + id: listView + anchors.fill: parent; anchors.margins: 20 + model: fruitModel + delegate: listDelegate + } + + Row { + anchors { left: parent.left; bottom: parent.bottom; margins: 20 } + spacing: 10 + + TextButton { + text: "Add an item" + onClicked: { + fruitModel.append({ + "name": "Pizza Margarita", + "cost": 5.95, + "attributes": [{"description": "Cheese"}, {"description": "Tomato"}] + }) + } + } + + TextButton { + text: "Remove all items" + onClicked: fruitModel.clear() + } + } +} + diff --git a/examples/qtquick/modelviews/listview/expandingdelegates.qml b/examples/qtquick/modelviews/listview/expandingdelegates.qml new file mode 100644 index 0000000000..43a9662422 --- /dev/null +++ b/examples/qtquick/modelviews/listview/expandingdelegates.qml @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +// This example illustrates expanding a list item to show a more detailed view. + +Rectangle { + id: page + width: 400; height: 240 + color: "black" + + // Delegate for the recipes. This delegate has two modes: + // 1. List mode (default), which just shows the picture and title of the recipe. + // 2. Details mode, which also shows the ingredients and method. + Component { + id: recipeDelegate + + Item { + id: recipe + + // Create a property to contain the visibility of the details. + // We can bind multiple element's opacity to this one property, + // rather than having a "PropertyChanges" line for each element we + // want to fade. + property real detailsOpacity : 0 + + width: listView.width + height: 70 + + // A simple rounded rectangle for the background + Rectangle { + id: background + x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 + color: "ivory" + border.color: "orange" + radius: 5 + } + + // This mouse region covers the entire delegate. + // When clicked it changes mode to 'Details'. If we are already + // in Details mode, then no change will happen. + MouseArea { + anchors.fill: parent + onClicked: recipe.state = 'Details'; + } + + // Lay out the page: picture, title and ingredients at the top, and method at the + // bottom. Note that elements that should not be visible in the list + // mode have their opacity set to recipe.detailsOpacity. + Row { + id: topLayout + x: 10; y: 10; height: recipeImage.height; width: parent.width + spacing: 10 + + Image { + id: recipeImage + width: 50; height: 50 + source: picture + } + + Column { + width: background.width - recipeImage.width - 20; height: recipeImage.height + spacing: 5 + + Text { + text: title + font.bold: true; font.pointSize: 16 + } + + Text { + text: "Ingredients" + font.pointSize: 12; font.bold: true + opacity: recipe.detailsOpacity + } + + Text { + text: ingredients + wrapMode: Text.WordWrap + width: parent.width + opacity: recipe.detailsOpacity + } + } + } + + Item { + id: details + x: 10; width: parent.width - 20 + anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + opacity: recipe.detailsOpacity + + Text { + id: methodTitle + anchors.top: parent.top + text: "Method" + font.pointSize: 12; font.bold: true + } + + Flickable { + id: flick + width: parent.width + anchors { top: methodTitle.bottom; bottom: parent.bottom } + contentHeight: methodText.height + clip: true + + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } + } + + Image { + anchors { right: flick.right; top: flick.top } + source: "content/pics/moreUp.png" + opacity: flick.atYBeginning ? 0 : 1 + } + + Image { + anchors { right: flick.right; bottom: flick.bottom } + source: "content/pics/moreDown.png" + opacity: flick.atYEnd ? 0 : 1 + } + } + + // A button to close the detailed view, i.e. set the state back to default (''). + TextButton { + y: 10 + anchors { right: background.right; rightMargin: 10 } + opacity: recipe.detailsOpacity + text: "Close" + + onClicked: recipe.state = ''; + } + + states: State { + name: "Details" + + PropertyChanges { target: background; color: "white" } + PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger + PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible + PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view + + // Move the list so that this item is at the top. + PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } + + // Disallow flicking while we're in detailed view + PropertyChanges { target: recipe.ListView.view; interactive: false } + } + + transitions: Transition { + // Make the state changes smooth + ParallelAnimation { + ColorAnimation { property: "color"; duration: 500 } + NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" } + } + } + } + } + + // The actual list + ListView { + id: listView + anchors.fill: parent + model: RecipesModel {} + delegate: recipeDelegate + } +} diff --git a/examples/qtquick/modelviews/listview/highlight.qml b/examples/qtquick/modelviews/listview/highlight.qml new file mode 100644 index 0000000000..d8f76080e6 --- /dev/null +++ b/examples/qtquick/modelviews/listview/highlight.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example shows how to create your own highlight delegate for a ListView +// that uses a SpringAnimation to provide custom movement when the +// highlight bar is moved between items. + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 200; height: 300 + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + Component { + id: petDelegate + Item { + id: wrapper + width: 200; height: 55 + Column { + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } + // indent the item if it is the current item + states: State { + name: "Current" + when: wrapper.ListView.isCurrentItem + PropertyChanges { target: wrapper; x: 20 } + } + transitions: Transition { + NumberAnimation { properties: "x"; duration: 200 } + } + } + } + + // Define a highlight with customised movement between items. + Component { + id: highlightBar + Rectangle { + width: 200; height: 50 + color: "#FFFF88" + y: listView.currentItem.y; + Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } } + } + } + + ListView { + id: listView + width: 200; height: parent.height + + model: PetsModel {} + delegate: petDelegate + focus: true + + // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem + // to false so the highlight delegate can control how the highlight is moved. + highlight: highlightBar + highlightFollowsCurrentItem: false + } +} diff --git a/examples/qtquick/modelviews/listview/highlightranges.qml b/examples/qtquick/modelviews/listview/highlightranges.qml new file mode 100644 index 0000000000..a536ddcbb2 --- /dev/null +++ b/examples/qtquick/modelviews/listview/highlightranges.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: root + property int current: 0 + width: 600; height: 300 + + // This example shows the same model in three different ListView items, + // with different highlight ranges. The highlight ranges are set by the + // preferredHighlightBegin and preferredHighlightEnd properties in ListView. + // + // The first ListView does not set a highlight range, so its currentItem + // can move freely within the visible area. If it moves outside the + // visible area, the view is automatically scrolled to keep the current + // item visible. + // + // The second ListView sets a highlight range which attempts to keep the + // current item within the the bounds of the range. However, + // items will not scroll beyond the beginning or end of the view, + // forcing the highlight to move outside the range at the ends. + // + // The third ListView sets the highlightRangeMode to StrictlyEnforceRange + // and sets a range smaller than the height of an item. This + // forces the current item to change when the view is flicked, + // since the highlight is unable to move. + // + // All ListViews bind their currentIndex to the root.current property. + // The first ListView sets root.current whenever its currentIndex changes + // due to keyboard interaction. + // Flicking the third ListView with the mouse also changes root.current. + + ListView { + id: list1 + width: 200; height: parent.height + model: PetsModel {} + delegate: petDelegate + + highlight: Rectangle { color: "lightsteelblue" } + currentIndex: root.current + onCurrentIndexChanged: root.current = currentIndex + focus: true + } + + ListView { + id: list2 + x: list1.width + width: 200; height: parent.height + model: PetsModel {} + delegate: petDelegate + + highlight: Rectangle { color: "yellow" } + currentIndex: root.current + preferredHighlightBegin: 80; preferredHighlightEnd: 220 + highlightRangeMode: ListView.ApplyRange + } + + ListView { + id: list3 + x: list1.width + list2.width + width: 200; height: parent.height + model: PetsModel {} + delegate: petDelegate + + highlight: Rectangle { color: "yellow" } + currentIndex: root.current + onCurrentIndexChanged: root.current = currentIndex + preferredHighlightBegin: 125; preferredHighlightEnd: 125 + highlightRangeMode: ListView.StrictlyEnforceRange + } + + // The delegate for each list + Component { + id: petDelegate + Column { + width: 200 + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + } + } +} diff --git a/examples/qtquick/modelviews/listview/sections.qml b/examples/qtquick/modelviews/listview/sections.qml new file mode 100644 index 0000000000..2e63a86bb6 --- /dev/null +++ b/examples/qtquick/modelviews/listview/sections.qml @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example shows how a ListView can be separated into sections using +// the ListView.section attached property. + +import QtQuick 2.0 +import "content" + +Rectangle { + id: container + width: 300 + height: 360 + + ListModel { + id: animalsModel + ListElement { name: "Ant"; size: "Tiny" } + ListElement { name: "Flea"; size: "Tiny" } + ListElement { name: "Parrot"; size: "Small" } + ListElement { name: "Guinea pig"; size: "Small" } + ListElement { name: "Rat"; size: "Small" } + ListElement { name: "Butterfly"; size: "Small" } + ListElement { name: "Dog"; size: "Medium" } + ListElement { name: "Cat"; size: "Medium" } + ListElement { name: "Pony"; size: "Medium" } + ListElement { name: "Koala"; size: "Medium" } + ListElement { name: "Horse"; size: "Large" } + ListElement { name: "Tiger"; size: "Large" } + ListElement { name: "Giraffe"; size: "Large" } + ListElement { name: "Elephant"; size: "Huge" } + ListElement { name: "Whale"; size: "Huge" } + } + +//! [0] + // The delegate for each section header + Component { + id: sectionHeading + Rectangle { + width: container.width + height: childrenRect.height + color: "lightsteelblue" + + Text { + text: section + font.bold: true + font.pixelSize: 20 + } + } + } + + ListView { + id: view + anchors.top: parent.top + anchors.bottom: buttonBar.top + width: parent.width + model: animalsModel + delegate: Text { text: name; font.pixelSize: 18 } + + section.property: "size" + section.criteria: ViewSection.FullString + section.delegate: sectionHeading + } +//! [0] + + Row { + id: buttonBar + anchors.bottom: parent.bottom + anchors.bottomMargin: 1 + spacing: 1 + ToggleButton { + label: "CurrentLabelAtStart" + onToggled: { + if (active) + view.section.labelPositioning |= ViewSection.CurrentLabelAtStart + else + view.section.labelPositioning &= ~ViewSection.CurrentLabelAtStart + } + } + ToggleButton { + label: "NextLabelAtEnd" + onToggled: { + if (active) + view.section.labelPositioning |= ViewSection.NextLabelAtEnd + else + view.section.labelPositioning &= ~ViewSection.NextLabelAtEnd + } + } + } +} + diff --git a/examples/qtquick/modelviews/modelviews.pro b/examples/qtquick/modelviews/modelviews.pro new file mode 100644 index 0000000000..7748da0471 --- /dev/null +++ b/examples/qtquick/modelviews/modelviews.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + abstractitemmodel \ + objectlistmodel \ + stringlistmodel + + diff --git a/examples/qtquick/modelviews/modelviews.qml b/examples/qtquick/modelviews/modelviews.qml new file mode 100644 index 0000000000..f11608bcc7 --- /dev/null +++ b/examples/qtquick/modelviews/modelviews.qml @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../../shared" + +Item { + height: 480 + width: 480 + LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("Dynamic List", "A ListView harboring dynamic data", Qt.resolvedUrl("listview/dynamiclist.qml")); + addExample("Expanding Delegates", "Delegates that expand to fill the list when clicked", Qt.resolvedUrl("listview/expandingdelegates.qml")); + addExample("Highlight", "Adding a highlight to the current item", Qt.resolvedUrl("listview/highlight.qml")); + addExample("Sections", "A ListView with section headers", Qt.resolvedUrl("listview/sections.qml")); + addExample("GridView", "A view laid out in a grid", Qt.resolvedUrl("gridview/gridview-example.qml")); + addExample("PathView", "A view laid out along a path", Qt.resolvedUrl("pathview/pathview-example.qml")); + addExample("Package", "Using a package to transition items between views", Qt.resolvedUrl("package/view.qml")); + addExample("Parallax", "Adds a background and a parallax effect to a ListView", Qt.resolvedUrl("parallax/parallax.qml")); + addExample("Slideshow", "A model demonstrating delayed image loading", Qt.resolvedUrl("visualdatamodel/slideshow.qml")); + addExample("Sorted Model", "Two views on a model, one of which is sorted", Qt.resolvedUrl("visualdatamodel/sortedmodel.qml")); + addExample("VisualItemModel", "A model that consists of the actual Items", Qt.resolvedUrl("visualitemmodel/visualitemmodel.qml")); + } + } +} diff --git a/examples/qtquick/modelviews/modelviews.qmlproject b/examples/qtquick/modelviews/modelviews.qmlproject new file mode 100644 index 0000000000..40f9e568fd --- /dev/null +++ b/examples/qtquick/modelviews/modelviews.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "modelviews.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/modelviews/objectlistmodel/dataobject.cpp b/examples/qtquick/modelviews/objectlistmodel/dataobject.cpp new file mode 100644 index 0000000000..7216283616 --- /dev/null +++ b/examples/qtquick/modelviews/objectlistmodel/dataobject.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "dataobject.h" + +DataObject::DataObject(QObject *parent) + : QObject(parent) +{ +} + +DataObject::DataObject(const QString &name, const QString &color, QObject *parent) + : QObject(parent), m_name(name), m_color(color) +{ +} + +QString DataObject::name() const +{ + return m_name; +} + +void DataObject::setName(const QString &name) +{ + if (name != m_name) { + m_name = name; + emit nameChanged(); + } +} + +QString DataObject::color() const +{ + return m_color; +} + +void DataObject::setColor(const QString &color) +{ + if (color != m_color) { + m_color = color; + emit colorChanged(); + } +} diff --git a/examples/qtquick/modelviews/objectlistmodel/dataobject.h b/examples/qtquick/modelviews/objectlistmodel/dataobject.h new file mode 100644 index 0000000000..bea92a273c --- /dev/null +++ b/examples/qtquick/modelviews/objectlistmodel/dataobject.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef DATAOBJECT_H +#define DATAOBJECT_H + +#include + +//![0] +class DataObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) +//![0] + +public: + DataObject(QObject *parent=0); + DataObject(const QString &name, const QString &color, QObject *parent=0); + + QString name() const; + void setName(const QString &name); + + QString color() const; + void setColor(const QString &color); + +signals: + void nameChanged(); + void colorChanged(); + +private: + QString m_name; + QString m_color; +//![1] +}; +//![1] + +#endif // DATAOBJECT_H diff --git a/examples/qtquick/modelviews/objectlistmodel/main.cpp b/examples/qtquick/modelviews/objectlistmodel/main.cpp new file mode 100644 index 0000000000..c8542976c3 --- /dev/null +++ b/examples/qtquick/modelviews/objectlistmodel/main.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include "dataobject.h" + +/* + This example illustrates exposing a QList as a + model in QML +*/ + +//![0] +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + QList dataList; + dataList.append(new DataObject("Item 1", "red")); + dataList.append(new DataObject("Item 2", "green")); + dataList.append(new DataObject("Item 3", "blue")); + dataList.append(new DataObject("Item 4", "yellow")); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + QDeclarativeContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.pro b/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.pro new file mode 100644 index 0000000000..74dc5b1016 --- /dev/null +++ b/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.pro @@ -0,0 +1,6 @@ +QT += declarative quick + +SOURCES += main.cpp \ + dataobject.cpp +HEADERS += dataobject.h +RESOURCES += objectlistmodel.qrc diff --git a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qrc new file mode 100644 index 0000000000..17e9301471 --- /dev/null +++ b/examples/qtquick/modelviews/objectlistmodel/objectlistmodel.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/qtquick/modelviews/objectlistmodel/view.qml b/examples/qtquick/modelviews/objectlistmodel/view.qml new file mode 100644 index 0000000000..3954e79829 --- /dev/null +++ b/examples/qtquick/modelviews/objectlistmodel/view.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +ListView { + width: 100; height: 100 + + model: myModel + delegate: Rectangle { + height: 25 + width: 100 + color: model.modelData.color + Text { text: name } + } +} +//![0] diff --git a/examples/qtquick/modelviews/package/Delegate.qml b/examples/qtquick/modelviews/package/Delegate.qml new file mode 100644 index 0000000000..97c7840cb4 --- /dev/null +++ b/examples/qtquick/modelviews/package/Delegate.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Package { + Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } + + Rectangle { + id: wrapper + width: 200; height: 25 + color: 'lightsteelblue' + + Text { text: display; anchors.centerIn: parent } + MouseArea { + anchors.fill: parent + onClicked: { + if (wrapper.state == 'inList') + wrapper.state = 'inGrid'; + else + wrapper.state = 'inList'; + } + } + + state: 'inList' + states: [ + State { + name: 'inList' + ParentChange { target: wrapper; parent: listDelegate } + }, + State { + name: 'inGrid' + ParentChange { + target: wrapper; parent: gridDelegate + x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } +} +//![0] diff --git a/examples/qtquick/modelviews/package/view.qml b/examples/qtquick/modelviews/package/view.qml new file mode 100644 index 0000000000..7ba6664ae2 --- /dev/null +++ b/examples/qtquick/modelviews/package/view.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "white" + width: 400 + height: 200 + + ListModel { + id: myModel + ListElement { display: "One" } + ListElement { display: "Two" } + ListElement { display: "Three" } + ListElement { display: "Four" } + ListElement { display: "Five" } + ListElement { display: "Six" } + ListElement { display: "Seven" } + ListElement { display: "Eight" } + } + //![0] + VisualDataModel { + id: visualModel + delegate: Delegate {} + model: myModel + } + + ListView { + width: 200; height:200 + model: visualModel.parts.list + } + GridView { + x: 200; width: 200; height:200 + cellHeight: 50 + model: visualModel.parts.grid + } + //![0] + Text { + anchors.bottom: parent.bottom + text: "Tap a delegate to move between views" + } +} diff --git a/examples/qtquick/modelviews/parallax/content/Clock.qml b/examples/qtquick/modelviews/parallax/content/Clock.qml new file mode 100644 index 0000000000..7f0e8cba83 --- /dev/null +++ b/examples/qtquick/modelviews/parallax/content/Clock.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id : clock + width: { + if (ListView.view && ListView.view.width >= 200) + return ListView.view.width / Math.floor(ListView.view.width / 200.0); + else + return 200; + } + + height: { + if (ListView.view && ListView.view.height >= 240) + return ListView.view.height; + else + return 240; + } + + property alias city: cityLabel.text + property int hours + property int minutes + property int seconds + property real shift + property bool night: false + property bool internationalTime: true //Unset for local time + + function timeChanged() { + var date = new Date; + hours = internationalTime ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() + night = ( hours < 7 || hours > 19 ) + minutes = internationalTime ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes() + seconds = date.getUTCSeconds(); + } + + Timer { + interval: 100; running: true; repeat: true; + onTriggered: clock.timeChanged() + } + + Item { + anchors.centerIn: parent + width: 200; height: 240 + + Image { id: background; source: "clock.png"; visible: clock.night == false } + Image { source: "clock-night.png"; visible: clock.night == true } + + + Image { + x: 92.5; y: 27 + source: "hour.png" + smooth: true + transform: Rotation { + id: hourRotation + origin.x: 7.5; origin.y: 73; + angle: (clock.hours * 30) + (clock.minutes * 0.5) + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + x: 93.5; y: 17 + source: "minute.png" + smooth: true + transform: Rotation { + id: minuteRotation + origin.x: 6.5; origin.y: 83; + angle: clock.minutes * 6 + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + x: 97.5; y: 20 + source: "second.png" + smooth: true + transform: Rotation { + id: secondRotation + origin.x: 2.5; origin.y: 80; + angle: clock.seconds * 6 + Behavior on angle { + SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } + } + } + } + + Image { + anchors.centerIn: background; source: "center.png" + } + + Text { + id: cityLabel + y: 210; anchors.horizontalCenter: parent.horizontalCenter + color: "white" + font.family: "Helvetica" + font.bold: true; font.pixelSize: 16 + style: Text.Raised; styleColor: "black" + } + } +} diff --git a/examples/qtquick/modelviews/parallax/content/ParallaxView.qml b/examples/qtquick/modelviews/parallax/content/ParallaxView.qml new file mode 100644 index 0000000000..2acf50dcef --- /dev/null +++ b/examples/qtquick/modelviews/parallax/content/ParallaxView.qml @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + + property alias background: background.source + property int currentIndex: 0 + default property alias content: visualModel.children + + Image { + id: background + fillMode: Image.TileHorizontally + x: -list.contentX / 2 + width: Math.max(list.contentWidth, parent.width) + } + + ListView { + id: list + anchors.fill: parent + + currentIndex: root.currentIndex + onCurrentIndexChanged: root.currentIndex = currentIndex + + orientation: Qt.Horizontal + boundsBehavior: Flickable.DragOverBounds + model: VisualItemModel { id: visualModel } + + highlightRangeMode: ListView.StrictlyEnforceRange + snapMode: ListView.SnapOneItem + } + + ListView { + id: selector + + height: 50 + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + width: Math.min(count * 50, parent.width - 20) + interactive: width == parent.width - 20 + orientation: Qt.Horizontal + + currentIndex: root.currentIndex + onCurrentIndexChanged: root.currentIndex = currentIndex + + model: visualModel.children + delegate: Item { + width: 50; height: 50 + id: delegateRoot + + Image { + id: image + source: modelData.icon + smooth: true + scale: 0.8 + } + + MouseArea { + anchors.fill: parent + onClicked: { root.currentIndex = index } + } + + states: State { + name: "Selected" + when: delegateRoot.ListView.isCurrentItem == true + PropertyChanges { + target: image + scale: 1 + y: -5 + } + } + transitions: Transition { + NumberAnimation { properties: "scale,y" } + } + } + + Rectangle { + color: "#60FFFFFF" + x: -10; y: -10; z: -1 + width: parent.width + 20; height: parent.height + 20 + radius: 10 + } + } +} diff --git a/examples/qtquick/modelviews/parallax/content/QuitButton.qml b/examples/qtquick/modelviews/parallax/content/QuitButton.qml new file mode 100644 index 0000000000..702b892d23 --- /dev/null +++ b/examples/qtquick/modelviews/parallax/content/QuitButton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/qtquick/modelviews/parallax/content/Smiley.qml b/examples/qtquick/modelviews/parallax/content/Smiley.qml new file mode 100644 index 0000000000..982b6c5d2b --- /dev/null +++ b/examples/qtquick/modelviews/parallax/content/Smiley.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +// This is taken from the declarative animation/basics/property-animation.qml +// example + +Item { + id: window + width: 320; height: 480 + + Image { + anchors.horizontalCenter: parent.horizontalCenter + y: smiley.minHeight + 58 + source: "pics/shadow.png" + + scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) + } + + Image { + id: smiley + property int maxHeight: window.height / 3 + property int minHeight: 2 * window.height / 3 + + anchors.horizontalCenter: parent.horizontalCenter + y: minHeight + source: "pics/face-smile.png" + + SequentialAnimation on y { + loops: Animation.Infinite + + NumberAnimation { + from: smiley.minHeight; to: smiley.maxHeight + easing.type: Easing.OutExpo; duration: 300 + } + + NumberAnimation { + from: smiley.maxHeight; to: smiley.minHeight + easing.type: Easing.OutBounce; duration: 1000 + } + + PauseAnimation { duration: 500 } + } + } +} + diff --git a/examples/qtquick/modelviews/parallax/content/background.png b/examples/qtquick/modelviews/parallax/content/background.png new file mode 100644 index 0000000000..a885950862 Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/background.png differ diff --git a/examples/qtquick/modelviews/parallax/content/center.png b/examples/qtquick/modelviews/parallax/content/center.png new file mode 100644 index 0000000000..7fbd802a44 Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/center.png differ diff --git a/examples/qtquick/modelviews/parallax/content/clock-night.png b/examples/qtquick/modelviews/parallax/content/clock-night.png new file mode 100644 index 0000000000..cc7151a397 Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/clock-night.png differ diff --git a/examples/qtquick/modelviews/parallax/content/clock.png b/examples/qtquick/modelviews/parallax/content/clock.png new file mode 100644 index 0000000000..462edacc0e Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/clock.png differ diff --git a/examples/qtquick/modelviews/parallax/content/hour.png b/examples/qtquick/modelviews/parallax/content/hour.png new file mode 100644 index 0000000000..f8061a1235 Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/hour.png differ diff --git a/examples/qtquick/modelviews/parallax/content/minute.png b/examples/qtquick/modelviews/parallax/content/minute.png new file mode 100644 index 0000000000..1297ec7c2b Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/minute.png differ diff --git a/examples/qtquick/modelviews/parallax/content/pics/background.jpg b/examples/qtquick/modelviews/parallax/content/pics/background.jpg new file mode 100644 index 0000000000..61cca2f138 Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/pics/background.jpg differ diff --git a/examples/qtquick/modelviews/parallax/content/pics/face-smile.png b/examples/qtquick/modelviews/parallax/content/pics/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/pics/face-smile.png differ diff --git a/examples/qtquick/modelviews/parallax/content/pics/home-page.png b/examples/qtquick/modelviews/parallax/content/pics/home-page.png new file mode 100644 index 0000000000..bd090c3708 Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/pics/home-page.png differ diff --git a/examples/qtquick/modelviews/parallax/content/pics/home-page.svg b/examples/qtquick/modelviews/parallax/content/pics/home-page.svg new file mode 100644 index 0000000000..4f16958844 --- /dev/null +++ b/examples/qtquick/modelviews/parallax/content/pics/home-page.svg @@ -0,0 +1,445 @@ + +image/svg+xmlGo HomeJakub Steinerhttp://jimmac.musichall.czhomereturngodefaultuserdirectoryTuomas Kuosmanen + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/qtquick/modelviews/parallax/content/pics/shadow.png b/examples/qtquick/modelviews/parallax/content/pics/shadow.png new file mode 100644 index 0000000000..8270565e87 Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/pics/shadow.png differ diff --git a/examples/qtquick/modelviews/parallax/content/pics/yast-joystick.png b/examples/qtquick/modelviews/parallax/content/pics/yast-joystick.png new file mode 100644 index 0000000000..858cea0301 Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/pics/yast-joystick.png differ diff --git a/examples/qtquick/modelviews/parallax/content/pics/yast-wol.png b/examples/qtquick/modelviews/parallax/content/pics/yast-wol.png new file mode 100644 index 0000000000..7712180a3b Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/pics/yast-wol.png differ diff --git a/examples/qtquick/modelviews/parallax/content/quit.png b/examples/qtquick/modelviews/parallax/content/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/quit.png differ diff --git a/examples/qtquick/modelviews/parallax/content/second.png b/examples/qtquick/modelviews/parallax/content/second.png new file mode 100644 index 0000000000..4aa9fb5e8e Binary files /dev/null and b/examples/qtquick/modelviews/parallax/content/second.png differ diff --git a/examples/qtquick/modelviews/parallax/parallax.qml b/examples/qtquick/modelviews/parallax/parallax.qml new file mode 100644 index 0000000000..30578e510e --- /dev/null +++ b/examples/qtquick/modelviews/parallax/parallax.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 320; height: 480 + + ParallaxView { + id: parallax + anchors.fill: parent + background: "content/pics/background.jpg" + + Item { + property url icon: "content/pics/yast-wol.png" + width: 320; height: 480 + Clock { anchors.centerIn: parent } + } + + Item { + property url icon: "content/pics/home-page.png" + width: 320; height: 480 + Smiley { } + } + + Item { + property url icon: "content/pics/yast-joystick.png" + width: 320; height: 480 + + Loader { + anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter } + width: 300; height: 400 + clip: true; + source: "../../samegame/samegame.qml" + } + } + } +} diff --git a/examples/qtquick/modelviews/pathview/pathview-example.qml b/examples/qtquick/modelviews/pathview/pathview-example.qml new file mode 100644 index 0000000000..6161343830 --- /dev/null +++ b/examples/qtquick/modelviews/pathview/pathview-example.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 400; height: 240 + color: "white" + + ListModel { + id: appModel + ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } + ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } + ListElement { name: "Camera"; icon: "pics/Camera_48.png" } + ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } + ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } + ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } + ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } + } + + Component { + id: appDelegate + Item { + width: 100; height: 100 + scale: PathView.iconScale + + Image { + id: myIcon + y: 20; anchors.horizontalCenter: parent.horizontalCenter + source: icon + smooth: true + } + Text { + anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } + text: name + smooth: true + } + + MouseArea { + anchors.fill: parent + onClicked: view.currentIndex = index + } + } + } + + Component { + id: appHighlight + Rectangle { width: 80; height: 80; color: "lightsteelblue" } + } + + PathView { + id: view + anchors.fill: parent + highlight: appHighlight + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + focus: true + model: appModel + delegate: appDelegate + path: Path { + startX: 10 + startY: 50 + PathAttribute { name: "iconScale"; value: 0.5 } + PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } + PathAttribute { name: "iconScale"; value: 1.0 } + PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } + PathAttribute { name: "iconScale"; value: 0.5 } + } + } +} diff --git a/examples/qtquick/modelviews/pathview/pics/AddressBook_48.png b/examples/qtquick/modelviews/pathview/pics/AddressBook_48.png new file mode 100644 index 0000000000..1ab7c8eec1 Binary files /dev/null and b/examples/qtquick/modelviews/pathview/pics/AddressBook_48.png differ diff --git a/examples/qtquick/modelviews/pathview/pics/AudioPlayer_48.png b/examples/qtquick/modelviews/pathview/pics/AudioPlayer_48.png new file mode 100644 index 0000000000..f4b8689f87 Binary files /dev/null and b/examples/qtquick/modelviews/pathview/pics/AudioPlayer_48.png differ diff --git a/examples/qtquick/modelviews/pathview/pics/Camera_48.png b/examples/qtquick/modelviews/pathview/pics/Camera_48.png new file mode 100644 index 0000000000..c76b524945 Binary files /dev/null and b/examples/qtquick/modelviews/pathview/pics/Camera_48.png differ diff --git a/examples/qtquick/modelviews/pathview/pics/DateBook_48.png b/examples/qtquick/modelviews/pathview/pics/DateBook_48.png new file mode 100644 index 0000000000..58f5787fb8 Binary files /dev/null and b/examples/qtquick/modelviews/pathview/pics/DateBook_48.png differ diff --git a/examples/qtquick/modelviews/pathview/pics/EMail_48.png b/examples/qtquick/modelviews/pathview/pics/EMail_48.png new file mode 100644 index 0000000000..d6d84a61be Binary files /dev/null and b/examples/qtquick/modelviews/pathview/pics/EMail_48.png differ diff --git a/examples/qtquick/modelviews/pathview/pics/TodoList_48.png b/examples/qtquick/modelviews/pathview/pics/TodoList_48.png new file mode 100644 index 0000000000..0988448d9b Binary files /dev/null and b/examples/qtquick/modelviews/pathview/pics/TodoList_48.png differ diff --git a/examples/qtquick/modelviews/pathview/pics/VideoPlayer_48.png b/examples/qtquick/modelviews/pathview/pics/VideoPlayer_48.png new file mode 100644 index 0000000000..52638c50a7 Binary files /dev/null and b/examples/qtquick/modelviews/pathview/pics/VideoPlayer_48.png differ diff --git a/examples/qtquick/modelviews/stringlistmodel/main.cpp b/examples/qtquick/modelviews/stringlistmodel/main.cpp new file mode 100644 index 0000000000..47d7fdaa8c --- /dev/null +++ b/examples/qtquick/modelviews/stringlistmodel/main.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include + + +/* + This example illustrates exposing a QStringList as a + model in QML +*/ + +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + +//![0] + QStringList dataList; + dataList.append("Item 1"); + dataList.append("Item 2"); + dataList.append("Item 3"); + dataList.append("Item 4"); + + QQuickView view; + QDeclarativeContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); +//![0] + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.pro b/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.pro new file mode 100644 index 0000000000..540d8c71f0 --- /dev/null +++ b/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.pro @@ -0,0 +1,4 @@ +QT += declarative quick + +SOURCES += main.cpp +RESOURCES += stringlistmodel.qrc diff --git a/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.qrc new file mode 100644 index 0000000000..17e9301471 --- /dev/null +++ b/examples/qtquick/modelviews/stringlistmodel/stringlistmodel.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/qtquick/modelviews/stringlistmodel/view.qml b/examples/qtquick/modelviews/stringlistmodel/view.qml new file mode 100644 index 0000000000..945763c295 --- /dev/null +++ b/examples/qtquick/modelviews/stringlistmodel/view.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] + +ListView { + width: 100; height: 100 + + model: myModel + delegate: Rectangle { + height: 25 + width: 100 + Text { text: modelData } + } +} +//![0] diff --git a/examples/qtquick/modelviews/visualdatamodel/dragselection.qml b/examples/qtquick/modelviews/visualdatamodel/dragselection.qml new file mode 100644 index 0000000000..c3186a5ad8 --- /dev/null +++ b/examples/qtquick/modelviews/visualdatamodel/dragselection.qml @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + + width: 320 + height: 480 + + property bool dragging: false + + Component { + id: packageDelegate + Package { + id: packageRoot + + MouseArea { + id: visibleContainer + Package.name: "visible" + + width: 64 + height: 64 + enabled: packageRoot.VisualDataModel.inSelected + + drag.target: draggable + + Item { + id: draggable + + width: 64 + height: 64 + + Drag.active: visibleContainer.drag.active + + anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } + + states: State { + when: visibleContainer.drag.active + AnchorChanges { target: draggable; anchors { horizontalCenter: undefined; verticalCenter: undefined} } + ParentChange { target: selectionView; parent: draggable; x: 0; y: 0 } + PropertyChanges { target: root; dragging: true } + ParentChange { target: draggable; parent: root } + } + } + DropArea { + anchors.fill: parent + onEntered: selectedItems.move(0, visualModel.items.get(packageRoot.VisualDataModel.itemsIndex), selectedItems.count) + } + } + Item { + id: selectionContainer + Package.name: "selection" + + width: 64 + height: 64 + + visible: PathView.onPath + } + Rectangle { + id: content + parent: visibleContainer + + width: 58 + height: 58 + + radius: 8 + + gradient: Gradient { + GradientStop { id: gradientStart; position: 0.0; color: "#8AC953" } + GradientStop { id: gradientEnd; position: 1.0; color: "#8BC953" } + } + + border.width: 2 + border.color: "#007423" + + state: root.dragging && packageRoot.VisualDataModel.inSelected ? "selected" : "visible" + + Text { + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: "white" + text: modelData + font.pixelSize: 18 + } + + Rectangle { + anchors { right: parent.right; top: parent.top; margins: 3 } + width: 12; height: 12 + color: packageRoot.VisualDataModel.inSelected ? "black" : "white" + radius: 6 + + border.color: "white" + border.width: 2 + + MouseArea { + anchors.fill: parent + onClicked: packageRoot.VisualDataModel.inSelected = !packageRoot.VisualDataModel.inSelected + } + } + + states: [ + State { + name: "selected" + ParentChange { target: content; parent: selectionContainer; x: 3; y: 3 } + PropertyChanges { target: packageRoot; VisualDataModel.inItems: visibleContainer.drag.active } + PropertyChanges { target: gradientStart; color: "#017423" } + PropertyChanges { target: gradientStart; color: "#007423" } + }, State { + name: "visible" + PropertyChanges { target: packageRoot; VisualDataModel.inItems: true } + ParentChange { target: content; parent: visibleContainer; x: 3; y: 3 } + PropertyChanges { target: gradientStart; color: "#8AC953" } + PropertyChanges { target: gradientStart; color: "#8BC953" } + } + ] + transitions: Transition { + PropertyAction { target: packageRoot; properties: "VisualDataModel.inItems" } + ParentAnimation { + target: content + NumberAnimation { target: content; properties: "x,y"; duration: 500 } + } + ColorAnimation { targets: [gradientStart, gradientEnd]; duration: 500 } + } + } + } + } + + VisualDataModel { + id: visualModel + model: 35 + delegate: packageDelegate + + groups: VisualDataGroup { id: selectedItems; name: "selected" } + + Component.onCompleted: parts.selection.filterOnGroup = "selected" + } + + PathView { + id: selectionView + + height: 64 + width: 64 + + model: visualModel.parts.selection + + path: Path { + startX: 0 + startY: 0 + PathLine { x: 64; y: 64 } + } + } + + GridView { + id: itemsView + anchors { fill: parent } + cellWidth: 64 + cellHeight: 64 + model: visualModel.parts.visible + } +} diff --git a/examples/qtquick/modelviews/visualdatamodel/slideshow.qml b/examples/qtquick/modelviews/visualdatamodel/slideshow.qml new file mode 100644 index 0000000000..040c6be307 --- /dev/null +++ b/examples/qtquick/modelviews/visualdatamodel/slideshow.qml @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.XmlListModel 2.0 + +Rectangle { + id: root + + property Item displayItem: null + + width: 300; height: 400 + + color: "black" + + VisualDataModel { + id: visualModel + + model: XmlListModel { + source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2" + query: "/rss/channel/item" + namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" + + XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" } + XmlRole { name: "url"; query: "media:content/@url/string()" } + } + + delegate: Item { + id: delegateItem + + width: 76; height: 76 + + Rectangle { + id: image + x: 0; y: 0; width: 76; height: 76 + border.width: 1 + border.color: "white" + color: "black" + + Image { + anchors.fill: parent + anchors.leftMargin: 1 + anchors.topMargin: 1 + + source: imagePath + fillMode: Image.PreserveAspectFit + + } + + MouseArea { + id: clickArea + anchors.fill: parent + + onClicked: root.displayItem = root.displayItem !== delegateItem ? delegateItem : null + } + + states: [ + State { + when: root.displayItem === delegateItem + name: "inDisplay"; + ParentChange { target: image; parent: imageContainer; x: 75; y: 75; width: 150; height: 150 } + PropertyChanges { target: image; z: 2 } + PropertyChanges { target: delegateItem; VisualDataModel.inItems: false } + }, + State { + when: root.displayItem !== delegateItem + name: "inList"; + ParentChange { target: image; parent: delegateItem; x: 2; y: 2; width: 75; height: 75 } + PropertyChanges { target: image; z: 1 } + PropertyChanges { target: delegateItem; VisualDataModel.inItems: true } + } + ] + + transitions: [ + Transition { + from: "inList" + SequentialAnimation { + PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: true } + ParentAnimation { + target: image; + via: root + NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } + } + } + }, Transition { + from: "inDisplay" + SequentialAnimation { + ParentAnimation { + target: image + NumberAnimation { target: image; properties: "x,y,width,height"; duration: 1000 } + } + PropertyAction { target: delegateItem; property: "VisualDataModel.inPersistedItems"; value: false } + } + } + ] + } + } + } + + + PathView { + id: imagePath + + anchors { left: parent.left; top: imageContainer.bottom; right: parent.right; bottom: parent.bottom } + model: visualModel + + pathItemCount: 7 + path: Path { + startX: -50; startY: 0 + PathQuad { x: 150; y: 50; controlX: 0; controlY: 50 } + PathQuad { x: 350; y: 0; controlX: 300; controlY: 50 } + } + } + + Item { + id: imageContainer + anchors { fill: parent; bottomMargin: 100 } + } +} diff --git a/examples/qtquick/modelviews/visualdatamodel/sortedmodel.qml b/examples/qtquick/modelviews/visualdatamodel/sortedmodel.qml new file mode 100644 index 0000000000..8d3b0a58e5 --- /dev/null +++ b/examples/qtquick/modelviews/visualdatamodel/sortedmodel.qml @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 480; height: 640 + + Component { + id: numberDelegate + + Text { + id: numberText + anchors { left: parent.left; right: parent.right } + text: number + + horizontalAlignment: Text.AlignHCenter + font.pixelSize: 18 + + Text { + anchors { left: parent.left; baseline: parent.baseline } + text: index + + horizontalAlignment: Text.AlignLeft + font.pixelSize: 12 + } + Text { + anchors { right: parent.right; baseline: parent.baseline } + text: numberText.VisualDataModel.itemsIndex + + horizontalAlignment: Text.AlignRight + font.pixelSize: 12 + } + } + } + + ListView { + anchors { + left: parent.left; top: parent.top; + right: parent.horizontalCenter; bottom: button.top + leftMargin: 2; topMargin: 2; rightMargin: 1; bottomMargin: 2 + } + + model: ListModel { + id: unsortedModel + } + delegate: numberDelegate + } + ListView { + anchors { + left: parent.horizontalCenter; top: parent.top; + right: parent.right; bottom: button.top + leftMargin: 1; topMargin: 2; rightMargin: 2; bottomMargin: 2 + } + model: VisualDataModel { + model: unsortedModel + delegate: numberDelegate + + items.onChanged: { + for (var i = 0; i < inserted.length; ++i) { + for (var j = inserted[i].index; j < inserted[i].index + inserted[i].count; ++j) { + var number = items.get(j).model.number + for (var l = 0, k = 0; l < unsortedModel.count; ++l) { + if (l == inserted[k].index) { + l += inserted[k].count - 1 + ++k + } else if (number < items.get(l).model.number) { + items.move(j, l, 1) + break + } + } + inserted[i].index += 1; + inserted[i].count -= 1; + } + } + } + } + } + + Rectangle { + id: button + + anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 } + height: moreText.implicitHeight + 4 + + color: "black" + + Text { + id: moreText + + anchors.fill: parent + text: "More" + color: "white" + font.pixelSize: 18 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + MouseArea { + anchors.fill: parent + + onClicked: unsortedModel.append({ "number": Math.floor(Math.random() * 100) }) + } + } +} diff --git a/examples/qtquick/modelviews/visualdatamodel/visualdatamodel.qmlproject b/examples/qtquick/modelviews/visualdatamodel/visualdatamodel.qmlproject new file mode 100644 index 0000000000..2bb4016996 --- /dev/null +++ b/examples/qtquick/modelviews/visualdatamodel/visualdatamodel.qmlproject @@ -0,0 +1,14 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/modelviews/visualitemmodel/visualitemmodel.qml b/examples/qtquick/modelviews/visualitemmodel/visualitemmodel.qml new file mode 100644 index 0000000000..2e012adec6 --- /dev/null +++ b/examples/qtquick/modelviews/visualitemmodel/visualitemmodel.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This example demonstrates placing items in a view using +// a VisualItemModel + +import QtQuick 2.0 + +Rectangle { + id: root + color: "lightgray" + width: 320 + height: 480 + property bool printDestruction: false + + VisualItemModel { + id: itemModel + + Rectangle { + width: view.width; height: view.height + color: "#FFFEF0" + Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 1") + } + Rectangle { + width: view.width; height: view.height + color: "#F0FFF7" + Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 2") + } + Rectangle { + width: view.width; height: view.height + color: "#F4F0FF" + Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } + + Component.onDestruction: if (printDestruction) print("destroyed 3") + } + } + + ListView { + id: view + anchors { fill: parent; bottomMargin: 30 } + model: itemModel + preferredHighlightBegin: 0; preferredHighlightEnd: 0 + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem; flickDeceleration: 2000 + cacheBuffer: 200 + } + + Rectangle { + width: root.width; height: 30 + anchors { top: view.bottom; bottom: parent.bottom } + color: "gray" + + Row { + anchors.centerIn: parent + spacing: 20 + + Repeater { + model: itemModel.count + + Rectangle { + width: 5; height: 5 + radius: 3 + color: view.currentIndex == index ? "blue" : "white" + + MouseArea { + width: 20; height: 20 + anchors.centerIn: parent + onClicked: view.currentIndex = index + } + } + } + } + } +} diff --git a/examples/qtquick/mousearea/mousearea-example.qml b/examples/qtquick/mousearea/mousearea-example.qml new file mode 100644 index 0000000000..30e3e62864 --- /dev/null +++ b/examples/qtquick/mousearea/mousearea-example.qml @@ -0,0 +1,176 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: box + width: 400; height: 300 + + Rectangle { + id: redSquare + width: 120; height: 120 + anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10 + color: "red" + + Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + property string buttonID + + acceptedButtons: Qt.AllButtons + // Value 'All.Buttons' is eqivalent to: + // 'Qt::LeftButton | Qt::RightButton | Qt::MiddleButton .... | Qt::ExtraButton24' + + onEntered: info.text = 'Entered' + onExited: info.text = 'Exited (pressed=' + pressed + ')' + + onPressed: { + if (mouse.button == Qt.LeftButton) + buttonID = 'LeftButton' + else if (mouse.button == Qt.RightButton) + buttonID = 'RightButton' + else if (mouse.button == Qt.MidButton) + buttonID = 'MiddleButton' + else if (mouse.button == Qt.BackButton) + buttonID = 'BackButton' + else if (mouse.button == Qt.ForwardButton) + buttonID = 'ForwardButton' + else if (mouse.button == Qt.TaskButton) + buttonID = 'TaskButton' + else if (mouse.button == Qt.ExtraButton4) + buttonID = 'ExtraButton4' + else if (mouse.button == Qt.ExtraButton5) + buttonID = 'ExtraButton5' + else if (mouse.button == Qt.ExtraButton6) + buttonID = 'ExtraButton6' + else if (mouse.button == Qt.ExtraButton7) + buttonID = 'ExtraButton7' + else if (mouse.button == Qt.ExtraButton8) + buttonID = 'ExtraButton8' + else if (mouse.button == Qt.ExtraButton9) + buttonID = 'ExtraButton9' + else if (mouse.button == Qt.ExtraButton10) + buttonID = 'ExtraButton10' + else if (mouse.button == Qt.ExtraButton11) + buttonID = 'ExtraButton11' + else if (mouse.button == Qt.ExtraButton12) + buttonID = 'ExtraButton12' + else if (mouse.button == Qt.ExtraButton13) + buttonID = 'ExtraButton13' + else if (mouse.button == Qt.ExtraButton14) + buttonID = 'ExtraButton14' + else if (mouse.button == Qt.ExtraButton15) + buttonID = 'ExtraButton15' + else if (mouse.button == Qt.ExtraButton16) + buttonID = 'ExtraButton16' + else if (mouse.button == Qt.ExtraButton17) + buttonID = 'ExtraButton17' + else if (mouse.button == Qt.ExtraButton18) + buttonID = 'ExtraButton18' + else if (mouse.button == Qt.ExtraButton19) + buttonID = 'ExtraButton19' + else if (mouse.button == Qt.ExtraButton20) + buttonID = 'ExtraButton20' + else if (mouse.button == Qt.ExtraButton21) + buttonID = 'ExtraButton21' + else if (mouse.button == Qt.ExtraButton22) + buttonID = 'ExtraButton22' + else if (mouse.button == Qt.ExtraButton23) + buttonID = 'ExtraButton23' + else if (mouse.button == Qt.ExtraButton24) + buttonID = 'ExtraButton24' + + info.text = 'Pressed (' + buttonID + ' shift=' + + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')' + var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y) + posInfo.text = + mouse.x + ',' + mouse.y + ' in square' + + ' (' + posInBox.x + ',' + posInBox.y + ' in window)' + } + + onReleased: { + btn.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')' + posInfo.text = '' + } + + onPressAndHold: btn.text = 'Press and hold' + onClicked: btn.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')' + onDoubleClicked: btn.text = 'Double clicked' + } + } + + Rectangle { + id: blueSquare + width: 120; height: 120 + x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors + color: "blue" + + Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + drag.target: blueSquare + drag.axis: Drag.XandYAxis + drag.minimumX: 0 + drag.maximumX: box.width - parent.width + drag.minimumY: 0 + drag.maximumY: box.height - parent.width + } + } + + Text { + id: info + anchors.bottom: btn.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 + + onTextChanged: console.log(text) + } + + Text { + id: btn + anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 + } + + Text { + id: posInfo + anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 20 + } +} diff --git a/examples/qtquick/openglunderqml/main.cpp b/examples/qtquick/openglunderqml/main.cpp new file mode 100644 index 0000000000..3b682deaec --- /dev/null +++ b/examples/qtquick/openglunderqml/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include + +#include "squircle.h" + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("QtQuick", 2, 0, "Squircle"); + + QQuickView view; + view.setSource(QUrl("main.qml")); + view.show(); + + return app.exec(); + +} diff --git a/examples/qtquick/openglunderqml/main.qml b/examples/qtquick/openglunderqml/main.qml new file mode 100644 index 0000000000..1485cbbdb8 --- /dev/null +++ b/examples/qtquick/openglunderqml/main.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + + width: 400 + height: 300 + + Squircle { + SequentialAnimation on t { + NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad } + NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad } + loops: Animation.Infinite + running: true + } + } + + Rectangle { + color: Qt.rgba(1, 1, 1, 0.8); + radius: 10 + border.width: 1 + border.color: "white" + anchors.fill: label + anchors.margins: -10 + } + + Text { + id: label + color: "black" + wrapMode: Text.WordWrap + text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickCanvas. This text label and its border is rendered using QML" + anchors.right: parent.right + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.margins: 20 + } + +} diff --git a/examples/qtquick/openglunderqml/openglunderqml.pro b/examples/qtquick/openglunderqml/openglunderqml.pro new file mode 100644 index 0000000000..117ad0c33e --- /dev/null +++ b/examples/qtquick/openglunderqml/openglunderqml.pro @@ -0,0 +1,6 @@ +QT += declarative quick + +HEADERS += squircle.h +SOURCES += squircle.cpp main.cpp + +OTHER_FILES += main.qml diff --git a/examples/qtquick/openglunderqml/squircle.cpp b/examples/qtquick/openglunderqml/squircle.cpp new file mode 100644 index 0000000000..b56f0baaf6 --- /dev/null +++ b/examples/qtquick/openglunderqml/squircle.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "squircle.h" + +#include +#include +#include + +Squircle::Squircle() + : m_program(0) +{ + setFlag(ItemHasContents); +} + +void Squircle::itemChange(ItemChange change, const ItemChangeData &) +{ + // The ItemSceneChange event is sent when we are first attached to a canvas. + if (change == ItemSceneChange) { + QQuickCanvas *c = canvas(); + + // Connect our the beforeRendering signal to our paint function. + // Since this call is executed on the rendering thread it must be + // a Qt::DirectConnection + connect(c, SIGNAL(beforeRendering()), this, SLOT(paint()), Qt::DirectConnection); + + // If we allow QML to do the clearing, they would clear what we paint + // and nothing would show. + c->setClearBeforeRendering(false); + } +} + + +void Squircle::paint() +{ + if (!m_program) { + m_program = new QOpenGLShaderProgram(); + m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, + "attribute highp vec4 vertices;" + "varying highp vec2 coords;" + "void main() {" + " gl_Position = vertices;" + " coords = vertices.xy;" + "}"); + m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, + "uniform lowp float t;" + "varying highp vec2 coords;" + "void main() {" + " lowp float i = 1. - (pow(coords.x, 4.) + pow(coords.y, 4.));" + " i = smoothstep(t - 0.3, t + 0.3, i);" + " gl_FragColor = vec4(coords / 2. + .5, i, i);" + "}"); + + m_program->bindAttributeLocation("vertices", 0); + m_program->link(); + } + + m_program->bind(); + + m_program->enableAttributeArray(0); + + float values[] = { + -1, -1, + 1, -1, + -1, 1, + 1, 1 + }; + m_program->setAttributeArray(0, GL_FLOAT, values, 2); + m_program->setUniformValue("t", (float) m_t); + + glDisable(GL_DEPTH_TEST); + + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + m_program->disableAttributeArray(0); + m_program->release(); +} + + diff --git a/examples/qtquick/openglunderqml/squircle.h b/examples/qtquick/openglunderqml/squircle.h new file mode 100644 index 0000000000..283131a662 --- /dev/null +++ b/examples/qtquick/openglunderqml/squircle.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SQUIRCLE_H +#define SQUIRCLE_H + +#include +#include + +class Squircle : public QQuickItem +{ + Q_OBJECT + + Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged) + +public: + Squircle(); + + qreal t() const { return m_t; } + void setT(qreal t) { m_t = t; emit tChanged(); } + + void itemChange(ItemChange change, const ItemChangeData &); + +signals: + void tChanged(); + +public slots: + void paint(); + +private: + QOpenGLShaderProgram *m_program; + + qreal m_t; + bool m_render_under; + bool m_render_over; +}; + +#endif // SQUIRCLE_H diff --git a/examples/qtquick/painteditem/painteditem.pro b/examples/qtquick/painteditem/painteditem.pro new file mode 100644 index 0000000000..e3afd6b0f0 --- /dev/null +++ b/examples/qtquick/painteditem/painteditem.pro @@ -0,0 +1,5 @@ +TEMPLATE = subdirs + +SUBDIRS = \ + smile \ + textballoons diff --git a/examples/qtquick/painteditem/smile/main.cpp b/examples/qtquick/painteditem/smile/main.cpp new file mode 100644 index 0000000000..1e6b42351d --- /dev/null +++ b/examples/qtquick/painteditem/smile/main.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +class MyPaintItem : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QString face READ face WRITE setFace NOTIFY faceChanged) +public: + MyPaintItem() + : QQuickPaintedItem() + , m_face(QLatin1String(":-)")) + { + setAntialiasing(true); + } + QString face() const {return m_face;} + void setFace(const QString &face) { + if (m_face != face) { + m_face = face; + emit faceChanged(); + } + } + virtual void paint(QPainter *p) + { + QRectF rect(0, 0, width(), height()); + rect.adjust(10, 10, -10, -10); + p->setPen(QPen(Qt::black, 20)); + p->setBrush(Qt::yellow); + p->drawEllipse(rect); + p->setPen(Qt::black); + p->setFont(QFont(QLatin1String("Times"), qRound(rect.height() / 2))); + p->drawText(rect, Qt::AlignCenter, m_face); + } +signals: + void faceChanged(); +private: + QString m_face; +}; + +int main(int argc, char ** argv) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("MyModule", 1, 0, "MyPaintItem"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("smile.qml")); + view.show(); + view.raise(); + + return app.exec(); +} + +#include "main.moc" diff --git a/examples/qtquick/painteditem/smile/smile.pro b/examples/qtquick/painteditem/smile/smile.pro new file mode 100644 index 0000000000..780d351fe6 --- /dev/null +++ b/examples/qtquick/painteditem/smile/smile.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +TARGET = painteditem + +QT += declarative quick + +macx: CONFIG -= app_bundle + +SOURCES += main.cpp + +CONFIG += console + diff --git a/examples/qtquick/painteditem/smile/smile.qml b/examples/qtquick/painteditem/smile/smile.qml new file mode 100644 index 0000000000..33919bc04f --- /dev/null +++ b/examples/qtquick/painteditem/smile/smile.qml @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import MyModule 1.0 + +Rectangle { + width: 500 + height: 500 + gradient: Gradient { + GradientStop { position: 0.0; color: "#00249a" } + GradientStop { position: 0.7; color: "#ffd94f" } + GradientStop { position: 1.0; color: "#ffa322" } + } + MyPaintItem { + renderTarget:PaintedItem.Image + clip:true + width:240 + height:240 + anchors.left : parent.left + anchors.top :parent.top + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } + MyPaintItem { + clip:true + renderTarget:PaintedItem.Image + width:240 + height:240 + anchors.right : parent.right + anchors.top :parent.top + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } + MyPaintItem { + clip:true + renderTarget:PaintedItem.Image + width:240 + height:240 + anchors.left : parent.left + anchors.bottom :parent.bottom + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } + MyPaintItem { + clip:true + renderTarget:PaintedItem.Image + width:240 + height:240 + anchors.right : parent.right + anchors.bottom :parent.bottom + anchors.margins: 10 + smooth: true + MouseArea { + anchors.fill:parent + onClicked: { + if (parent.face == ":-)") + parent.face = ":-("; + else + parent.face = ":-)"; + parent.update() + } + } + } +} \ No newline at end of file diff --git a/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/plugin.h b/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/plugin.h new file mode 100644 index 0000000000..f444d31f4e --- /dev/null +++ b/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/plugin.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "../textballoon.h" + +class TextBalloonPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "textballoon.json") +public: + void registerTypes(const char *uri) + { + qmlRegisterType(uri, 1, 0, "TextBalloon"); + } +}; diff --git a/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/qmldir b/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/qmldir new file mode 100644 index 0000000000..e8a08ae9d3 --- /dev/null +++ b/examples/qtquick/painteditem/textballoons/TextBalloonPlugin/qmldir @@ -0,0 +1 @@ +plugin qmltextballoonplugin diff --git a/examples/qtquick/painteditem/textballoons/textballoon.cpp b/examples/qtquick/painteditem/textballoons/textballoon.cpp new file mode 100644 index 0000000000..d097adfe1b --- /dev/null +++ b/examples/qtquick/painteditem/textballoons/textballoon.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "textballoon.h" + +//! [0] +TextBalloon::TextBalloon(QQuickItem *parent) + : QQuickPaintedItem(parent) + , rightAligned(false) +{ +} +//! [0] + +//! [1] +void TextBalloon::paint(QPainter *painter) +{ + QBrush brush(QColor("#007430")); + + painter->setBrush(brush); + painter->setPen(Qt::NoPen); + painter->setRenderHint(QPainter::Antialiasing); + + painter->drawRoundedRect(0, 0, boundingRect().width(), boundingRect().height() - 10, 10, 10); + + if (rightAligned) + { + const QPointF points[3] = { + QPointF(boundingRect().width() - 10.0, boundingRect().height() - 10.0), + QPointF(boundingRect().width() - 20.0, boundingRect().height()), + QPointF(boundingRect().width() - 30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } + else + { + const QPointF points[3] = { + QPointF(10.0, boundingRect().height() - 10.0), + QPointF(20.0, boundingRect().height()), + QPointF(30.0, boundingRect().height() - 10.0), + }; + painter->drawConvexPolygon(points, 3); + } +} +//! [1] + +bool TextBalloon::isRightAligned() +{ + return this->rightAligned; +} + +void TextBalloon::setRightAligned(bool rightAligned) +{ + this->rightAligned = rightAligned; +} diff --git a/examples/qtquick/painteditem/textballoons/textballoon.h b/examples/qtquick/painteditem/textballoons/textballoon.h new file mode 100644 index 0000000000..93ed0a7105 --- /dev/null +++ b/examples/qtquick/painteditem/textballoons/textballoon.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TEXTBALLOON_H +#define TEXTBALLOON_H + +#include + +//! [0] +class TextBalloon : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(bool rightAligned READ isRightAligned WRITE setRightAligned NOTIFY rightAlignedChanged) + + public: + TextBalloon(QQuickItem *parent = 0); + void paint(QPainter *painter); + + bool isRightAligned(); + void setRightAligned(bool rightAligned); + + private: + bool rightAligned; + + signals: + void rightAlignedChanged(); +}; +//! [0] + +#endif diff --git a/examples/qtquick/painteditem/textballoons/textballoons.pro b/examples/qtquick/painteditem/textballoons/textballoons.pro new file mode 100644 index 0000000000..e0b9404f65 --- /dev/null +++ b/examples/qtquick/painteditem/textballoons/textballoons.pro @@ -0,0 +1,25 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += declarative quick + +TARGET = qmltextballoonplugin + +HEADERS += TextBalloonPlugin/plugin.h \ + textballoon.h + +SOURCES += textballoon.cpp + +OTHER_FILES += textballoon.json + +DESTDIR = TextBalloonPlugin + +qdeclarativesources.files += \ + TextBalloonPlugin/qmldir + +qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin + +sources.files = textballoons.qml +sources.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons +target.path += $$[QT_INSTALL_EXAMPLES]/qtdeclarative/declarative/painteditem/textballoons/TextBalloonPlugin + +INSTALLS = qdeclarativesources sources target diff --git a/examples/qtquick/painteditem/textballoons/textballoons.qml b/examples/qtquick/painteditem/textballoons/textballoons.qml new file mode 100644 index 0000000000..b00ce2bfed --- /dev/null +++ b/examples/qtquick/painteditem/textballoons/textballoons.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import TextBalloonPlugin 1.0 + +Item { + height: 480 + width: 640 + + //! [0] + ListModel { + id: balloonModel + ListElement { + balloonWidth: 200 + } + ListElement { + balloonWidth: 350 + } + } + + ListView { + anchors.bottom: controls.top + anchors.bottomMargin: 2 + anchors.top: parent.top + id: balloonView + delegate: TextBalloon { + anchors.right: index % 2 == 0 ? undefined : parent.right + height: 60 + rightAligned: index % 2 == 0 ? false : true + width: balloonWidth + } + model: balloonModel + spacing: 5 + width: parent.width + } + //! [0] + + //! [1] + Rectangle { + id: controls + + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.margins: 1 + anchors.right: parent.right + border.width: 2 + color: "white" + height: parent.height * 0.15 + + Text { + anchors.centerIn: parent + text: "Add another balloon" + } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onClicked: { + balloonModel.append({"balloonWidth": Math.floor(Math.random() * 300 + 100)}) + balloonView.positionViewAtIndex(balloonView.count -1, ListView.End) + } + onEntered: { + parent.color = "#8ac953" + } + onExited: { + parent.color = "white" + } + } + } + //! [1] +} diff --git a/examples/qtquick/positioners/content/Button.qml b/examples/qtquick/positioners/content/Button.qml new file mode 100644 index 0000000000..ee3aa9057e --- /dev/null +++ b/examples/qtquick/positioners/content/Button.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + + property string text + property string icon + signal clicked + + border.color: "black"; color: "steelblue"; radius: 5 + width: pix.width + textelement.width + 13 + height: pix.height + 10 + + Image { id: pix; x: 5; y:5; source: parent.icon } + + Text { + id: textelement + text: page.text; color: "white" + x: pix.width + pix.x + 3 + anchors.verticalCenter: pix.verticalCenter + } + + MouseArea { + id: mr + anchors.fill: parent + onClicked: { parent.focus = true; page.clicked() } + } + + states: State { + name: "pressed"; when: mr.pressed + PropertyChanges { target: textelement; x: 5 } + PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 } + } + + transitions: Transition { + NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 } + } +} diff --git a/examples/qtquick/positioners/content/add.png b/examples/qtquick/positioners/content/add.png new file mode 100644 index 0000000000..1ee45423e3 Binary files /dev/null and b/examples/qtquick/positioners/content/add.png differ diff --git a/examples/qtquick/positioners/content/del.png b/examples/qtquick/positioners/content/del.png new file mode 100644 index 0000000000..8d2eaed523 Binary files /dev/null and b/examples/qtquick/positioners/content/del.png differ diff --git a/examples/qtquick/positioners/positioners-attachedproperties.qml b/examples/qtquick/positioners/positioners-attachedproperties.qml new file mode 100644 index 0000000000..a05927f5ea --- /dev/null +++ b/examples/qtquick/positioners/positioners-attachedproperties.qml @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 400 + height: 100 + + // Create row with four rectangles, the fourth one is hidden + Row { + id: row + + Rectangle { + id: red + color: "red" + width: 100 + height: 100 + + // When mouse is clicked, display the values of the positioner + MouseArea { + anchors.fill: parent + onClicked: row.showInfo(red.Positioner) + } + } + + Rectangle { + id: green + color: "green" + width: 100 + height: 100 + + // When mouse is clicked, display the values of the positioner + MouseArea { + anchors.fill: parent + onClicked: row.showInfo(green.Positioner) + } + } + + Rectangle { + id: blue + color: "blue" + width: 100 + height: 100 + + // When mouse is clicked, display the values of the positioner + MouseArea { + anchors.fill: parent + onClicked: row.showInfo(blue.Positioner) + } + } + + // This rectangle is not visible, so it doesn't have a positioner value + Rectangle { + color: "black" + width: 100 + height: 100 + visible: false + } + + // Print the index of the child item in the positioner and convenience + // properties showing if it's the first or last item. + function showInfo(positioner) { + console.log("Item Index = " + positioner.index) + console.log(" isFirstItem = " + positioner.isFirstItem) + console.log(" isLastItem = " + positioner.isLastItem) + } + } +} diff --git a/examples/qtquick/positioners/positioners.qml b/examples/qtquick/positioners/positioners.qml new file mode 100644 index 0000000000..6627ad7dd4 --- /dev/null +++ b/examples/qtquick/positioners/positioners.qml @@ -0,0 +1,268 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: page + width: 320; height: 480 + Flickable { + anchors.fill: parent + contentWidth: 420; contentHeight: 420 + + Column { + id: layout1 + y: 0 + move: Transition { + NumberAnimation { properties: "y"; easing.type: Easing.OutBounce } + } + add: Transition { + NumberAnimation { properties: "y"; easing.type: Easing.OutQuad } + } + + Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueV1 + visible: opacity != 0 + width: 100; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueV2 + visible: opacity != 0 + width: 100; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } + } + + Row { + id: layout2 + y: 300 + move: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.OutBounce } + } + add: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.OutQuad } + } + + Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } + + Rectangle { + id: blueH1 + visible: opacity != 0 + width: 50; height: 100 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } + + Rectangle { + id: blueH2 + visible: opacity != 0 + width: 50; height: 100 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } + } + + Button { + x: 135; y: 90 + text: "Remove" + icon: "del.png" + + onClicked: { + blueH2.opacity = 0 + blueH1.opacity = 0 + blueV1.opacity = 0 + blueV2.opacity = 0 + blueG1.opacity = 0 + blueG2.opacity = 0 + blueG3.opacity = 0 + blueF1.opacity = 0 + blueF2.opacity = 0 + blueF3.opacity = 0 + } + } + + Button { + x: 145; y: 140 + text: "Add" + icon: "add.png" + + onClicked: { + blueH2.opacity = 1 + blueH1.opacity = 1 + blueV1.opacity = 1 + blueV2.opacity = 1 + blueG1.opacity = 1 + blueG2.opacity = 1 + blueG3.opacity = 1 + blueF1.opacity = 1 + blueF2.opacity = 1 + blueF3.opacity = 1 + } + } + + Grid { + x: 260; y: 0 + columns: 3 + + move: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + add: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG1 + visible: opacity != 0 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG2 + visible: opacity != 0 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueG3 + visible: opacity != 0 + width: 50; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + } + + Flow { + id: layout4 + x: 260; y: 250; width: 150 + + move: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + add: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } + } + + Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF1 + visible: opacity != 0 + width: 60; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF2 + visible: opacity != 0 + width: 60; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } + + Rectangle { + id: blueF3 + visible: opacity != 0 + width: 40; height: 50 + color: "lightsteelblue" + border.color: "black" + radius: 15 + Behavior on opacity { NumberAnimation {} } + } + + Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 } + } + + } +} diff --git a/examples/qtquick/qtquick.pro b/examples/qtquick/qtquick.pro new file mode 100644 index 0000000000..2ffc377f32 --- /dev/null +++ b/examples/qtquick/qtquick.pro @@ -0,0 +1,17 @@ +TEMPLATE = subdirs +SUBDIRS = accessibility \ + animation + #canvas \ + #draganddrop \ + #imageelements \ + #keyinteraction \ + #modelviews \ + #mousearea \ + #openglunderqml \ + #painteditem \ + #positioners \ + #righttoleft \ + #shadereffects \ + #text \ + #threading \ + #touchinteraction diff --git a/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qml b/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qml new file mode 100644 index 0000000000..0c65647d5b --- /dev/null +++ b/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qml @@ -0,0 +1,246 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + property bool mirror + property int direction: Qt.application.layoutDirection + LayoutMirroring.enabled: mirror + LayoutMirroring.childrenInherit: true + width: column.width + 80 + height: column.height + 40 + Column { + id: column + width: 190 + spacing: 10 + anchors.centerIn: parent + + Text { + text: "Row" + anchors.horizontalCenter: parent.horizontalCenter + } + + Row { + layoutDirection: root.direction + spacing: 10 + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 4 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "Grid" + anchors.horizontalCenter: parent.horizontalCenter + } + + Grid { + layoutDirection: root.direction + spacing: 10; columns: 4 + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 11 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "Flow" + anchors.horizontalCenter: parent.horizontalCenter + } + + Flow { + layoutDirection: root.direction + spacing: 10; width: parent.width + move: Transition { + NumberAnimation { + properties: "x" + } + } + Repeater { + model: 10 + Loader { + property int value: index + sourceComponent: positionerDelegate + } + } + } + + Text { + text: "ListView" + anchors.horizontalCenter: parent.horizontalCenter + } + + ListView { + id: listView + clip: true + width: parent.width; height: 40 + layoutDirection: root.direction + orientation: Qt.Horizontal + model: 48 + delegate: viewDelegate + } + + Text { + text: "GridView" + anchors.horizontalCenter: parent.horizontalCenter + } + + GridView { + clip: true + width: 200; height: 160 + cellWidth: 50; cellHeight: 50 + layoutDirection: root.direction + model: 48 + delegate: viewDelegate + } + + Rectangle { + height: 50; width: parent.width + color: mouseArea.pressed ? "black" : "gray" + Column { + anchors.centerIn: parent + Text { + text: root.direction ? "Right to left" : "Left to right" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + if (root.direction == Qt.LeftToRight) { + root.direction = Qt.RightToLeft; + } else { + root.direction = Qt.LeftToRight; + } + } + } + } + + Rectangle { + height: 50; width: parent.width + color: mouseArea2.pressed ? "black" : "gray" + Column { + anchors.centerIn: parent + Text { + text: root.mirror ? "Mirrored" : "Not mirrored" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea2 + anchors.fill: parent + onClicked: { + root.mirror = !root.mirror; + } + } + } + } + + Component { + id: positionerDelegate + Rectangle { + width: 40; height: 40 + color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0) + Text { + text: parent.parent.value+1 + color: "white" + font.pixelSize: 18 + anchors.centerIn: parent + } + } + } + Component { + id: viewDelegate + Item { + width: (listView.effectiveLayoutDirection == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50 + Rectangle { + width: 40; height: 40 + color: Qt.rgba(0.5+(48 - index)*Math.random()/48, + 0.3+index*Math.random()/48, + 0.3*Math.random(), + 1.0) + Text { + text: index+1 + color: "white" + font.pixelSize: 18 + anchors.centerIn: parent + } + } + } + } +} + diff --git a/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qmlproject b/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qmlproject new file mode 100644 index 0000000000..33cbb3c9e2 --- /dev/null +++ b/examples/qtquick/righttoleft/layoutdirection/layoutdirection.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "layoutdirection.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qml new file mode 100644 index 0000000000..5c4739bd57 --- /dev/null +++ b/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qml @@ -0,0 +1,313 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft + LayoutMirroring.enabled: mirror + LayoutMirroring.childrenInherit: true + width: 400 + height: 875 + color: "lightsteelblue" + + Column { + spacing: 10 + anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 } + + Text { + text: "Positioners" + anchors.left: parent.left + } + + Column { + id: positioners + spacing: 5 + anchors.left: parent.left + Row { + id: row + spacing: 4 + property string text: "THISISROW" + anchors.left: parent.left + Repeater { + model: parent.text.length + delegate: positionerDelegate + } + } + Flow { + id: flow + spacing: 4 + width: 90 + property string text: "THISISFLOW" + anchors.left: parent.left + Repeater { + model: parent.text.length + delegate: positionerDelegate + } + } + Grid { + id: grid + spacing: 4 + columns: 6 + property string text: "THISISGRID" + anchors.left: parent.left + Repeater { + model: parent.text.length + delegate: positionerDelegate + } + } + Component { + id: positionerDelegate + Text { + color: "white" + font.pixelSize: 20 + text: parent.text[index] + Rectangle { + z: -1 + opacity: 0.7 + color: "black" + anchors.fill: parent + } + } + } + } + + Text { + text: "Text alignment" + anchors.left: parent.left + } + + Rectangle { + id: textStrings + width: 148 + height: 85 + color: "white" + anchors.left: parent.left + Column { + spacing: 5 + width: parent.width + anchors { fill: parent; margins: 5 } + Text { + id: englishText + width: parent.width + text: "English text" + } + Text { + id: arabicText + width: parent.width + text: "النص العربي" + } + Text { + id: leftAlignedText + width: parent.width + text: "Text aligned to left" + horizontalAlignment: Text.AlignLeft + } + Text { + id: rightAlignedText + width: parent.width + text: "Text aligned to right" + horizontalAlignment: Text.AlignRight + } + } + } + + Text { + text: "Model views" + anchors.left: parent.left + } + + Column { + id: views + spacing: 10 + anchors.left: parent.left + ListView { + id: listView + z: -1 + clip: true + model: text.length + width: 360; height: 45 + orientation: Qt.Horizontal + property string text: "LISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEW" + delegate: Rectangle { + color: "black" + width: 45; height: 45 + Rectangle { + anchors { fill: parent; margins: 1 } + color: "red" + } + Text { + text: listView.text[index] + font.pixelSize: 30 + anchors.centerIn: parent + } + } + } + GridView { + id: gridView + z: -1 + clip: true + model: text.length + width: 180; height: 90 + cellWidth: 45; cellHeight: 45 + property string text: "GRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEW" + anchors.left: parent.left + delegate: Rectangle { + color: "black" + width: 45; height: 45 + Rectangle { + anchors { fill: parent; margins: 1 } + color: "red" + } + Text { + anchors.centerIn: parent + font.pixelSize: 30 + text: gridView.text[index] + } + } + } + } + + Text { + text: "Item x" + anchors.left: parent.left + } + Rectangle { + id: items + color: Qt.rgba(0.2, 0.2, 0.2, 0.6) + width: 275; height: 95 + anchors.left: parent.left + Rectangle { + y: 5; x: 5 + width: 130; height: 40 + Text { + text: "Item with x: 5\n(not mirrored)" + anchors.centerIn: parent + } + } + Rectangle { + color: Qt.rgba(0.7, 0.7, 0.7) + y: 50; x: mirror(5) + width: 130; height: 40 + function mirror(value) { + return LayoutMirroring.enabled ? (parent.width - width - value) : value; + } + Text { + text: "Item with x: " + parent.x + "\n(manually mirrored)" + anchors.centerIn: parent + } + } + } + Text { + text: "Item anchors" + anchors.left: parent.left + } + + Rectangle { + id: anchoredItems + color: Qt.rgba(0.2, 0.2, 0.2, 0.6) + width: 270; height: 170 + anchors.left: parent.left + Rectangle { + id: blackRectangle + color: "black" + width: 180; height: 90 + anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 } + Text { + text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent." + color: "white" + anchors.centerIn: parent + } + } + Rectangle { + id: whiteRectangle + color: "white" + width: 120; height: 70 + anchors { left: parent.left; bottom: parent.bottom } + Text { + text: "Left side anchored\nto the left side\nof the parent." + color: "black" + anchors.centerIn: parent + } + } + Rectangle { + id: grayRectangle + color: Qt.rgba(0.7, 0.7, 0.7) + width: 140; height: 90 + anchors { right: parent.right; bottom: parent.bottom } + Text { + text: "Right side anchored\nto the right side\nof the parent." + anchors.centerIn: parent + } + } + } + Rectangle { + id: mirrorButton + color: mouseArea2.pressed ? "black" : "gray" + height: 50; width: parent.width + anchors.left: parent.left + Column { + anchors.centerIn: parent + Text { + text: root.mirror ? "Mirrored" : "Not mirrored" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea2 + anchors.fill: parent + onClicked: { + root.mirror = !root.mirror; + } + } + } + } +} + diff --git a/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qmlproject new file mode 100644 index 0000000000..72bc04a8a9 --- /dev/null +++ b/examples/qtquick/righttoleft/layoutmirroring/layoutmirroring.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "layoutmirroring.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/righttoleft/textalignment/textalignment.qml b/examples/qtquick/righttoleft/textalignment/textalignment.qml new file mode 100644 index 0000000000..ef5b97bb1a --- /dev/null +++ b/examples/qtquick/righttoleft/textalignment/textalignment.qml @@ -0,0 +1,427 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + color: "white" + width: containerColumn.width + height: containerColumn.height + containerColumn.anchors.topMargin + + property bool mirror: false + property variant horizontalAlignment: undefined + + property variant editorType: ["Plain Text", "Styled Text", "Plain Rich Text", "Italic Rich Text", "Plain TextEdit", "Italic TextEdit", "TextInput"] + property variant text: ["", " ", "Hello world!", "مرحبا العالم!", "Hello world! Hello!\nHello world! Hello!", "مرحبا العالم! مرحبا! مرحبا العالم! مرحبا!" ,"مرحبا العالم! مرحبا! مرحبا Hello world!\nالعالم! مرحبا!"] + property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text", "multi-line left-to-right text", "multi-line right-to-left text", "multi-line bidi text"] + property variant textComponents: [plainTextComponent, styledTextComponent, richTextComponent, italicRichTextComponent, plainTextEdit, italicTextEdit, textInput] + + function shortText(horizontalAlignment) { + + // all the different QML editors have + // the same alignment values + switch (horizontalAlignment) { + case Text.AlignLeft: + return "L"; + case Text.AlignRight: + return "R"; + case Text.AlignHCenter: + return "C"; + case Text.AlignJustify: + return "J"; + default: + return "Error"; + } + } + Column { + id: containerColumn + spacing: 10 + width: editorTypeRow.width + anchors { top: parent.top; topMargin: 5 } + Row { + id: editorTypeRow + Repeater { + model: editorType.length + Item { + width: editorColumn.width + height: editorColumn.height + Column { + id: editorColumn + spacing: 5 + width: textColumn.width+10 + Text { + text: root.editorType[index] + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Column { + id: textColumn + spacing: 5 + anchors.horizontalCenter: parent.horizontalCenter + Repeater { + model: textComponents.length + delegate: textComponents[index] + } + } + } + } + } + } + Column { + spacing: 2 + width: parent.width + Rectangle { + // button + height: 50; width: parent.width + color: mouseArea.pressed ? "black" : "lightgray" + Column { + anchors.centerIn: parent + Text { + text: root.mirror ? "Mirrored" : "Not mirrored" + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea + property int index: 0 + anchors.fill: parent + onClicked: root.mirror = !root.mirror + } + } + Rectangle { + // button + height: 50; width: parent.width + color: mouseArea2.pressed ? "black" : "gray" + Column { + anchors.centerIn: parent + Text { + text: { + if (root.horizontalAlignment == undefined) + return "Implict alignment"; + switch (root.horizontalAlignment) { + case Text.AlignLeft: + return "Left alignment"; + case Text.AlignRight: + return "Right alignment"; + case Text.AlignHCenter: + return "Center alignment"; + case Text.AlignJustify: + return "Justify alignment"; + } + } + color: "white" + font.pixelSize: 16 + anchors.horizontalCenter: parent.horizontalCenter + } + Text { + text: "(click here to toggle)" + color: "white" + font.pixelSize: 10 + font.italic: true + anchors.horizontalCenter: parent.horizontalCenter + } + } + MouseArea { + id: mouseArea2 + property int index: 0 + anchors.fill: parent + onClicked: { + if (index < 0) { + root.horizontalAlignment = undefined; + } else { + root.horizontalAlignment = Math.pow(2, index); + } + index = (index + 2) % 5 - 1; + } + } + } + } + } + + Component { + id: plainTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: styledTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + style: Text.Sunken + styleColor: "white" + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: richTextComponent + Text { + width: 180 + text: root.text[index] + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + Rectangle { + z: -1 + color: Qt.rgba(0.8, 0.2, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: italicRichTextComponent + Text { + width: 180 + text: "" + root.text[index] + "" + font.pixelSize: 24 + wrapMode: Text.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + textFormat: Text.RichText + property variant backgroundColor: Qt.rgba(0.8, 0.2, 0.2, 0.3) + Rectangle { + z: -1 + color: parent.backgroundColor + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: plainTextEdit + TextEdit { + width: 180 + text: root.text[index] + font.pixelSize: 24 + cursorVisible: true + wrapMode: TextEdit.WordWrap + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.5, 0.5, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: italicTextEdit + TextEdit { + width: 180 + text: "" + root.text[index] + "" + font.pixelSize: 24 + cursorVisible: true + wrapMode: TextEdit.WordWrap + textFormat: TextEdit.RichText + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.5, 0.5, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + + Component { + id: textInput + Item { + width: 180 + height: textInput.text.length > 20 ? 3*textInput.height : textInput.height + TextInput { + id: textInput + width: 180 + text: root.text[index] + font.pixelSize: 24 + cursorVisible: true + horizontalAlignment: root.horizontalAlignment + LayoutMirroring.enabled: root.mirror + Rectangle { + z: -1 + color: Qt.rgba(0.6, 0.4, 0.2, 0.3) + anchors.fill: parent + } + Text { + text: root.description[index] + color: Qt.rgba(1,1,1,1.0) + anchors.centerIn: parent + Rectangle { + z: -1 + color: Qt.rgba(0.3, 0, 0, 0.3) + anchors { fill: parent; margins: -3 } + } + } + Text { + color: "white" + text: shortText(parent.horizontalAlignment) + anchors { top: parent.top; right: parent.right; margins: 2 } + } + } + } + } +} + diff --git a/examples/qtquick/righttoleft/textalignment/textalignment.qmlproject b/examples/qtquick/righttoleft/textalignment/textalignment.qmlproject new file mode 100644 index 0000000000..e4b5061364 --- /dev/null +++ b/examples/qtquick/righttoleft/textalignment/textalignment.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "textalignment.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/shadereffects/content/Slider.qml b/examples/qtquick/shadereffects/content/Slider.qml new file mode 100644 index 0000000000..4ddc6d3432 --- /dev/null +++ b/examples/qtquick/shadereffects/content/Slider.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + property real value: bar.x / (foo.width - bar.width) + Item { + id: foo + width: parent.width - 4 + height: 6 + anchors.centerIn: parent + + Rectangle { + height: parent.height + anchors.left: parent.left + anchors.right: bar.horizontalCenter + color: "blue" + radius: 3 + } + Rectangle { + height: parent.height + anchors.left: bar.horizontalCenter + anchors.right: parent.right + color: "gray" + radius: 3 + } + Rectangle { + anchors.fill: parent + color: "transparent" + radius: 3 + border.width: 2 + border.color: "black" + } + + Rectangle { + id: bar + y: -7 + width: 20 + height: 20 + radius: 15 + color: "white" + border.width: 2 + border.color: "black" + MouseArea { + anchors.fill: parent + drag.target: parent + drag.axis: Drag.XAxis + drag.minimumX: 0 + drag.maximumX: foo.width - parent.width + } + } + } +} + diff --git a/examples/qtquick/shadereffects/content/face-smile.png b/examples/qtquick/shadereffects/content/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qtquick/shadereffects/content/face-smile.png differ diff --git a/examples/qtquick/shadereffects/content/qt-logo.png b/examples/qtquick/shadereffects/content/qt-logo.png new file mode 100644 index 0000000000..7d3e97eb36 Binary files /dev/null and b/examples/qtquick/shadereffects/content/qt-logo.png differ diff --git a/examples/qtquick/shadereffects/shadereffects.qml b/examples/qtquick/shadereffects/shadereffects.qml new file mode 100644 index 0000000000..70bcf1352a --- /dev/null +++ b/examples/qtquick/shadereffects/shadereffects.qml @@ -0,0 +1,315 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Image { + width: 320 + height: 480 +/*! + \title QML Examples - Shader Effects + \example declarative/shadereffects + \image qml-shadereffects-example.png + \brief This is a shader effects example + + This example demonstrates a couple of visual effects that you can perform + with shaders in QtQuick 2.0 +*/ + source: "../snake/content/pics/background.png" + + Flickable { + anchors.fill: parent + contentWidth: 640 + contentHeight: 360 + + ShaderEffectSource { + id: theSource + sourceItem: theItem + smooth: true + } + + function saturate(x) { + return Math.min(Math.max(x, 0), 1) + } + + function sliderToColor(x) { + return Qt.rgba(saturate(Math.max(2 - 6 * x, 6 * x - 4)), + saturate(Math.min(6 * x, 4 - 6 * x)), + saturate(Math.min(6 * x - 2, 6 - 6 * x))) + } + + Grid { + anchors.centerIn: parent + columns: 3 + + Item { + id: theItem + width: 180 + height: 180 + ListView { + anchors.centerIn: parent + width: 160 + height: 140 + clip: true + snapMode: ListView.SnapOneItem + model: VisualItemModel { + Text { + width: 160 + height: 140 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: 120 + font.family: "Times" + color: "blue" + text: "Qt" + } + Image { + width: 160 + height: 140 + source: "content/qt-logo.png" + smooth: true + } + Image { + width: 160 + height: 140 + source: "content/face-smile.png" + smooth: true + } + } + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property real amplitude: 0.04 * wobbleSlider.value + property real frequency: 20 + property real time: 0 + NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 } + fragmentShader: + "uniform lowp float qt_Opacity;" + + "uniform highp float amplitude;" + + "uniform highp float frequency;" + + "uniform highp float time;" + + "uniform sampler2D source;" + + "varying highp vec2 qt_TexCoord0;" + + "void main() {" + + " highp vec2 p = sin(time + frequency * qt_TexCoord0);" + + " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" + + "}" + Slider { + id: wobbleSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property variant shadow: ShaderEffectSource { + smooth: true + sourceItem: ShaderEffect { + width: theItem.width + height: theItem.height + property variant delta: Qt.size(0.0, 1.0 / height) + property variant source: ShaderEffectSource { + smooth: true + sourceItem: ShaderEffect { + width: theItem.width + height: theItem.height + property variant delta: Qt.size(1.0 / width, 0.0) + property variant source: theSource + fragmentShader: " + uniform lowp float qt_Opacity; + uniform sampler2D source; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) + + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) + + 0.2466 * texture2D(source, qt_TexCoord0) + + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) + + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; + }" + } + } + fragmentShader: " + uniform lowp float qt_Opacity; + uniform sampler2D source; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) + + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) + + 0.2466 * texture2D(source, qt_TexCoord0) + + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) + + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; + }" + } + } + property real angle: 0 + property variant offset: Qt.point(15.0 * Math.cos(angle), 15.0 * Math.sin(angle)) + NumberAnimation on angle { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 6000 } + property variant delta: Qt.size(offset.x / width, offset.y / height) + property real darkness: shadowSlider.value + fragmentShader: " + uniform lowp float qt_Opacity; + uniform highp vec2 offset; + uniform sampler2D source; + uniform sampler2D shadow; + uniform highp float darkness; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 fg = texture2D(source, qt_TexCoord0); + lowp vec4 bg = texture2D(shadow, qt_TexCoord0 + delta); + gl_FragColor = (fg + vec4(0., 0., 0., darkness * bg.a) * (1. - fg.a)) * qt_Opacity; + }" + Slider { + id: shadowSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property variant delta: Qt.size(0.5 / width, 0.5 / height) + fragmentShader: " + uniform sampler2D source; + uniform highp vec2 delta; + uniform highp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 tl = texture2D(source, qt_TexCoord0 - delta); + lowp vec4 tr = texture2D(source, qt_TexCoord0 + vec2(delta.x, -delta.y)); + lowp vec4 bl = texture2D(source, qt_TexCoord0 - vec2(delta.x, -delta.y)); + lowp vec4 br = texture2D(source, qt_TexCoord0 + delta); + lowp vec4 gx = (tl + bl) - (tr + br); + lowp vec4 gy = (tl + tr) - (bl + br); + gl_FragColor.xyz = vec3(0.); + gl_FragColor.w = clamp(dot(sqrt(gx * gx + gy * gy), vec4(1.)), 0., 1.) * qt_Opacity; + }" + } + ShaderEffect { + width: 180 + height: 180 + property variant source: theSource + property color tint: sliderToColor(colorizeSlider.value) + fragmentShader: " + uniform sampler2D source; + uniform lowp vec4 tint; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + lowp vec4 c = texture2D(source, qt_TexCoord0); + lowp float lo = min(min(c.x, c.y), c.z); + lowp float hi = max(max(c.x, c.y), c.z); + gl_FragColor = qt_Opacity * vec4(mix(vec3(lo), vec3(hi), tint.xyz), c.w); + }" + Slider { + id: colorizeSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + ShaderEffect { + width: 180 + height: 180 + mesh: Qt.size(10, 10) + property variant source: theSource + property real bend: 0 + property real minimize: 0 + property real side: genieSlider.value + SequentialAnimation on bend { + loops: Animation.Infinite + NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1600 } + NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1000 } + } + SequentialAnimation on minimize { + loops: Animation.Infinite + PauseAnimation { duration: 300 } + NumberAnimation { to: 1; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1000 } + NumberAnimation { to: 0; duration: 700; easing.type: Easing.InOutSine } + PauseAnimation { duration: 1300 } + } + vertexShader: " + uniform highp mat4 qt_Matrix; + uniform highp float bend; + uniform highp float minimize; + uniform highp float side; + uniform highp float width; + uniform highp float height; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main() { + qt_TexCoord0 = qt_MultiTexCoord0; + highp vec4 pos = qt_Vertex; + pos.y = mix(qt_Vertex.y, height, minimize); + highp float t = pos.y / height; + t = (3. - 2. * t) * t * t; + pos.x = mix(qt_Vertex.x, side * width, t * bend); + gl_Position = qt_Matrix * pos; + }" + Slider { + id: genieSlider + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 40 + } + } + } + } +} diff --git a/examples/qtquick/text/fonts/availableFonts.qml b/examples/qtquick/text/fonts/availableFonts.qml new file mode 100644 index 0000000000..0b87259556 --- /dev/null +++ b/examples/qtquick/text/fonts/availableFonts.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 480; height: 640; color: "steelblue" + + ListView { + anchors.fill: parent; model: Qt.fontFamilies() + + delegate: Item { + height: 40; width: ListView.view.width + Text { + anchors.centerIn: parent + text: modelData; font.family: modelData; font.pixelSize: 24; color: "white" + } + } + } +} diff --git a/examples/qtquick/text/fonts/banner.qml b/examples/qtquick/text/fonts/banner.qml new file mode 100644 index 0000000000..6c9aa25fa1 --- /dev/null +++ b/examples/qtquick/text/fonts/banner.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: screen + + property int pixelSize: screen.height * 1.25 + property color textColor: "lightsteelblue" + property string text: "Hello world! " + + width: 640; height: 320 + color: "steelblue" + + Row { + y: -screen.height / 4.5 + + NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite } + Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } + } +} diff --git a/examples/qtquick/text/fonts/content/fonts/tarzeau_ocr_a.ttf b/examples/qtquick/text/fonts/content/fonts/tarzeau_ocr_a.ttf new file mode 100644 index 0000000000..cf93f9651f Binary files /dev/null and b/examples/qtquick/text/fonts/content/fonts/tarzeau_ocr_a.ttf differ diff --git a/examples/qtquick/text/fonts/fonts.qml b/examples/qtquick/text/fonts/fonts.qml new file mode 100644 index 0000000000..78cef25eae --- /dev/null +++ b/examples/qtquick/text/fonts/fonts.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + property string myText: "The quick brown fox jumps over the lazy dog." + + width: 800; height: 480 + color: "steelblue" + + FontLoader { id: fixedFont; name: "Courier" } + FontLoader { id: localFont; source: "content/fonts/tarzeau_ocr_a.ttf" } + FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } + + Column { + anchors { fill: parent; leftMargin: 10; rightMargin: 10 } + spacing: 15 + + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideRight + font.family: "Times"; font.pointSize: 42 + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideLeft + font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideMiddle + font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideRight + font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps } + } + Text { + text: myText + color: "lightsteelblue" + width: parent.width + elide: Text.ElideLeft + font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize } + } + Text { + text: { + if (webFont.status == FontLoader.Ready) myText + else if (webFont.status == FontLoader.Loading) "Loading..." + else if (webFont.status == FontLoader.Error) "Error loading font" + } + color: "lightsteelblue" + width: parent.width + elide: Text.ElideMiddle + font.family: webFont.name; font.pointSize: 42 + } + } +} diff --git a/examples/qtquick/text/fonts/hello.qml b/examples/qtquick/text/fonts/hello.qml new file mode 100644 index 0000000000..d9479fb208 --- /dev/null +++ b/examples/qtquick/text/fonts/hello.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: screen + + width: 800; height: 480 + color: "black" + + Item { + id: container + x: screen.width / 2; y: screen.height / 2 + + Text { + id: text + anchors.centerIn: parent + color: "white" + text: "Hello world!" + font.pixelSize: 60 + smooth: true + + SequentialAnimation on font.letterSpacing { + loops: Animation.Infinite; + NumberAnimation { from: 0; to: 150; easing.type: Easing.InQuad; duration: 3000 } + ScriptAction { + script: { + container.y = (screen.height / 4) + (Math.random() * screen.height / 2) + container.x = (screen.width / 4) + (Math.random() * screen.width / 2) + } + } + } + + SequentialAnimation on opacity { + loops: Animation.Infinite; + NumberAnimation { from: 1; to: 0; duration: 2600 } + PauseAnimation { duration: 400 } + } + } + } +} diff --git a/examples/qtquick/text/imgtag/TextWithImage.qml b/examples/qtquick/text/imgtag/TextWithImage.qml new file mode 100644 index 0000000000..bc09aa2a52 --- /dev/null +++ b/examples/qtquick/text/imgtag/TextWithImage.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Text { + width: parent.width + font.pointSize: 14 + wrapMode: Text.WordWrap + textFormat: Text.StyledText + horizontalAlignment: main.hAlign + + Rectangle { + border.color: "#efefef" + color: "transparent" + anchors.fill: parent + } +} diff --git a/examples/qtquick/text/imgtag/images/face-sad.png b/examples/qtquick/text/imgtag/images/face-sad.png new file mode 100644 index 0000000000..24188b7985 Binary files /dev/null and b/examples/qtquick/text/imgtag/images/face-sad.png differ diff --git a/examples/qtquick/text/imgtag/images/face-smile-big.png b/examples/qtquick/text/imgtag/images/face-smile-big.png new file mode 100644 index 0000000000..d05e0bf21e Binary files /dev/null and b/examples/qtquick/text/imgtag/images/face-smile-big.png differ diff --git a/examples/qtquick/text/imgtag/images/face-smile.png b/examples/qtquick/text/imgtag/images/face-smile.png new file mode 100644 index 0000000000..e5e1d1353c Binary files /dev/null and b/examples/qtquick/text/imgtag/images/face-smile.png differ diff --git a/examples/qtquick/text/imgtag/images/heart200.png b/examples/qtquick/text/imgtag/images/heart200.png new file mode 100644 index 0000000000..cedd3ea608 Binary files /dev/null and b/examples/qtquick/text/imgtag/images/heart200.png differ diff --git a/examples/qtquick/text/imgtag/images/qtlogo.png b/examples/qtquick/text/imgtag/images/qtlogo.png new file mode 100644 index 0000000000..996719a4c6 Binary files /dev/null and b/examples/qtquick/text/imgtag/images/qtlogo.png differ diff --git a/examples/qtquick/text/imgtag/images/starfish_2.png b/examples/qtquick/text/imgtag/images/starfish_2.png new file mode 100644 index 0000000000..132c20ffd0 Binary files /dev/null and b/examples/qtquick/text/imgtag/images/starfish_2.png differ diff --git a/examples/qtquick/text/imgtag/imgtag.qml b/examples/qtquick/text/imgtag/imgtag.qml new file mode 100644 index 0000000000..9d181af2cb --- /dev/null +++ b/examples/qtquick/text/imgtag/imgtag.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: main + width: 320; height: 480 + focus: true + + property var hAlign: Text.AlignLeft + + Flickable { + anchors.fill: parent + contentWidth: parent.width + contentHeight: col.height + 20 + + Column { + id: col + x: 10; y: 10 + spacing: 20 + width: parent.width - 20 + + TextWithImage { + text: "This is a happy face" + } + TextWithImage { + text: "This is a veryhappy face aligned in the middle." + } + TextWithImage { + elide: Text.ElideRight + maximumLineCount: 2 + text: "This is a sad face aligned to the top. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatisLorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc rutrum dui pretium ipsum malesuada venenatis. Nulla sed turpis risus. Integer sit amet odio quis mauris varius venenatis." + } + TextWithImage { + text: "This is a tinyhappy face." + } + TextWithImage { + text: "This is a starfishaligned to the top and another onealigned to the bottom." + } + TextWithImage { + text: "Qt logosaligned in the middle with different sizes." + } + TextWithImage { + text: "Some hearts with different sizes." + } + TextWithImage { + text: "Resized imagefrom the internet." + } + TextWithImage { + text: "Imagefrom the internet." + } + TextWithImage { + height: 120 + verticalAlignment: Text.AlignVCenter + text: "This is a happy face with an explicit height." + } + } + } + + Keys.onUpPressed: main.hAlign = Text.AlignHCenter + Keys.onLeftPressed: main.hAlign = Text.AlignLeft + Keys.onRightPressed: main.hAlign = Text.AlignRight +} diff --git a/examples/qtquick/text/styledtext-layout.qml b/examples/qtquick/text/styledtext-layout.qml new file mode 100644 index 0000000000..4571330568 --- /dev/null +++ b/examples/qtquick/text/styledtext-layout.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: main + width: 320; height: 480 + focus: true + + property real offset: 0 + property real margin: 10 + + Keys.onLeftPressed: myText.horizontalAlignment = Text.AlignLeft + Keys.onUpPressed: myText.horizontalAlignment = Text.AlignHCenter + Keys.onRightPressed: myText.horizontalAlignment = Text.AlignRight + Keys.onDownPressed: myText.horizontalAlignment = Text.AlignJustify + + Text { + id: myText + anchors.fill: parent + anchors.margins: 10 + wrapMode: Text.WordWrap + font.family: "Times New Roman" + font.pixelSize: 13 + textFormat: Text.StyledText + horizontalAlignment: Text.AlignJustify + + text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at ante dui sed eu egestas est facilis www.nokia.com.
          Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Phasellus id neque id velit facilisis cursus ac sit amet nibh. Donec enim arcu, pharetra non semper nec, iaculis eget elit. Nunc blandit condimentum odio vel egestas.
          • Coffee
            1. Espresso
            2. Cappuccino
            3. Flat White
            4. Latte
          • Juice
            1. Orange
            2. Apple
            3. Pineapple
            4. Tomato

          Proin consectetur sapien in ipsum lacinia sit amet mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis, sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Aenean ultricies lectus ut orci dictum quis convallis nisi ultrices. Nunc elit mi, iaculis a porttitor rutrum, venenatis malesuada nisi. Suspendisse turpis quam, euismod non imperdiet et, rutrum nec ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit." + + onLineLaidOut: { + line.width = width / 2 - (2 * margin) + if (line.number === 30) { + main.offset = line.y + } + if (line.number >= 30) { + line.x = width / 2 + margin + line.y -= main.offset + } + if ((line.y + line.height) > rect.y && line.y < (rect.y + rect.height)) { + if (line.number < 30) + line.width = Math.min((rect.x - line.x), line.width) + else { + line.x = Math.max((rect.x + rect.width), width / 2 + margin) + line.width = Math.min((width - margin - line.x), line.width) + } + } + } + + Item { + id: rect + x: 28; y: 20 + width: 60; height: 60 + + Rectangle { + anchors { fill: parent; leftMargin: 2; rightMargin: 2 } + color: "lightsteelblue"; opacity: 0.3 + } + + MouseArea { + anchors.fill: parent + drag.target: rect + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: mouse.button == Qt.RightButton ? myText.font.pixelSize -= 1 : myText.font.pixelSize += 1 + onPositionChanged: myText.doLayout() + } + } + } + +} diff --git a/examples/qtquick/text/text.qml b/examples/qtquick/text/text.qml new file mode 100644 index 0000000000..9bfd290059 --- /dev/null +++ b/examples/qtquick/text/text.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../../shared" + +Item { + height: 480 + width: 480 + LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("Hello", "An Animated Hello World", Qt.resolvedUrl("fonts/hello.qml")); + addExample("Fonts", "Using various fonts with a Text element", Qt.resolvedUrl("fonts/fonts.qml")); + addExample("Available Fonts", "A list of your available fonts", Qt.resolvedUrl("fonts/availableFonts.qml")); + addExample("Banner", "Large, scrolling text", Qt.resolvedUrl("fonts/banner.qml")); + } + } +} diff --git a/examples/qtquick/text/text.qmlproject b/examples/qtquick/text/text.qmlproject new file mode 100644 index 0000000000..c08d9b9a89 --- /dev/null +++ b/examples/qtquick/text/text.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "text.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/text/textselection/pics/endHandle.png b/examples/qtquick/text/textselection/pics/endHandle.png new file mode 100644 index 0000000000..1a4bc5d7a0 Binary files /dev/null and b/examples/qtquick/text/textselection/pics/endHandle.png differ diff --git a/examples/qtquick/text/textselection/pics/endHandle.sci b/examples/qtquick/text/textselection/pics/endHandle.sci new file mode 100644 index 0000000000..4f51f24278 --- /dev/null +++ b/examples/qtquick/text/textselection/pics/endHandle.sci @@ -0,0 +1,5 @@ +border.left: 0 +border.top: 6 +border.bottom: 6 +border.right: 6 +source: endHandle.png diff --git a/examples/qtquick/text/textselection/pics/startHandle.png b/examples/qtquick/text/textselection/pics/startHandle.png new file mode 100644 index 0000000000..deedcd5c91 Binary files /dev/null and b/examples/qtquick/text/textselection/pics/startHandle.png differ diff --git a/examples/qtquick/text/textselection/pics/startHandle.sci b/examples/qtquick/text/textselection/pics/startHandle.sci new file mode 100644 index 0000000000..f9eae204c1 --- /dev/null +++ b/examples/qtquick/text/textselection/pics/startHandle.sci @@ -0,0 +1,5 @@ +border.left: 6 +border.top: 6 +border.bottom: 6 +border.right: 0 +source: startHandle.png diff --git a/examples/qtquick/text/textselection/textselection.qml b/examples/qtquick/text/textselection/textselection.qml new file mode 100644 index 0000000000..7938ce5bf7 --- /dev/null +++ b/examples/qtquick/text/textselection/textselection.qml @@ -0,0 +1,211 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Rectangle { + id: editor + color: "lightGrey" + width: 640; height: 480 + + Rectangle { + color: "white" + anchors.fill: parent + anchors.margins: 20 + + BorderImage { + id: startHandle + source: "pics/startHandle.sci" + opacity: 0.0 + width: 10 + x: edit.positionToRectangle(edit.selectionStart).x - flick.contentX-width + y: edit.positionToRectangle(edit.selectionStart).y - flick.contentY + height: edit.positionToRectangle(edit.selectionStart).height + } + + BorderImage { + id: endHandle + source: "pics/endHandle.sci" + opacity: 0.0 + width: 10 + x: edit.positionToRectangle(edit.selectionEnd).x - flick.contentX + y: edit.positionToRectangle(edit.selectionEnd).y - flick.contentY + height: edit.positionToRectangle(edit.selectionEnd).height + } + + Flickable { + id: flick + + anchors.fill: parent + contentWidth: edit.paintedWidth + contentHeight: edit.paintedHeight + interactive: true + clip: true + + function ensureVisible(r) { + if (contentX >= r.x) + contentX = r.x; + else if (contentX+width <= r.x+r.width) + contentX = r.x+r.width-width; + if (contentY >= r.y) + contentY = r.y; + else if (contentY+height <= r.y+r.height) + contentY = r.y+r.height-height; + } + + TextEdit { + id: edit + width: flick.width + height: flick.height + focus: true + wrapMode: TextEdit.Wrap + textFormat: TextEdit.RichText + + onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) + + text: "

          Text Selection

          " + +"

          This example is a whacky text selection mechanisms, showing how these can be implemented in the TextEdit element, to cater for whatever style is appropriate for the target platform." + +"

          Press-and-hold to select a word, then drag the selection handles." + +"

          Drag outside the selection to scroll the text." + +"

          Click inside the selection to cut/copy/paste/cancel selection." + +"

          It's too whacky to let you paste if there is no current selection." + + } + } + + Item { + id: menu + opacity: 0.0 + width: 100 + height: 120 + anchors.centerIn: parent + + Rectangle { + border.width: 1 + border.color: "darkBlue" + radius: 15 + color: "#806080FF" + anchors.fill: parent + } + + Column { + anchors.centerIn: parent + spacing: 8 + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Cut" } + + MouseArea { + anchors.fill: parent + onClicked: { edit.cut(); editor.state = "" } + } + } + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Copy" } + + MouseArea { + anchors.fill: parent + onClicked: { edit.copy(); editor.state = "selection" } + } + } + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Paste" } + + MouseArea { + anchors.fill: parent + onClicked: { edit.paste(); edit.cursorPosition = edit.selectionEnd; editor.state = "" } + } + } + + Rectangle { + border.width: 1 + border.color: "darkBlue" + color: "#ff7090FF" + width: 60 + height: 16 + + Text { anchors.centerIn: parent; text: "Deselect" } + + MouseArea { + anchors.fill: parent + onClicked: { + edit.cursorPosition = edit.selectionEnd; + edit.deselect(); + editor.state = "" + } + } + } + } + } + } + + states: [ + State { + name: "selection" + PropertyChanges { target: startHandle; opacity: 1.0 } + PropertyChanges { target: endHandle; opacity: 1.0 } + }, + State { + name: "menu" + PropertyChanges { target: startHandle; opacity: 0.5 } + PropertyChanges { target: endHandle; opacity: 0.5 } + PropertyChanges { target: menu; opacity: 1.0 } + } + ] +} diff --git a/examples/qtquick/threading/threadedlistmodel/dataloader.js b/examples/qtquick/threading/threadedlistmodel/dataloader.js new file mode 100644 index 0000000000..4d2aab323d --- /dev/null +++ b/examples/qtquick/threading/threadedlistmodel/dataloader.js @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ![0] +WorkerScript.onMessage = function(msg) { + if (msg.action == 'appendCurrentTime') { + var data = {'time': new Date().toTimeString()}; + msg.model.append(data); + msg.model.sync(); // updates the changes to the list + } +} +// ![0] diff --git a/examples/qtquick/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/qtquick/threading/threadedlistmodel/threadedlistmodel.qmlproject new file mode 100644 index 0000000000..e7c8e69f14 --- /dev/null +++ b/examples/qtquick/threading/threadedlistmodel/threadedlistmodel.qmlproject @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QmlProject 1.1 + +Project { + mainFile: "timedisplay.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/threading/threadedlistmodel/timedisplay.qml b/examples/qtquick/threading/threadedlistmodel/timedisplay.qml new file mode 100644 index 0000000000..48d0f659e5 --- /dev/null +++ b/examples/qtquick/threading/threadedlistmodel/timedisplay.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// ![0] +import QtQuick 2.0 + +Rectangle { + color: "white" + width: 200 + height: 300 + + ListView { + anchors.fill: parent + model: listModel + delegate: Component { + Text { text: time } + } + + ListModel { id: listModel } + + WorkerScript { + id: worker + source: "dataloader.js" + } + + Timer { + id: timer + interval: 2000; repeat: true + running: true + triggeredOnStart: true + + onTriggered: { + var msg = {'action': 'appendCurrentTime', 'model': listModel}; + worker.sendMessage(msg); + } + } + } +} +// ![0] diff --git a/examples/qtquick/threading/workerscript/workerscript.js b/examples/qtquick/threading/workerscript/workerscript.js new file mode 100644 index 0000000000..f76471f920 --- /dev/null +++ b/examples/qtquick/threading/workerscript/workerscript.js @@ -0,0 +1,15 @@ +var lastx = 0; +var lasty = 0; + +WorkerScript.onMessage = function(message) { + var ydiff = message.y - lasty; + var xdiff = message.x - lastx; + + var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); + + lastx = message.x; + lasty = message.y; + + WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); +} + diff --git a/examples/qtquick/threading/workerscript/workerscript.qml b/examples/qtquick/threading/workerscript/workerscript.qml new file mode 100644 index 0000000000..7fced8166c --- /dev/null +++ b/examples/qtquick/threading/workerscript/workerscript.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 480; height: 320 + + WorkerScript { + id: myWorker + source: "workerscript.js" + + onMessage: { + console.log("Moved " + messageObject.xmove + " along the X axis."); + console.log("Moved " + messageObject.ymove + " along the Y axis."); + console.log("Moved " + messageObject.move + " pixels."); + } + } + + Rectangle { + width: 200; height: 200 + anchors.left: parent.left; anchors.leftMargin: 20 + color: "red" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); + } + } + + Rectangle { + width: 200; height: 200 + anchors.right: parent.right; anchors.rightMargin: 20 + color: "blue" + + MouseArea { + anchors.fill: parent + onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); + } + } + + Text { + text: "Click a Rectangle!" + anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } + } +} diff --git a/examples/qtquick/threading/workerscript/workerscript.qmlproject b/examples/qtquick/threading/workerscript/workerscript.qmlproject new file mode 100644 index 0000000000..6d7a91feeb --- /dev/null +++ b/examples/qtquick/threading/workerscript/workerscript.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "workerscript.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/touchinteraction/multipointtouch/bearwhack.qml b/examples/qtquick/touchinteraction/multipointtouch/bearwhack.qml new file mode 100644 index 0000000000..db46473c05 --- /dev/null +++ b/examples/qtquick/touchinteraction/multipointtouch/bearwhack.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Item { + id: root + height: 640 + width: 320 + Item { + id: startScreen + anchors.fill: parent + z: 1000 + Image { + source: "content/title.png" + anchors.centerIn: parent + } + MouseArea{ + anchors.fill: parent + onClicked: {//Game Start + parent.visible = false; + } + } + } + Rectangle { + id: bg + anchors.fill: parent + gradient: Gradient { + GradientStop { position: 0.0; color: "DarkBlue" } + GradientStop { position: 0.8; color: "SkyBlue" } + GradientStop { position: 0.81; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + BearWhackParticleSystem { + id: particleSystem + anchors.fill: parent + running: !startScreen.visible + } + + property int score: 0 + + Text { + anchors.right: parent.right + anchors.margins: 4 + anchors.top: parent.top + color: "white" + function padded(num) { + var ret = num.toString(); + while (ret.length < 6) + ret = "0" + ret; + return ret; + } + text: "Score: " + padded(score) + } + MultiPointTouchArea { + anchors.fill: parent + touchPoints: [//Support up to 4 touches at once? + AugmentedTouchPoint{ system: particleSystem }, + AugmentedTouchPoint{ system: particleSystem }, + AugmentedTouchPoint{ system: particleSystem }, + AugmentedTouchPoint{ system: particleSystem } + ] + } + MouseArea{ + anchors.fill: parent + id: ma + onPressedChanged: { + if (pressed) { + timer.restart(); + sgoal.enabled = true; + particleSystem.explode(mouseX,mouseY); + } + } + Timer { + id: timer + interval: 100 + running: false + repeat: false + onTriggered: sgoal.enabled = false + } + SpriteGoal { + id: sgoal + x: ma.mouseX - 16 + y: ma.mouseY - 16 + width: 32 + height: 32 + system: particleSystem + parent: particleSystem + goalState: "falling" + enabled: false + } + } +} diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml b/examples/qtquick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml new file mode 100644 index 0000000000..aede1a8f4e --- /dev/null +++ b/examples/qtquick/touchinteraction/multipointtouch/content/AugmentedTouchPoint.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +TouchPoint { + id: container + property ParticleSystem system + onPressedChanged: { + if (pressed) { + timer.restart(); + child.enabled = true; + system.explode(x,y); + } + } + property QtObject obj: Timer { + id: timer + interval: 100 + running: false + repeat: false + onTriggered: child.enabled = false + } + property Item child: SpriteGoal { + enabled: false + x: container.area.x - 16 + y: container.area.y - 16 + width: container.area.width + 32 + height: container.area.height + 32 //+32 so it doesn't have to hit the exact center + system: container.system + parent: container.system + goalState: "falling" + } +} diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear0.png b/examples/qtquick/touchinteraction/multipointtouch/content/Bear0.png new file mode 100644 index 0000000000..64a02cec8e Binary files /dev/null and b/examples/qtquick/touchinteraction/multipointtouch/content/Bear0.png differ diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear1.png b/examples/qtquick/touchinteraction/multipointtouch/content/Bear1.png new file mode 100644 index 0000000000..3b88f3b32e Binary files /dev/null and b/examples/qtquick/touchinteraction/multipointtouch/content/Bear1.png differ diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear2.png b/examples/qtquick/touchinteraction/multipointtouch/content/Bear2.png new file mode 100644 index 0000000000..337b636070 Binary files /dev/null and b/examples/qtquick/touchinteraction/multipointtouch/content/Bear2.png differ diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/Bear3.png b/examples/qtquick/touchinteraction/multipointtouch/content/Bear3.png new file mode 100644 index 0000000000..f0e68590f4 Binary files /dev/null and b/examples/qtquick/touchinteraction/multipointtouch/content/Bear3.png differ diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/BearB.png b/examples/qtquick/touchinteraction/multipointtouch/content/BearB.png new file mode 100644 index 0000000000..c9a84ae1d4 Binary files /dev/null and b/examples/qtquick/touchinteraction/multipointtouch/content/BearB.png differ diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml b/examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml new file mode 100644 index 0000000000..05d74ab0ea --- /dev/null +++ b/examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +ParticleSystem { + id: particleSystem + function explode(x,y) { + fireEmitter.burst(100,x,y); + } + + Emitter { + id: emitter + group: "bears" + width: parent.width + emitRate: 1 + NumberAnimation on emitRate { + id: goFaster + from: 1 + to: 16 + running: particleSystem.running + loops: 1 + duration: 60000 * 5 + easing.type: Easing.Linear + } + lifeSpan: 4000 + 800*(16-emitRate) + maximumEmitted: 128 + size: 64 + speed: PointDirection{ y: 40 + 10 * emitter.emitRate } + } + + Emitter { + id: fireEmitter + enabled: false + maximumEmitted: 6000 + group: "flame" + emitRate: 1000 + size: 16 + endSize: 8 + speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 120;} PointDirection { y: -60 }} + lifeSpan: 400 + } + Emitter { + id: heartEmitter + enabled: false + maximumEmitted: 6000 + group: "hearts" + emitRate: 1000 + size: 16 + endSize: 8 + speed: AngleDirection {angleVariation: 180; magnitudeVariation: 180;} + lifeSpan: 600 + } + Emitter { + id: bloodEmitter + enabled: false + maximumEmitted: 6000 + group: "blood" + emitRate: 1000 + size: 16 + endSize: 8 + speed: CumulativeDirection { AngleDirection {angleVariation: 180; magnitudeVariation: 80;} PointDirection { y: 40 }} + lifeSpan: 600 + } + + Affector { + width: parent.width + height: 64 + once: true + y: parent.height - 32 + groups: "bears" + onAffectParticles: { + for (var i=0;i +#include +#define DECLARATIVE_EXAMPLE_MAIN(NAME) int main(int argc, char* argv[]) \ +{\ + QGuiApplication app(argc,argv);\ + QQuickView view;\ + view.setSource(QUrl::fromLocalFile(#NAME ".qml"));\ + view.show();\ + return app.exec();\ +} diff --git a/examples/shared/shared.pro b/examples/shared/shared.pro new file mode 100644 index 0000000000..d6ce120f41 --- /dev/null +++ b/examples/shared/shared.pro @@ -0,0 +1,9 @@ +#just install the files, all QML for now +TEMPLATE = aux + +qml.files = images \ + LauncherList.qml \ + SimpleLauncherDelegate.qml \ + Button.qml +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/shared +INSTALLS = qml diff --git a/examples/tutorials/dynamicview/dynamicview1/PetsModel.qml b/examples/tutorials/dynamicview/dynamicview1/PetsModel.qml new file mode 100644 index 0000000000..f07613c968 --- /dev/null +++ b/examples/tutorials/dynamicview/dynamicview1/PetsModel.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } +//![0] + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +//![1] +} +//![1] diff --git a/examples/tutorials/dynamicview/dynamicview1/dynamicview.qml b/examples/tutorials/dynamicview/dynamicview1/dynamicview.qml new file mode 100644 index 0000000000..1a9dd453ce --- /dev/null +++ b/examples/tutorials/dynamicview/dynamicview1/dynamicview.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: root + + width: 300; height: 400 + +//![1] + Component { + id: dragDelegate + + Rectangle { + id: content + + anchors { left: parent.left; right: parent.right } + height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" + + radius: 2 + + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } + } + } +//![1] +//![2] + ListView { + id: view + + anchors { fill: parent; margins: 2 } + + model: PetsModel {} + delegate: dragDelegate + + spacing: 4 + cacheBuffer: 50 + } +//![2] +} +//![0] diff --git a/examples/tutorials/dynamicview/dynamicview2/PetsModel.qml b/examples/tutorials/dynamicview/dynamicview2/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/tutorials/dynamicview/dynamicview2/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/tutorials/dynamicview/dynamicview2/dynamicview.qml b/examples/tutorials/dynamicview/dynamicview2/dynamicview.qml new file mode 100644 index 0000000000..9e654a685c --- /dev/null +++ b/examples/tutorials/dynamicview/dynamicview2/dynamicview.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + + width: 300; height: 400 + +//![0] + Component { + id: dragDelegate + +//![1] + MouseArea { + id: dragArea + + property bool held: false + + anchors { left: parent.left; right: parent.right } + height: content.height + + drag.target: held ? content : undefined + drag.axis: Drag.YAxis + + onPressAndHold: held = true + onReleased: held = false + + Rectangle { + id: content +//![1] + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + width: dragArea.width; height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" +//![3] + color: dragArea.held ? "lightsteelblue" : "white" + Behavior on color { ColorAnimation { duration: 100 } } +//![3] + radius: 2 +//![4] + states: State { + when: dragArea.held + + ParentChange { target: content; parent: root } + AnchorChanges { + target: content + anchors { horizontalCenter: undefined; verticalCenter: undefined } + } + } +//![4] + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } +//![2] + } + } +//![2] + } +//![0] + + ListView { + id: view + + anchors { fill: parent; margins: 2 } + + model: PetsModel {} + delegate: dragDelegate + + spacing: 4 + cacheBuffer: 50 + } +} diff --git a/examples/tutorials/dynamicview/dynamicview3/PetsModel.qml b/examples/tutorials/dynamicview/dynamicview3/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/tutorials/dynamicview/dynamicview3/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/tutorials/dynamicview/dynamicview3/dynamicview.qml b/examples/tutorials/dynamicview/dynamicview3/dynamicview.qml new file mode 100644 index 0000000000..5a579f78d9 --- /dev/null +++ b/examples/tutorials/dynamicview/dynamicview3/dynamicview.qml @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![0] +Rectangle { + id: root + + width: 300; height: 400 + + Component { + id: dragDelegate + + MouseArea { + id: dragArea + + property bool held: false + + anchors { left: parent.left; right: parent.right } + height: content.height + + drag.target: held ? content : undefined + drag.axis: Drag.YAxis + + onPressAndHold: held = true + onReleased: held = false + + Rectangle { + id: content +//![0] + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + width: dragArea.width; height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" + + color: dragArea.held ? "lightsteelblue" : "white" + Behavior on color { ColorAnimation { duration: 100 } } + + radius: 2 +//![1] + Drag.active: dragArea.held + Drag.source: dragArea + Drag.hotSpot.x: width / 2 + Drag.hotSpot.y: height / 2 +//![1] + states: State { + when: dragArea.held + + ParentChange { target: content; parent: root } + AnchorChanges { + target: content + anchors { horizontalCenter: undefined; verticalCenter: undefined } + } + } + + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } +//![2] + } +//![3] + DropArea { + anchors { fill: parent; margins: 10 } + + onEntered: { + visualModel.items.move( + drag.source.VisualDataModel.itemsIndex, + dragArea.VisualDataModel.itemsIndex) + } + } +//![3] + } + } +//![2] +//![4] + VisualDataModel { + id: visualModel + + model: PetsModel {} + delegate: dragDelegate + } + + ListView { + id: view + + anchors { fill: parent; margins: 2 } + + model: visualModel + + spacing: 4 + cacheBuffer: 50 + } +//![4] +//![5] +} +//![5] diff --git a/examples/tutorials/dynamicview/dynamicview4/ListSelector.qml b/examples/tutorials/dynamicview/dynamicview4/ListSelector.qml new file mode 100644 index 0000000000..c6b8287beb --- /dev/null +++ b/examples/tutorials/dynamicview/dynamicview4/ListSelector.qml @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: selector + + property alias list: view.model + property alias selectedIndex: view.currentIndex + property alias label: labelText.text + property bool expanded + + width: 100; height: labelText.implicitHeight + 26 + + Rectangle { + anchors { left: parent.left; right: parent.right; bottom: parent.bottom; } + + height: labelText.implicitHeight + 4 + (expanded ? 20 * view.count : 20) + Behavior on height { NumberAnimation { duration: 300 } } + + radius: 2 + border.width: 1 + border.color: "yellow" + color: "yellow" + + MouseArea { + anchors.fill: parent + + onClicked: selector.expanded = !selector.expanded + + Text { + id: labelText + anchors { left: parent.left; top: parent.top; margins: 2 } + } + + Rectangle { + anchors { + left: parent.left; top: labelText.bottom; + right: parent.right; bottom: parent.bottom; + margins: 2 + leftMargin: 10 + } + + radius: 2 + color: "white" + + ListView { + id: view + + anchors.fill: parent + + clip: true + + delegate: Text { + anchors { left: parent.left; right: parent.right } + height: 20 + + verticalAlignment: Text.AlignVCenter + + text: modelData + + MouseArea { + anchors.fill: parent + + onClicked: { + view.currentIndex = index + selector.expanded = !selector.expanded + } + } + } + highlight: Rectangle { + anchors { left: parent.left; right: parent.right } + height: 20 + radius: 2 + + color: "yellow" + } + } + } + } + } +} diff --git a/examples/tutorials/dynamicview/dynamicview4/PetsModel.qml b/examples/tutorials/dynamicview/dynamicview4/PetsModel.qml new file mode 100644 index 0000000000..4f2087d95e --- /dev/null +++ b/examples/tutorials/dynamicview/dynamicview4/PetsModel.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +ListModel { + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } +} diff --git a/examples/tutorials/dynamicview/dynamicview4/dynamicview.qml b/examples/tutorials/dynamicview/dynamicview4/dynamicview.qml new file mode 100644 index 0000000000..9bd4e0c438 --- /dev/null +++ b/examples/tutorials/dynamicview/dynamicview4/dynamicview.qml @@ -0,0 +1,219 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: root + + width: 300; height: 400 + + Component { + id: dragDelegate + + MouseArea { + id: dragArea + + property bool held: false + + anchors { left: parent.left; right: parent.right } + height: content.height + + enabled: visualModel.sortOrder == visualModel.lessThan.length + + drag.target: held ? content : undefined + drag.axis: Drag.YAxis + + onPressAndHold: held = true + onReleased: held = false + + Rectangle { + id: content + + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + width: dragArea.width; height: column.implicitHeight + 4 + + border.width: 1 + border.color: "lightsteelblue" + + color: dragArea.held ? "lightsteelblue" : "white" + Behavior on color { ColorAnimation { duration: 100 } } + + radius: 2 + + Drag.active: dragArea.held + Drag.source: dragArea + Drag.hotSpot.x: width / 2 + Drag.hotSpot.y: height / 2 + + states: State { + when: dragArea.held + + ParentChange { target: content; parent: root } + AnchorChanges { + target: content + anchors { horizontalCenter: undefined; verticalCenter: undefined } + } + } + + Column { + id: column + anchors { fill: parent; margins: 2 } + + Text { text: 'Name: ' + name } + Text { text: 'Type: ' + type } + Text { text: 'Age: ' + age } + Text { text: 'Size: ' + size } + } + } + + DropArea { + anchors { fill: parent; margins: 10 } + + onEntered: { + visualModel.items.move( + drag.source.VisualDataModel.itemsIndex, + dragArea.VisualDataModel.itemsIndex) + } + } + } + } +//![0] + VisualDataModel { + id: visualModel +//![4] + property var lessThan: [ + function(left, right) { return left.name < right.name }, + function(left, right) { return left.type < right.type }, + function(left, right) { return left.age < right.age }, + function(left, right) { + if (left.size == "Small") + return true + else if (right.size == "Small") + return false + else if (left.size == "Medium") + return true + else + return false + } + ] +//![4] +//![6] + + property int sortOrder: orderSelector.selectedIndex + onSortOrderChanged: items.setGroups(0, items.count, "unsorted") + +//![6] +//![3] + function insertPosition(lessThan, item) { + var lower = 0 + var upper = items.count + while (lower < upper) { + var middle = Math.floor(lower + (upper - lower) / 2) + var result = lessThan(item.model, items.get(middle).model); + if (result) { + upper = middle + } else { + lower = middle + 1 + } + } + return lower + } + + function sort(lessThan) { + while (unsortedItems.count > 0) { + var item = unsortedItems.get(0) + var index = insertPosition(lessThan, item) + + item.groups = "items" + items.move(item.itemsIndex, index) + } + } +//![3] + +//![1] + items.includeByDefault: false +//![5] + groups: VisualDataGroup { + id: unsortedItems + name: "unsorted" + + includeByDefault: true +//![1] + onChanged: { + if (visualModel.sortOrder == visualModel.lessThan.length) + setGroups(0, count, "items") + else + visualModel.sort(visualModel.lessThan[visualModel.sortOrder]) + } +//![2] + } +//![2] +//![5] + model: PetsModel {} + delegate: dragDelegate + } +//![0] + ListView { + id: view + + anchors { + left: parent.left; top: parent.top; right: parent.right; bottom: orderSelector.top; + margins: 2 + } + + model: visualModel + + spacing: 4 + cacheBuffer: 50 + } + + ListSelector { + id: orderSelector + + anchors { left: parent.left; right: parent.right; bottom: parent.bottom; margins: 2 } + + label: "Sort By" + list: [ "Name", "Type", "Age", "Size", "Custom" ] + } +} diff --git a/examples/tutorials/extending/chapter1-basics/app.qml b/examples/tutorials/extending/chapter1-basics/app.qml new file mode 100644 index 0000000000..6f0c1d3a23 --- /dev/null +++ b/examples/tutorials/extending/chapter1-basics/app.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: aPieChart + anchors.centerIn: parent + width: 100; height: 100 + name: "A simple pie chart" + color: "red" + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: aPieChart.name + } +} +//![0] diff --git a/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro new file mode 100644 index 0000000000..affc57ce1f --- /dev/null +++ b/examples/tutorials/extending/chapter1-basics/chapter1-basics.pro @@ -0,0 +1,5 @@ +QT += declarative quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/tutorials/extending/chapter1-basics/main.cpp b/examples/tutorials/extending/chapter1-basics/main.cpp new file mode 100644 index 0000000000..ed9e412bd6 --- /dev/null +++ b/examples/tutorials/extending/chapter1-basics/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/tutorials/extending/chapter1-basics/piechart.cpp b/examples/tutorials/extending/chapter1-basics/piechart.cpp new file mode 100644 index 0000000000..bc81d6a3a0 --- /dev/null +++ b/examples/tutorials/extending/chapter1-basics/piechart.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include + +//![0] +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} +//![0] + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +void PieChart::setColor(const QColor &color) +{ + m_color = color; +} + +//![1] +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} +//![1] + diff --git a/examples/tutorials/extending/chapter1-basics/piechart.h b/examples/tutorials/extending/chapter1-basics/piechart.h new file mode 100644 index 0000000000..71a8786e7d --- /dev/null +++ b/examples/tutorials/extending/chapter1-basics/piechart.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +//![0] +#include +#include + +class PieChart : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QColor color READ color WRITE setColor) + +public: + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +private: + QString m_name; + QColor m_color; +}; +//![0] + +#endif + diff --git a/examples/tutorials/extending/chapter2-methods/app.qml b/examples/tutorials/extending/chapter2-methods/app.qml new file mode 100644 index 0000000000..eee0933734 --- /dev/null +++ b/examples/tutorials/extending/chapter2-methods/app.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: aPieChart + anchors.centerIn: parent + width: 100; height: 100 + color: "red" + + onChartCleared: console.log("The chart has been cleared") + } + + MouseArea { + anchors.fill: parent + onClicked: aPieChart.clearChart() + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: "Click anywhere to clear the chart" + } +} +//![0] diff --git a/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro new file mode 100644 index 0000000000..affc57ce1f --- /dev/null +++ b/examples/tutorials/extending/chapter2-methods/chapter2-methods.pro @@ -0,0 +1,5 @@ +QT += declarative quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/tutorials/extending/chapter2-methods/main.cpp b/examples/tutorials/extending/chapter2-methods/main.cpp new file mode 100644 index 0000000000..ed9e412bd6 --- /dev/null +++ b/examples/tutorials/extending/chapter2-methods/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/tutorials/extending/chapter2-methods/piechart.cpp b/examples/tutorials/extending/chapter2-methods/piechart.cpp new file mode 100644 index 0000000000..71be74e943 --- /dev/null +++ b/examples/tutorials/extending/chapter2-methods/piechart.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include + +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +void PieChart::setColor(const QColor &color) +{ + m_color = color; +} + +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} + +//![0] +void PieChart::clearChart() +{ + setColor(QColor(Qt::transparent)); + update(); + + emit chartCleared(); +} +//![0] diff --git a/examples/tutorials/extending/chapter2-methods/piechart.h b/examples/tutorials/extending/chapter2-methods/piechart.h new file mode 100644 index 0000000000..7650d6e8d7 --- /dev/null +++ b/examples/tutorials/extending/chapter2-methods/piechart.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include +#include + +//![0] +class PieChart : public QQuickPaintedItem +{ +//![0] + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QColor color READ color WRITE setColor) + +//![1] +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +//![2] + Q_INVOKABLE void clearChart(); + +signals: + void chartCleared(); +//![2] + +private: + QString m_name; + QColor m_color; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/tutorials/extending/chapter3-bindings/app.qml b/examples/tutorials/extending/chapter3-bindings/app.qml new file mode 100644 index 0000000000..4ad929132c --- /dev/null +++ b/examples/tutorials/extending/chapter3-bindings/app.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + Row { + anchors.centerIn: parent + spacing: 20 + + PieChart { + id: chartA + width: 100; height: 100 + color: "red" + } + + PieChart { + id: chartB + width: 100; height: 100 + color: chartA.color + } + } + + MouseArea { + anchors.fill: parent + onClicked: { chartA.color = "blue" } + } + + Text { + anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } + text: "Click anywhere to change the chart color" + } +} +//![0] diff --git a/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro new file mode 100644 index 0000000000..affc57ce1f --- /dev/null +++ b/examples/tutorials/extending/chapter3-bindings/chapter3-bindings.pro @@ -0,0 +1,5 @@ +QT += declarative quick + +HEADERS += piechart.h +SOURCES += piechart.cpp \ + main.cpp diff --git a/examples/tutorials/extending/chapter3-bindings/main.cpp b/examples/tutorials/extending/chapter3-bindings/main.cpp new file mode 100644 index 0000000000..ed9e412bd6 --- /dev/null +++ b/examples/tutorials/extending/chapter3-bindings/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include "piechart.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} +//![0] diff --git a/examples/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/tutorials/extending/chapter3-bindings/piechart.cpp new file mode 100644 index 0000000000..2a392125da --- /dev/null +++ b/examples/tutorials/extending/chapter3-bindings/piechart.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include + +PieChart::PieChart(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QColor PieChart::color() const +{ + return m_color; +} + +//![0] +void PieChart::setColor(const QColor &color) +{ + if (color != m_color) { + m_color = color; + update(); // repaint with the new color + emit colorChanged(); + } +} +//![0] + +void PieChart::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} + +void PieChart::clearChart() +{ + setColor(QColor(Qt::transparent)); + update(); +} diff --git a/examples/tutorials/extending/chapter3-bindings/piechart.h b/examples/tutorials/extending/chapter3-bindings/piechart.h new file mode 100644 index 0000000000..77075b5727 --- /dev/null +++ b/examples/tutorials/extending/chapter3-bindings/piechart.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include +#include + +//![0] +class PieChart : public QQuickPaintedItem +{ +//![0] + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + + Q_INVOKABLE void clearChart(); + +//![2] +signals: + void colorChanged(); +//![2] + +private: + QString m_name; + QColor m_color; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/tutorials/extending/chapter4-customPropertyTypes/app.qml new file mode 100644 index 0000000000..06490773f4 --- /dev/null +++ b/examples/tutorials/extending/chapter4-customPropertyTypes/app.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + id: chart + anchors.centerIn: parent + width: 100; height: 100 + + pieSlice: PieSlice { + anchors.fill: parent + color: "red" + } + } + + Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color) +} +//![0] diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro new file mode 100644 index 0000000000..6724fa0375 --- /dev/null +++ b/examples/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro @@ -0,0 +1,7 @@ +QT += declarative quick + +HEADERS += piechart.h \ + pieslice.h +SOURCES += piechart.cpp \ + pieslice.cpp \ + main.cpp diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/tutorials/extending/chapter4-customPropertyTypes/main.cpp new file mode 100644 index 0000000000..537ea766fc --- /dev/null +++ b/examples/tutorials/extending/chapter4-customPropertyTypes/main.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +#include +#include + +//![0] +int main(int argc, char *argv[]) +{ +//![0] + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + +//![1] + qmlRegisterType("Charts", 1, 0, "PieSlice"); +//![1] + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); + +//![2] +} +//![2] diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp new file mode 100644 index 0000000000..3cf9bdc00c --- /dev/null +++ b/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +PieSlice *PieChart::pieSlice() const +{ + return m_pieSlice; +} + +//![0] +void PieChart::setPieSlice(PieSlice *pieSlice) +{ + m_pieSlice = pieSlice; + pieSlice->setParentItem(this); +} +//![0] + diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.h new file mode 100644 index 0000000000..b89db5a2b1 --- /dev/null +++ b/examples/tutorials/extending/chapter4-customPropertyTypes/piechart.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +//![0] +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) +//![0] + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] +public: +//![1] + + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + +//![2] + PieSlice *pieSlice() const; + void setPieSlice(PieSlice *pieSlice); +//![2] + +private: + QString m_name; + PieSlice *m_pieSlice; + +//![3] +}; +//![3] + +#endif + diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp new file mode 100644 index 0000000000..654a46fc8d --- /dev/null +++ b/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), 90 * 16, 290 * 16); +} + diff --git a/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.h new file mode 100644 index 0000000000..8fc445d471 --- /dev/null +++ b/examples/tutorials/extending/chapter4-customPropertyTypes/pieslice.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIESLICE_H +#define PIESLICE_H + +#include +#include + +//![0] +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + void paint(QPainter *painter); + +private: + QColor m_color; +}; +//![0] + +#endif + diff --git a/examples/tutorials/extending/chapter5-listproperties/app.qml b/examples/tutorials/extending/chapter5-listproperties/app.qml new file mode 100644 index 0000000000..37b0626948 --- /dev/null +++ b/examples/tutorials/extending/chapter5-listproperties/app.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +import Charts 1.0 +import QtQuick 2.0 + +Item { + width: 300; height: 200 + + PieChart { + anchors.centerIn: parent + width: 100; height: 100 + + slices: [ + PieSlice { + anchors.fill: parent + color: "red" + fromAngle: 0; angleSpan: 110 + }, + PieSlice { + anchors.fill: parent + color: "black" + fromAngle: 110; angleSpan: 50 + }, + PieSlice { + anchors.fill: parent + color: "blue" + fromAngle: 160; angleSpan: 100 + } + ] + } +} +//![0] diff --git a/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro new file mode 100644 index 0000000000..6724fa0375 --- /dev/null +++ b/examples/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro @@ -0,0 +1,7 @@ +QT += declarative quick + +HEADERS += piechart.h \ + pieslice.h +SOURCES += piechart.cpp \ + pieslice.cpp \ + main.cpp diff --git a/examples/tutorials/extending/chapter5-listproperties/main.cpp b/examples/tutorials/extending/chapter5-listproperties/main.cpp new file mode 100644 index 0000000000..59587733eb --- /dev/null +++ b/examples/tutorials/extending/chapter5-listproperties/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + qmlRegisterType("Charts", 1, 0, "PieChart"); + qmlRegisterType("Charts", 1, 0, "PieSlice"); + + QQuickView view; + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl::fromLocalFile("app.qml")); + view.show(); + return app.exec(); +} diff --git a/examples/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/tutorials/extending/chapter5-listproperties/piechart.cpp new file mode 100644 index 0000000000..bfcb607e60 --- /dev/null +++ b/examples/tutorials/extending/chapter5-listproperties/piechart.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +//![0] +QDeclarativeListProperty PieChart::slices() +{ + return QDeclarativeListProperty(this, 0, &PieChart::append_slice); +} + +void PieChart::append_slice(QDeclarativeListProperty *list, PieSlice *slice) +{ + PieChart *chart = qobject_cast(list->object); + if (chart) { + slice->setParentItem(chart); + chart->m_slices.append(slice); + } +} +//![0] diff --git a/examples/tutorials/extending/chapter5-listproperties/piechart.h b/examples/tutorials/extending/chapter5-listproperties/piechart.h new file mode 100644 index 0000000000..9beabda5f3 --- /dev/null +++ b/examples/tutorials/extending/chapter5-listproperties/piechart.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +//![0] +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QDeclarativeListProperty slices READ slices) +//![0] + Q_PROPERTY(QString name READ name WRITE setName) + +//![1] +public: +//![1] + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + +//![2] + QDeclarativeListProperty slices(); + +private: + static void append_slice(QDeclarativeListProperty *list, PieSlice *slice); + + QString m_name; + QList m_slices; +}; +//![2] + +#endif + diff --git a/examples/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/tutorials/extending/chapter5-listproperties/pieslice.cpp new file mode 100644 index 0000000000..5bca2d58d8 --- /dev/null +++ b/examples/tutorials/extending/chapter5-listproperties/pieslice.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +int PieSlice::fromAngle() const +{ + return m_fromAngle; +} + +void PieSlice::setFromAngle(int angle) +{ + m_fromAngle = angle; +} + +int PieSlice::angleSpan() const +{ + return m_angleSpan; +} + +void PieSlice::setAngleSpan(int angle) +{ + m_angleSpan = angle; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); +} + diff --git a/examples/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/tutorials/extending/chapter5-listproperties/pieslice.h new file mode 100644 index 0000000000..f6497fcbae --- /dev/null +++ b/examples/tutorials/extending/chapter5-listproperties/pieslice.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIESLICE_H +#define PIESLICE_H + +#include +#include + +//![0] +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) + Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) +//![0] + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + int fromAngle() const; + void setFromAngle(int angle); + + int angleSpan() const; + void setAngleSpan(int span); + + void paint(QPainter *painter); + +private: + QColor m_color; + int m_fromAngle; + int m_angleSpan; +}; + +#endif + diff --git a/examples/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir b/examples/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir new file mode 100644 index 0000000000..72650d8243 --- /dev/null +++ b/examples/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir @@ -0,0 +1 @@ +plugin chartsplugin \ No newline at end of file diff --git a/examples/tutorials/extending/chapter6-plugins/app.qml b/examples/tutorials/extending/chapter6-plugins/app.qml new file mode 100644 index 0000000000..b6eac44e27 --- /dev/null +++ b/examples/tutorials/extending/chapter6-plugins/app.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 +import "ChartsPlugin" 1.0 + +Item { + width: 300; height: 200 + + PieChart { + anchors.centerIn: parent + width: 100; height: 100 + + slices: [ + PieSlice { + anchors.fill: parent + color: "red" + fromAngle: 0; angleSpan: 110 + }, + PieSlice { + anchors.fill: parent + color: "black" + fromAngle: 110; angleSpan: 50 + }, + PieSlice { + anchors.fill: parent + color: "blue" + fromAngle: 160; angleSpan: 100 + } + ] + } +} + diff --git a/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro new file mode 100644 index 0000000000..c243ec4572 --- /dev/null +++ b/examples/tutorials/extending/chapter6-plugins/chapter6-plugins.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += declarative quick + +DESTDIR = ChartsPlugin +TARGET = chartsplugin + +OBJECTS_DIR = tmp +MOC_DIR = tmp + +HEADERS += piechart.h \ + pieslice.h \ + chartsplugin.h + +SOURCES += piechart.cpp \ + pieslice.cpp \ + chartsplugin.cpp + diff --git a/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp new file mode 100644 index 0000000000..d75f810964 --- /dev/null +++ b/examples/tutorials/extending/chapter6-plugins/chartsplugin.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "chartsplugin.h" +//![0] +#include "piechart.h" +#include "pieslice.h" +#include + +void ChartsPlugin::registerTypes(const char *uri) +{ + qmlRegisterType(uri, 1, 0, "PieChart"); + qmlRegisterType(uri, 1, 0, "PieSlice"); +} + +//![0] + diff --git a/examples/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/tutorials/extending/chapter6-plugins/chartsplugin.h new file mode 100644 index 0000000000..863564b09c --- /dev/null +++ b/examples/tutorials/extending/chapter6-plugins/chartsplugin.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CHARTSPLUGIN_H +#define CHARTSPLUGIN_H + +//![0] +#include + +class ChartsPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDeclarativeExtensionInterface" FILE "chartsplugin.json") + +public: + void registerTypes(const char *uri); +}; +//![0] + +#endif + diff --git a/examples/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/tutorials/extending/chapter6-plugins/piechart.cpp new file mode 100644 index 0000000000..2a8f40289e --- /dev/null +++ b/examples/tutorials/extending/chapter6-plugins/piechart.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "piechart.h" +#include "pieslice.h" + +PieChart::PieChart(QQuickItem *parent) + : QQuickItem(parent) +{ +} + +QString PieChart::name() const +{ + return m_name; +} + +void PieChart::setName(const QString &name) +{ + m_name = name; +} + +QDeclarativeListProperty PieChart::slices() +{ + return QDeclarativeListProperty(this, 0, &PieChart::append_slice); +} + +void PieChart::append_slice(QDeclarativeListProperty *list, PieSlice *slice) +{ + PieChart *chart = qobject_cast(list->object); + if (chart) { + slice->setParentItem(chart); + chart->m_slices.append(slice); + } +} + diff --git a/examples/tutorials/extending/chapter6-plugins/piechart.h b/examples/tutorials/extending/chapter6-plugins/piechart.h new file mode 100644 index 0000000000..fe6b96afdc --- /dev/null +++ b/examples/tutorials/extending/chapter6-plugins/piechart.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIECHART_H +#define PIECHART_H + +#include + +class PieSlice; + +class PieChart : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(QDeclarativeListProperty slices READ slices) + Q_PROPERTY(QString name READ name WRITE setName) + +public: + PieChart(QQuickItem *parent = 0); + + QString name() const; + void setName(const QString &name); + + QDeclarativeListProperty slices(); + +private: + static void append_slice(QDeclarativeListProperty *list, PieSlice *slice); + + QString m_name; + QList m_slices; +}; + +#endif + diff --git a/examples/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/tutorials/extending/chapter6-plugins/pieslice.cpp new file mode 100644 index 0000000000..5bca2d58d8 --- /dev/null +++ b/examples/tutorials/extending/chapter6-plugins/pieslice.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "pieslice.h" + +#include + +PieSlice::PieSlice(QQuickItem *parent) + : QQuickPaintedItem(parent) +{ +} + +QColor PieSlice::color() const +{ + return m_color; +} + +void PieSlice::setColor(const QColor &color) +{ + m_color = color; +} + +int PieSlice::fromAngle() const +{ + return m_fromAngle; +} + +void PieSlice::setFromAngle(int angle) +{ + m_fromAngle = angle; +} + +int PieSlice::angleSpan() const +{ + return m_angleSpan; +} + +void PieSlice::setAngleSpan(int angle) +{ + m_angleSpan = angle; +} + +void PieSlice::paint(QPainter *painter) +{ + QPen pen(m_color, 2); + painter->setPen(pen); + painter->setRenderHints(QPainter::HighQualityAntialiasing, true); + painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); +} + diff --git a/examples/tutorials/extending/chapter6-plugins/pieslice.h b/examples/tutorials/extending/chapter6-plugins/pieslice.h new file mode 100644 index 0000000000..8a636fb3e7 --- /dev/null +++ b/examples/tutorials/extending/chapter6-plugins/pieslice.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef PIESLICE_H +#define PIESLICE_H + +#include +#include + +class PieSlice : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) + Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) + +public: + PieSlice(QQuickItem *parent = 0); + + QColor color() const; + void setColor(const QColor &color); + + int fromAngle() const; + void setFromAngle(int angle); + + int angleSpan() const; + void setAngleSpan(int span); + + void paint(QPainter *painter); + +private: + QColor m_color; + int m_fromAngle; + int m_angleSpan; +}; + +#endif + diff --git a/examples/tutorials/extending/extending.pro b/examples/tutorials/extending/extending.pro new file mode 100644 index 0000000000..967473fda0 --- /dev/null +++ b/examples/tutorials/extending/extending.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + chapter1-basics \ + chapter2-methods \ + chapter3-bindings \ + chapter4-customPropertyTypes \ + chapter5-listproperties \ + chapter6-plugins + diff --git a/examples/tutorials/helloworld/Cell.qml b/examples/tutorials/helloworld/Cell.qml new file mode 100644 index 0000000000..7140dcb2c1 --- /dev/null +++ b/examples/tutorials/helloworld/Cell.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +//![1] +Item { + id: container +//![4] + property alias cellColor: rectangle.color +//![4] +//![5] + signal clicked(color cellColor) +//![5] + + width: 40; height: 25 +//![1] + +//![2] + Rectangle { + id: rectangle + border.color: "white" + anchors.fill: parent + } +//![2] + +//![3] + MouseArea { + anchors.fill: parent + onClicked: container.clicked(container.cellColor) + } +//![3] +} +//![0] diff --git a/examples/tutorials/helloworld/tutorial1.qml b/examples/tutorials/helloworld/tutorial1.qml new file mode 100644 index 0000000000..f0eb42d696 --- /dev/null +++ b/examples/tutorials/helloworld/tutorial1.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +//![3] +import QtQuick 2.0 +//![3] + +//![1] +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" +//![1] + +//![2] + Text { + id: helloText + text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + } +//![2] +} +//![0] diff --git a/examples/tutorials/helloworld/tutorial2.qml b/examples/tutorials/helloworld/tutorial2.qml new file mode 100644 index 0000000000..c5c045aace --- /dev/null +++ b/examples/tutorials/helloworld/tutorial2.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" + + Text { + id: helloText + text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + } + + Grid { + id: colorPicker + x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 + rows: 2; columns: 3; spacing: 3 + +//![1] + Cell { cellColor: "red"; onClicked: helloText.color = cellColor } +//![1] + Cell { cellColor: "green"; onClicked: helloText.color = cellColor } + Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } + Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "black"; onClicked: helloText.color = cellColor } + } +} +//![0] diff --git a/examples/tutorials/helloworld/tutorial3.qml b/examples/tutorials/helloworld/tutorial3.qml new file mode 100644 index 0000000000..c804bfca1d --- /dev/null +++ b/examples/tutorials/helloworld/tutorial3.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: page + width: 500; height: 200 + color: "lightgray" + + Text { + id: helloText + text: "Hello world!" + y: 30 + anchors.horizontalCenter: page.horizontalCenter + font.pointSize: 24; font.bold: true + +//![1] + MouseArea { id: mouseArea; anchors.fill: parent } +//![1] + +//![2] + states: State { + name: "down"; when: mouseArea.pressed == true + PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" } + } +//![2] + +//![3] + transitions: Transition { + from: ""; to: "down"; reversible: true + ParallelAnimation { + NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: Easing.InOutQuad } + ColorAnimation { duration: 500 } + } + } +//![3] + } + + Grid { + id: colorPicker + x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 + rows: 2; columns: 3; spacing: 3 + + Cell { cellColor: "red"; onClicked: helloText.color = cellColor } + Cell { cellColor: "green"; onClicked: helloText.color = cellColor } + Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } + Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } + Cell { cellColor: "black"; onClicked: helloText.color = cellColor } + } +} +//![0] diff --git a/examples/tutorials/samegame/samegame1/Block.qml b/examples/tutorials/samegame/samegame1/Block.qml new file mode 100644 index 0000000000..32ef8c2bba --- /dev/null +++ b/examples/tutorials/samegame/samegame1/Block.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: block + + Image { + id: img + anchors.fill: parent + source: "../shared/pics/redStone.png" + } +} +//![0] diff --git a/examples/tutorials/samegame/samegame1/Button.qml b/examples/tutorials/samegame/samegame1/Button.qml new file mode 100644 index 0000000000..6d1d1268de --- /dev/null +++ b/examples/tutorials/samegame/samegame1/Button.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} +//![0] diff --git a/examples/tutorials/samegame/samegame1/samegame.qml b/examples/tutorials/samegame/samegame1/samegame.qml new file mode 100644 index 0000000000..73e2cc31fd --- /dev/null +++ b/examples/tutorials/samegame/samegame1/samegame.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + } + + Rectangle { + id: toolBar + width: parent.width; height: 30 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: console.log("This doesn't do anything yet...") + } + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: Who knows?" + } + } +} +//![0] diff --git a/examples/tutorials/samegame/samegame1/samegame1.qmlproject b/examples/tutorials/samegame/samegame1/samegame1.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/tutorials/samegame/samegame1/samegame1.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/tutorials/samegame/samegame2/Block.qml b/examples/tutorials/samegame/samegame2/Block.qml new file mode 100644 index 0000000000..8056b39480 --- /dev/null +++ b/examples/tutorials/samegame/samegame2/Block.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: block + + Image { + id: img + anchors.fill: parent + source: "../shared/pics/redStone.png" + } +} diff --git a/examples/tutorials/samegame/samegame2/Button.qml b/examples/tutorials/samegame/samegame2/Button.qml new file mode 100644 index 0000000000..248c20cf0f --- /dev/null +++ b/examples/tutorials/samegame/samegame2/Button.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} diff --git a/examples/tutorials/samegame/samegame2/samegame.js b/examples/tutorials/samegame/samegame2/samegame.js new file mode 100644 index 0000000000..c749dc17b1 --- /dev/null +++ b/examples/tutorials/samegame/samegame2/samegame.js @@ -0,0 +1,63 @@ +//![0] +var blockSize = 40; +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; +var board = new Array(maxIndex); +var component; + +//Index function used instead of a 2D array +function index(column, row) { + return column + (row * maxColumn); +} + +function startNewGame() { + //Delete blocks from previous game + for (var i = 0; i < maxIndex; i++) { + if (board[i] != null) + board[i].destroy(); + } + + //Calculate board size + maxColumn = Math.floor(background.width / blockSize); + maxRow = Math.floor(background.height / blockSize); + maxIndex = maxRow * maxColumn; + + //Initialize Board + board = new Array(maxIndex); + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } +} + +function createBlock(column, row) { + if (component == null) + component = Qt.createComponent("Block.qml"); + + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { + var dynamicObject = component.createObject(background); + if (dynamicObject == null) { + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.x = column * blockSize; + dynamicObject.y = row * blockSize; + dynamicObject.width = blockSize; + dynamicObject.height = blockSize; + board[index(column, row)] = dynamicObject; + } else { + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} +//![0] + diff --git a/examples/tutorials/samegame/samegame2/samegame.qml b/examples/tutorials/samegame/samegame2/samegame.qml new file mode 100644 index 0000000000..c50010e97d --- /dev/null +++ b/examples/tutorials/samegame/samegame2/samegame.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +//![2] +import "samegame.js" as SameGame +//![2] + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + } + + Rectangle { + id: toolBar + width: parent.width; height: 32 + color: activePalette.window + anchors.bottom: screen.bottom + +//![1] + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: SameGame.startNewGame() + } +//![1] + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: Who knows?" + } + } +} diff --git a/examples/tutorials/samegame/samegame2/samegame2.qmlproject b/examples/tutorials/samegame/samegame2/samegame2.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/tutorials/samegame/samegame2/samegame2.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/tutorials/samegame/samegame3/Block.qml b/examples/tutorials/samegame/samegame3/Block.qml new file mode 100644 index 0000000000..9c41048fcb --- /dev/null +++ b/examples/tutorials/samegame/samegame3/Block.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: block + + property int type: 0 + + Image { + id: img + + anchors.fill: parent + source: { + if (type == 0) + return "../shared/pics/redStone.png"; + else if (type == 1) + return "../shared/pics/blueStone.png"; + else + return "../shared/pics/greenStone.png"; + } + } +} +//![0] diff --git a/examples/tutorials/samegame/samegame3/Button.qml b/examples/tutorials/samegame/samegame3/Button.qml new file mode 100644 index 0000000000..248c20cf0f --- /dev/null +++ b/examples/tutorials/samegame/samegame3/Button.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} diff --git a/examples/tutorials/samegame/samegame3/Dialog.qml b/examples/tutorials/samegame/samegame3/Dialog.qml new file mode 100644 index 0000000000..df1fa37d6a --- /dev/null +++ b/examples/tutorials/samegame/samegame3/Dialog.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: container + + function show(text) { + dialogText.text = text; + container.opacity = 1; + } + + function hide() { + container.opacity = 0; + } + + width: dialogText.width + 20 + height: dialogText.height + 20 + opacity: 0 + + Text { + id: dialogText + anchors.centerIn: parent + text: "" + } + + MouseArea { + anchors.fill: parent + onClicked: hide(); + } +} +//![0] diff --git a/examples/tutorials/samegame/samegame3/samegame.js b/examples/tutorials/samegame/samegame3/samegame.js new file mode 100644 index 0000000000..df5bdfb049 --- /dev/null +++ b/examples/tutorials/samegame/samegame3/samegame.js @@ -0,0 +1,174 @@ +/* This script file handles the game logic */ +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; +var board = new Array(maxIndex); +var component; + +//Index function used instead of a 2D array +function index(column, row) { + return column + (row * maxColumn); +} + +function startNewGame() { + //Calculate board size + maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); + maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); + maxIndex = maxRow * maxColumn; + + //Close dialogs + dialog.hide(); + + //Initialize Board + board = new Array(maxIndex); + gameCanvas.score = 0; + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } +} + +function createBlock(column, row) { + if (component == null) + component = Qt.createComponent("Block.qml"); + + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { + var dynamicObject = component.createObject(gameCanvas); + if (dynamicObject == null) { + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.type = Math.floor(Math.random() * 3); + dynamicObject.x = column * gameCanvas.blockSize; + dynamicObject.y = row * gameCanvas.blockSize; + dynamicObject.width = gameCanvas.blockSize; + dynamicObject.height = gameCanvas.blockSize; + board[index(column, row)] = dynamicObject; + } else { + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} + +var fillFound; //Set after a floodFill call to the number of blocks found +var floodBoard; //Set to 1 if the floodFill reaches off that node + +//![1] +function handleClick(xPos, yPos) { + var column = Math.floor(xPos / gameCanvas.blockSize); + var row = Math.floor(yPos / gameCanvas.blockSize); + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (board[index(column, row)] == null) + return; + //If it's a valid block, remove it and all connected (does nothing if it's not connected) + floodFill(column, row, -1); + if (fillFound <= 0) + return; + gameCanvas.score += (fillFound - 1) * (fillFound - 1); + shuffleDown(); + victoryCheck(); +} +//![1] + +function floodFill(column, row, type) { + if (board[index(column, row)] == null) + return; + var first = false; + if (type == -1) { + first = true; + type = board[index(column, row)].type; + + //Flood fill initialization + fillFound = 0; + floodBoard = new Array(maxIndex); + } + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) + return; + floodBoard[index(column, row)] = 1; + floodFill(column + 1, row, type); + floodFill(column - 1, row, type); + floodFill(column, row + 1, type); + floodFill(column, row - 1, type); + if (first == true && fillFound == 0) + return; //Can't remove single blocks + board[index(column, row)].opacity = 0; + board[index(column, row)] = null; + fillFound += 1; +} + +function shuffleDown() { + //Fall down + for (var column = 0; column < maxColumn; column++) { + var fallDist = 0; + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column, row)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.y += fallDist * gameCanvas.blockSize; + board[index(column, row + fallDist)] = obj; + board[index(column, row)] = null; + } + } + } + } + //Fall to the left + var fallDist = 0; + for (var column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + for (var row = 0; row < maxRow; row++) { + var obj = board[index(column, row)]; + if (obj == null) + continue; + obj.x -= fallDist * gameCanvas.blockSize; + board[index(column - fallDist, row)] = obj; + board[index(column, row)] = null; + } + } + } + } +} + +//![2] +function victoryCheck() { + //Award bonus points if no blocks left + var deservesBonus = true; + for (var column = maxColumn - 1; column >= 0; column--) + if (board[index(column, maxRow - 1)] != null) + deservesBonus = false; + if (deservesBonus) + gameCanvas.score += 500; + + //Check whether game has finished + if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) + dialog.show("Game Over. Your score is " + gameCanvas.score); +} +//![2] + +//only floods up and right, to see if it can find adjacent same-typed blocks +function floodMoveCheck(column, row, type) { + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return false; + if (board[index(column, row)] == null) + return false; + var myType = board[index(column, row)].type; + if (type == myType) + return true; + return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); +} + diff --git a/examples/tutorials/samegame/samegame3/samegame.qml b/examples/tutorials/samegame/samegame3/samegame.qml new file mode 100644 index 0000000000..f14829ef63 --- /dev/null +++ b/examples/tutorials/samegame/samegame3/samegame.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 +import "samegame.js" as SameGame + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + +//![1] + Item { + id: gameCanvas + + property int score: 0 + property int blockSize: 40 + + width: parent.width - (parent.width % blockSize) + height: parent.height - (parent.height % blockSize) + anchors.centerIn: parent + + MouseArea { + anchors.fill: parent + onClicked: SameGame.handleClick(mouse.x, mouse.y) + } + } +//![1] + } + +//![2] + Dialog { + id: dialog + anchors.centerIn: parent + z: 100 + } +//![2] + + Rectangle { + id: toolBar + width: parent.width; height: 30 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: SameGame.startNewGame() + } + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: Who knows?" + } + } +} +//![0] diff --git a/examples/tutorials/samegame/samegame3/samegame3.qmlproject b/examples/tutorials/samegame/samegame3/samegame3.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/tutorials/samegame/samegame3/samegame3.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/tutorials/samegame/samegame4/content/BoomBlock.qml new file mode 100644 index 0000000000..3786b9c0d1 --- /dev/null +++ b/examples/tutorials/samegame/samegame4/content/BoomBlock.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Qt.labs.particles 1.0 + +Item { + id: block + + property int type: 0 + property bool dying: false + + //![1] + property bool spawned: false + + Behavior on x { + enabled: spawned; + SpringAnimation{ spring: 2; damping: 0.2 } + } + Behavior on y { + SpringAnimation{ spring: 2; damping: 0.2 } + } + //![1] + + //![2] + Image { + id: img + + anchors.fill: parent + source: { + if (type == 0) + return "../../shared/pics/redStone.png"; + else if (type == 1) + return "../../shared/pics/blueStone.png"; + else + return "../../shared/pics/greenStone.png"; + } + opacity: 0 + + Behavior on opacity { + NumberAnimation { properties:"opacity"; duration: 200 } + } + } + //![2] + + //![3] + Particles { + id: particles + + width: 1; height: 1 + anchors.centerIn: parent + + emissionRate: 0 + lifeSpan: 700; lifeSpanDeviation: 600 + angle: 0; angleDeviation: 360; + velocity: 100; velocityDeviation: 30 + source: { + if (type == 0) + return "../../shared/pics/redStar.png"; + else if (type == 1) + return "../../shared/pics/blueStar.png"; + else + return "../../shared/pics/greenStar.png"; + } + } + //![3] + + //![4] + states: [ + State { + name: "AliveState" + when: spawned == true && dying == false + PropertyChanges { target: img; opacity: 1 } + }, + + State { + name: "DeathState" + when: dying == true + StateChangeScript { script: particles.burst(50); } + PropertyChanges { target: img; opacity: 0 } + StateChangeScript { script: block.destroy(1000); } + } + ] + //![4] +} diff --git a/examples/tutorials/samegame/samegame4/content/Button.qml b/examples/tutorials/samegame/samegame4/content/Button.qml new file mode 100644 index 0000000000..248c20cf0f --- /dev/null +++ b/examples/tutorials/samegame/samegame4/content/Button.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property string text: "Button" + + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 5 + border { width: 1; color: Qt.darker(activePalette.button) } + smooth: true + radius: 8 + + // color the button with a gradient + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return activePalette.dark + else + return activePalette.light + } + } + GradientStop { position: 1.0; color: activePalette.button } + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked(); + } + + Text { + id: buttonLabel + anchors.centerIn: container + color: activePalette.buttonText + text: container.text + } +} diff --git a/examples/tutorials/samegame/samegame4/content/Dialog.qml b/examples/tutorials/samegame/samegame4/content/Dialog.qml new file mode 100644 index 0000000000..984b3ddb6a --- /dev/null +++ b/examples/tutorials/samegame/samegame4/content/Dialog.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +//![0] +Rectangle { + id: container +//![0] + +//![1] + property string inputText: textInput.text + signal closed + + function show(text) { + dialogText.text = text; + container.opacity = 1; + textInput.opacity = 0; + } + + function showWithInput(text) { + show(text); + textInput.opacity = 1; + textInput.focus = true; + textInput.text = "" + } + + function hide() { + textInput.focus = false; + container.opacity = 0; + container.closed(); + } +//![1] + + width: dialogText.width + textInput.width + 20 + height: dialogText.height + 20 + opacity: 0 + visible: opacity > 0 + + Text { + id: dialogText + anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: 10 } + text: "" + } + +//![2] + TextInput { + id: textInput + anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } + width: 80 + text: "" + + onAccepted: container.hide() // close dialog when Enter is pressed + } +//![2] + + MouseArea { + anchors.fill: parent + + onClicked: { + if (textInput.text == "" && textInput.opacity > 0) + textInput.openSoftwareInputPanel(); + else + hide(); + } + } + +//![3] +} +//![3] diff --git a/examples/tutorials/samegame/samegame4/content/samegame.js b/examples/tutorials/samegame/samegame4/content/samegame.js new file mode 100755 index 0000000000..7bb7243914 --- /dev/null +++ b/examples/tutorials/samegame/samegame4/content/samegame.js @@ -0,0 +1,226 @@ +/* This script file handles the game logic */ +.import QtQuick.LocalStorage 2.0 as Sql + +var maxColumn = 10; +var maxRow = 15; +var maxIndex = maxColumn * maxRow; +var board = new Array(maxIndex); +var component; +var scoresURL = ""; +var gameDuration; + +//Index function used instead of a 2D array +function index(column, row) { + return column + (row * maxColumn); +} + +function startNewGame() { + //Delete blocks from previous game + for (var i = 0; i < maxIndex; i++) { + if (board[i] != null) + board[i].destroy(); + } + + //Calculate board size + maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); + maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); + maxIndex = maxRow * maxColumn; + + //Close dialogs + nameInputDialog.hide(); + dialog.hide(); + + //Initialize Board + board = new Array(maxIndex); + gameCanvas.score = 0; + for (var column = 0; column < maxColumn; column++) { + for (var row = 0; row < maxRow; row++) { + board[index(column, row)] = null; + createBlock(column, row); + } + } + + gameDuration = new Date(); +} + +function createBlock(column, row) { + if (component == null) + component = Qt.createComponent("content/BoomBlock.qml"); + + // Note that if Block.qml was not a local file, component.status would be + // Loading and we should wait for the component's statusChanged() signal to + // know when the file is downloaded and ready before calling createObject(). + if (component.status == Component.Ready) { + var dynamicObject = component.createObject(gameCanvas); + if (dynamicObject == null) { + console.log("error creating block"); + console.log(component.errorString()); + return false; + } + dynamicObject.type = Math.floor(Math.random() * 3); + dynamicObject.x = column * gameCanvas.blockSize; + dynamicObject.y = row * gameCanvas.blockSize; + dynamicObject.width = gameCanvas.blockSize; + dynamicObject.height = gameCanvas.blockSize; + dynamicObject.spawned = true; + board[index(column, row)] = dynamicObject; + } else { + console.log("error loading block component"); + console.log(component.errorString()); + return false; + } + return true; +} + +var fillFound; //Set after a floodFill call to the number of blocks found +var floodBoard; //Set to 1 if the floodFill reaches off that node + +function handleClick(xPos, yPos) { + var column = Math.floor(xPos / gameCanvas.blockSize); + var row = Math.floor(yPos / gameCanvas.blockSize); + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (board[index(column, row)] == null) + return; + //If it's a valid block, remove it and all connected (does nothing if it's not connected) + floodFill(column, row, -1); + if (fillFound <= 0) + return; + gameCanvas.score += (fillFound - 1) * (fillFound - 1); + shuffleDown(); + victoryCheck(); +} + +function floodFill(column, row, type) { + if (board[index(column, row)] == null) + return; + var first = false; + if (type == -1) { + first = true; + type = board[index(column, row)].type; + + //Flood fill initialization + fillFound = 0; + floodBoard = new Array(maxIndex); + } + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return; + if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) + return; + floodBoard[index(column, row)] = 1; + floodFill(column + 1, row, type); + floodFill(column - 1, row, type); + floodFill(column, row + 1, type); + floodFill(column, row - 1, type); + if (first == true && fillFound == 0) + return; //Can't remove single blocks + board[index(column, row)].dying = true; + board[index(column, row)] = null; + fillFound += 1; +} + +function shuffleDown() { + //Fall down + for (var column = 0; column < maxColumn; column++) { + var fallDist = 0; + for (var row = maxRow - 1; row >= 0; row--) { + if (board[index(column, row)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + var obj = board[index(column, row)]; + obj.y = (row + fallDist) * gameCanvas.blockSize; + board[index(column, row + fallDist)] = obj; + board[index(column, row)] = null; + } + } + } + } + //Fall to the left + fallDist = 0; + for (column = 0; column < maxColumn; column++) { + if (board[index(column, maxRow - 1)] == null) { + fallDist += 1; + } else { + if (fallDist > 0) { + for (row = 0; row < maxRow; row++) { + obj = board[index(column, row)]; + if (obj == null) + continue; + obj.x = (column - fallDist) * gameCanvas.blockSize; + board[index(column - fallDist, row)] = obj; + board[index(column, row)] = null; + } + } + } + } +} + +//![3] +function victoryCheck() { +//![3] + //Award bonus points if no blocks left + var deservesBonus = true; + for (var column = maxColumn - 1; column >= 0; column--) + if (board[index(column, maxRow - 1)] != null) + deservesBonus = false; + if (deservesBonus) + gameCanvas.score += 500; + +//![4] + //Check whether game has finished + if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { + gameDuration = new Date() - gameDuration; + nameInputDialog.showWithInput("You won! Please enter your name: "); + } +} +//![4] + +//only floods up and right, to see if it can find adjacent same-typed blocks +function floodMoveCheck(column, row, type) { + if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) + return false; + if (board[index(column, row)] == null) + return false; + var myType = board[index(column, row)].type; + if (type == myType) + return true; + return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); +} + +//![2] +function saveHighScore(name) { + if (scoresURL != "") + sendHighScore(name); + + var db = Sql.openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores", 100); + var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; + var data = [name, gameCanvas.score, maxColumn + "x" + maxRow, Math.floor(gameDuration / 1000)]; + db.transaction(function(tx) { + tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); + tx.executeSql(dataStr, data); + + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10'); + var r = "\nHIGH SCORES for a standard sized grid\n\n" + for (var i = 0; i < rs.rows.length; i++) { + r += (i + 1) + ". " + rs.rows.item(i).name + ' got ' + rs.rows.item(i).score + ' points in ' + rs.rows.item(i).time + ' seconds.\n'; + } + dialog.show(r); + }); +} +//![2] + +//![1] +function sendHighScore(name) { + var postman = new XMLHttpRequest() + var postData = "name=" + name + "&score=" + gameCanvas.score + "&gridSize=" + maxColumn + "x" + maxRow + "&time=" + Math.floor(gameDuration / 1000); + postman.open("POST", scoresURL, true); + postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + postman.onreadystatechange = function() { + if (postman.readyState == postman.DONE) { + dialog.show("Your score has been uploaded."); + } + } + postman.send(postData); +} +//![1] diff --git a/examples/tutorials/samegame/samegame4/highscores/README b/examples/tutorials/samegame/samegame4/highscores/README new file mode 100644 index 0000000000..eaa00fae37 --- /dev/null +++ b/examples/tutorials/samegame/samegame4/highscores/README @@ -0,0 +1 @@ +The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it. diff --git a/examples/tutorials/samegame/samegame4/highscores/score_data.xml b/examples/tutorials/samegame/samegame4/highscores/score_data.xml new file mode 100755 index 0000000000..c3fd90d9cf --- /dev/null +++ b/examples/tutorials/samegame/samegame4/highscores/score_data.xml @@ -0,0 +1,2 @@ +1000000Alan the Tester0x00 +6213Alan12x1751 diff --git a/examples/tutorials/samegame/samegame4/highscores/score_style.xsl b/examples/tutorials/samegame/samegame4/highscores/score_style.xsl new file mode 100755 index 0000000000..670354c965 --- /dev/null +++ b/examples/tutorials/samegame/samegame4/highscores/score_style.xsl @@ -0,0 +1,28 @@ + + + + + SameGame High Scores + +

          SameGame High Scores

          + + + + + + + + + + + + + + + + +
          NameScoreGrid SizeTime, s
          + + + + diff --git a/examples/tutorials/samegame/samegame4/highscores/scores.php b/examples/tutorials/samegame/samegame4/highscores/scores.php new file mode 100755 index 0000000000..daf480e21b --- /dev/null +++ b/examples/tutorials/samegame/samegame4/highscores/scores.php @@ -0,0 +1,31 @@ +"; + echo "SameGame High Scores"; + if($score > 0){#Sending in a new high score + $name = $_POST["name"]; + $grid = $_POST["gridSize"]; + $time = $_POST["time"]; + if($name == "") + $name = "Anonymous"; + $file = fopen("score_data.xml", "a"); + $ret = fwrite($file, "". $score . "" + . $name . "" . $grid . "" + . $time . "\n"); + echo "Your score has been recorded. Thanks for playing!"; + if($ret == False) + echo "
          There was an error though, so don't expect to see that score again."; + }else{#Read high score list + #Now uses XSLT to display. So just print the file. With XML cruft added. + #Note that firefox at least won't apply the XSLT on a php file. So redirecting + $file = fopen("scores.xml", "w"); + $ret = fwrite($file, '' . "\n" + . '' . "\n" + . "\n" . file_get_contents("score_data.xml") . "\n"); + if($ret == False) + echo "There was an internal error. Sorry."; + else + echo ''; + } + echo ""; +?> diff --git a/examples/tutorials/samegame/samegame4/samegame.qml b/examples/tutorials/samegame/samegame4/samegame.qml new file mode 100644 index 0000000000..c21b8de8bd --- /dev/null +++ b/examples/tutorials/samegame/samegame4/samegame.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" +import "content/samegame.js" as SameGame + +Rectangle { + id: screen + + width: 490; height: 720 + + SystemPalette { id: activePalette } + + Item { + width: parent.width + anchors { top: parent.top; bottom: toolBar.top } + + Image { + id: background + anchors.fill: parent + source: "../shared/pics/background.jpg" + fillMode: Image.PreserveAspectCrop + } + + Item { + id: gameCanvas + property int score: 0 + property int blockSize: 40 + + anchors.centerIn: parent + width: parent.width - (parent.width % blockSize); + height: parent.height - (parent.height % blockSize); + + MouseArea { + anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y); + } + } + } + + Dialog { + id: dialog + anchors.centerIn: parent + z: 100 + } + + //![0] + Dialog { + id: nameInputDialog + anchors.centerIn: parent + z: 100 + + onClosed: { + if (nameInputDialog.inputText != "") + SameGame.saveHighScore(nameInputDialog.inputText); + } + } + //![0] + + Rectangle { + id: toolBar + width: parent.width; height: 30 + color: activePalette.window + anchors.bottom: screen.bottom + + Button { + anchors { left: parent.left; verticalCenter: parent.verticalCenter } + text: "New Game" + onClicked: SameGame.startNewGame() + } + + Text { + id: score + anchors { right: parent.right; verticalCenter: parent.verticalCenter } + text: "Score: " + gameCanvas.score + } + } +} diff --git a/examples/tutorials/samegame/samegame4/samegame4.qmlproject b/examples/tutorials/samegame/samegame4/samegame4.qmlproject new file mode 100644 index 0000000000..42ffacf4f8 --- /dev/null +++ b/examples/tutorials/samegame/samegame4/samegame4.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "samegame.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/tutorials/samegame/shared/pics/background.jpg b/examples/tutorials/samegame/shared/pics/background.jpg new file mode 100644 index 0000000000..903d395c8d Binary files /dev/null and b/examples/tutorials/samegame/shared/pics/background.jpg differ diff --git a/examples/tutorials/samegame/shared/pics/blueStar.png b/examples/tutorials/samegame/shared/pics/blueStar.png new file mode 100644 index 0000000000..ff9588f80a Binary files /dev/null and b/examples/tutorials/samegame/shared/pics/blueStar.png differ diff --git a/examples/tutorials/samegame/shared/pics/blueStone.png b/examples/tutorials/samegame/shared/pics/blueStone.png new file mode 100644 index 0000000000..20e43c75b6 Binary files /dev/null and b/examples/tutorials/samegame/shared/pics/blueStone.png differ diff --git a/examples/tutorials/samegame/shared/pics/greenStar.png b/examples/tutorials/samegame/shared/pics/greenStar.png new file mode 100644 index 0000000000..cd06854719 Binary files /dev/null and b/examples/tutorials/samegame/shared/pics/greenStar.png differ diff --git a/examples/tutorials/samegame/shared/pics/greenStone.png b/examples/tutorials/samegame/shared/pics/greenStone.png new file mode 100644 index 0000000000..b568a1900c Binary files /dev/null and b/examples/tutorials/samegame/shared/pics/greenStone.png differ diff --git a/examples/tutorials/samegame/shared/pics/redStar.png b/examples/tutorials/samegame/shared/pics/redStar.png new file mode 100644 index 0000000000..0a4dffe583 Binary files /dev/null and b/examples/tutorials/samegame/shared/pics/redStar.png differ diff --git a/examples/tutorials/samegame/shared/pics/redStone.png b/examples/tutorials/samegame/shared/pics/redStone.png new file mode 100644 index 0000000000..36b09a2686 Binary files /dev/null and b/examples/tutorials/samegame/shared/pics/redStone.png differ diff --git a/examples/tutorials/samegame/shared/pics/star.png b/examples/tutorials/samegame/shared/pics/star.png new file mode 100644 index 0000000000..defbde53ca Binary files /dev/null and b/examples/tutorials/samegame/shared/pics/star.png differ diff --git a/examples/tutorials/samegame/shared/pics/yellowStone.png b/examples/tutorials/samegame/shared/pics/yellowStone.png new file mode 100644 index 0000000000..b1ce76212c Binary files /dev/null and b/examples/tutorials/samegame/shared/pics/yellowStone.png differ diff --git a/examples/tutorials/ui-components/dialcontrol/content/Dial.qml b/examples/tutorials/ui-components/dialcontrol/content/Dial.qml new file mode 100644 index 0000000000..c61adee364 --- /dev/null +++ b/examples/tutorials/ui-components/dialcontrol/content/Dial.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: root + property real value : 0 + + width: 210; height: 210 + + Image { source: "background.png" } + +//! [needle_shadow] + Image { + x: 96 + y: 35 + source: "needle_shadow.png" + transform: Rotation { + origin.x: 9; origin.y: 67 + angle: needleRotation.angle + } + } +//! [needle_shadow] +//! [needle] + Image { + id: needle + x: 98; y: 33 + smooth: true + source: "needle.png" + transform: Rotation { + id: needleRotation + origin.x: 5; origin.y: 65 + //! [needle angle] + angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) + Behavior on angle { + SpringAnimation { + spring: 1.4 + damping: .15 + } + } + //! [needle angle] + } + } +//! [needle] +//! [overlay] + Image { x: 21; y: 18; source: "overlay.png" } +//! [overlay] +} diff --git a/examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml b/examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml new file mode 100644 index 0000000000..702b892d23 --- /dev/null +++ b/examples/tutorials/ui-components/dialcontrol/content/QuitButton.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +Image { + source: "quit.png" + scale: quitMouse.pressed ? 0.8 : 1.0 + smooth: quitMouse.pressed + MouseArea { + id: quitMouse + anchors.fill: parent + anchors.margins: -10 + onClicked: Qt.quit() + } +} diff --git a/examples/tutorials/ui-components/dialcontrol/content/background.png b/examples/tutorials/ui-components/dialcontrol/content/background.png new file mode 100644 index 0000000000..75d555d7ab Binary files /dev/null and b/examples/tutorials/ui-components/dialcontrol/content/background.png differ diff --git a/examples/tutorials/ui-components/dialcontrol/content/needle.png b/examples/tutorials/ui-components/dialcontrol/content/needle.png new file mode 100644 index 0000000000..2d19f75039 Binary files /dev/null and b/examples/tutorials/ui-components/dialcontrol/content/needle.png differ diff --git a/examples/tutorials/ui-components/dialcontrol/content/needle_shadow.png b/examples/tutorials/ui-components/dialcontrol/content/needle_shadow.png new file mode 100644 index 0000000000..8d8a928cc5 Binary files /dev/null and b/examples/tutorials/ui-components/dialcontrol/content/needle_shadow.png differ diff --git a/examples/tutorials/ui-components/dialcontrol/content/overlay.png b/examples/tutorials/ui-components/dialcontrol/content/overlay.png new file mode 100644 index 0000000000..3860a7b590 Binary files /dev/null and b/examples/tutorials/ui-components/dialcontrol/content/overlay.png differ diff --git a/examples/tutorials/ui-components/dialcontrol/content/quit.png b/examples/tutorials/ui-components/dialcontrol/content/quit.png new file mode 100644 index 0000000000..b822057d4e Binary files /dev/null and b/examples/tutorials/ui-components/dialcontrol/content/quit.png differ diff --git a/examples/tutorials/ui-components/dialcontrol/dialcontrol.qml b/examples/tutorials/ui-components/dialcontrol/dialcontrol.qml new file mode 100644 index 0000000000..d645b34aa4 --- /dev/null +++ b/examples/tutorials/ui-components/dialcontrol/dialcontrol.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [imports] +import QtQuick 2.0 +import "content" +//! [imports] + +//! [0] +Rectangle { + color: "#545454" + width: 300; height: 300 + + // Dial with a slider to adjust it + Dial { + id: dial + anchors.centerIn: parent + value: slider.x * 100 / (container.width - 34) + } + + Rectangle { + id: container + anchors { bottom: parent.bottom; left: parent.left + right: parent.right; leftMargin: 20; rightMargin: 20 + bottomMargin: 10 + } + height: 16 + + radius: 8 + opacity: 0.7 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "gray" } + GradientStop { position: 1.0; color: "white" } + } + + Rectangle { + id: slider + x: 1; y: 1; width: 30; height: 14 + radius: 6 + smooth: true + gradient: Gradient { + GradientStop { position: 0.0; color: "#424242" } + GradientStop { position: 1.0; color: "black" } + } + + MouseArea { + anchors.fill: parent + anchors.margins: -16 // Increase mouse area a lot outside the slider + drag.target: parent; drag.axis: Drag.XAxis + drag.minimumX: 2; drag.maximumX: container.width - 32 + } + } + } + QuitButton { + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 10 + } +} +//! [0] diff --git a/examples/tutorials/ui-components/flipable/content/5_heart.png b/examples/tutorials/ui-components/flipable/content/5_heart.png new file mode 100644 index 0000000000..fb59d81453 Binary files /dev/null and b/examples/tutorials/ui-components/flipable/content/5_heart.png differ diff --git a/examples/tutorials/ui-components/flipable/content/9_club.png b/examples/tutorials/ui-components/flipable/content/9_club.png new file mode 100644 index 0000000000..2545001904 Binary files /dev/null and b/examples/tutorials/ui-components/flipable/content/9_club.png differ diff --git a/examples/tutorials/ui-components/flipable/content/Card.qml b/examples/tutorials/ui-components/flipable/content/Card.qml new file mode 100644 index 0000000000..6006ea14fc --- /dev/null +++ b/examples/tutorials/ui-components/flipable/content/Card.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Flipable { + id: container + + property alias source: frontImage.source + property bool flipped: true + property int xAxis: 0 + property int yAxis: 0 + property int angle: 0 + + width: front.width; height: front.height + + front: Image { id: frontImage; smooth: true } + back: Image { source: "back.png"; smooth: true } + + state: "back" + + MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } + + transform: Rotation { + id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 + axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 + } + + states: State { + name: "back"; when: container.flipped + PropertyChanges { target: rotation; angle: container.angle } + } + + transitions: Transition { + ParallelAnimation { + NumberAnimation { target: rotation; properties: "angle"; duration: 600 } + SequentialAnimation { + NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } + NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } + } + } + } +} diff --git a/examples/tutorials/ui-components/flipable/content/back.png b/examples/tutorials/ui-components/flipable/content/back.png new file mode 100644 index 0000000000..f715d7487e Binary files /dev/null and b/examples/tutorials/ui-components/flipable/content/back.png differ diff --git a/examples/tutorials/ui-components/flipable/flipable.qml b/examples/tutorials/ui-components/flipable/flipable.qml new file mode 100644 index 0000000000..4af64afc53 --- /dev/null +++ b/examples/tutorials/ui-components/flipable/flipable.qml @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: window + + width: 480; height: 320 + color: "darkgreen" + + Row { + anchors.centerIn: parent; spacing: 30 + Card { source: "content/9_club.png"; angle: 180; yAxis: 1 } + Card { source: "content/5_heart.png"; angle: 540; xAxis: 1 } + } +} diff --git a/examples/tutorials/ui-components/progressbar/content/ProgressBar.qml b/examples/tutorials/ui-components/progressbar/content/ProgressBar.qml new file mode 100644 index 0000000000..c9be8d7336 --- /dev/null +++ b/examples/tutorials/ui-components/progressbar/content/ProgressBar.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: progressbar + + property int minimum: 0 + property int maximum: 100 + property int value: 0 + property alias color: gradient1.color + property alias secondColor: gradient2.color + + width: 250; height: 23 + clip: true + + BorderImage { + source: "background.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + } + + Rectangle { + id: highlight + + property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) + + width: highlight.widthDest + Behavior on width { SmoothedAnimation { velocity: 1200 } } + + anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 } + radius: 1 + gradient: Gradient { + GradientStop { id: gradient1; position: 0.0 } + GradientStop { id: gradient2; position: 1.0 } + } + + } + Text { + anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } + color: "white" + font.bold: true + text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' + } +} diff --git a/examples/tutorials/ui-components/progressbar/content/background.png b/examples/tutorials/ui-components/progressbar/content/background.png new file mode 100644 index 0000000000..9044226f85 Binary files /dev/null and b/examples/tutorials/ui-components/progressbar/content/background.png differ diff --git a/examples/tutorials/ui-components/progressbar/main.qml b/examples/tutorials/ui-components/progressbar/main.qml new file mode 100644 index 0000000000..367e4c1265 --- /dev/null +++ b/examples/tutorials/ui-components/progressbar/main.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + id: main + + width: 600; height: 405 + color: "#edecec" + + Flickable { + anchors.fill: parent + contentHeight: column.height + 20 + + Column { + id: column + x: 10; y: 10 + spacing: 10 + + Repeater { + model: 25 + + ProgressBar { + property int r: Math.floor(Math.random() * 5000 + 1000) + width: main.width - 20 + + NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } + ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } + ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } + } + } + } + } +} diff --git a/examples/tutorials/ui-components/scrollbar/ScrollBar.qml b/examples/tutorials/ui-components/scrollbar/ScrollBar.qml new file mode 100644 index 0000000000..a3d0d3841c --- /dev/null +++ b/examples/tutorials/ui-components/scrollbar/ScrollBar.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: scrollBar + + // The properties that define the scrollbar's state. + // position and pageSize are in the range 0.0 - 1.0. They are relative to the + // height of the page, i.e. a pageSize of 0.5 means that you can see 50% + // of the height of the view. + // orientation can be either Qt.Vertical or Qt.Horizontal + property real position + property real pageSize + property variant orientation : Qt.Vertical + + // A light, semi-transparent background + Rectangle { + id: background + anchors.fill: parent + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "white" + opacity: 0.3 + } + + // Size the bar to the required size, depending upon the orientation. + Rectangle { + x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) + y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 + width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) + height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) + radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) + color: "black" + opacity: 0.7 + } +} diff --git a/examples/tutorials/ui-components/scrollbar/main.qml b/examples/tutorials/ui-components/scrollbar/main.qml new file mode 100644 index 0000000000..a7d602b437 --- /dev/null +++ b/examples/tutorials/ui-components/scrollbar/main.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + width: 640 + height: 480 + + // Create a flickable to view a large image. + Flickable { + id: view + anchors.fill: parent + contentWidth: picture.width + contentHeight: picture.height + + Image { + id: picture + source: "pics/niagara_falls.jpg" + asynchronous: true + } + + // Only show the scrollbars when the view is moving. + states: State { + name: "ShowBars" + when: view.movingVertically || view.movingHorizontally + PropertyChanges { target: verticalScrollBar; opacity: 1 } + PropertyChanges { target: horizontalScrollBar; opacity: 1 } + } + + transitions: Transition { + NumberAnimation { properties: "opacity"; duration: 400 } + } + } + + // Attach scrollbars to the right and bottom edges of the view. + ScrollBar { + id: verticalScrollBar + width: 12; height: view.height-12 + anchors.right: view.right + opacity: 0 + orientation: Qt.Vertical + position: view.visibleArea.yPosition + pageSize: view.visibleArea.heightRatio + } + + ScrollBar { + id: horizontalScrollBar + width: view.width-12; height: 12 + anchors.bottom: view.bottom + opacity: 0 + orientation: Qt.Horizontal + position: view.visibleArea.xPosition + pageSize: view.visibleArea.widthRatio + } +} diff --git a/examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpg b/examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpg new file mode 100644 index 0000000000..e625c0d3e6 Binary files /dev/null and b/examples/tutorials/ui-components/scrollbar/pics/niagara_falls.jpg differ diff --git a/examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject b/examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/tutorials/ui-components/scrollbar/scrollbar.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/tutorials/ui-components/searchbox/SearchBox.qml b/examples/tutorials/ui-components/searchbox/SearchBox.qml new file mode 100644 index 0000000000..6f6f486412 --- /dev/null +++ b/examples/tutorials/ui-components/searchbox/SearchBox.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +FocusScope { + id: focusScope + width: 250; height: 28 + + BorderImage { + source: "images/lineedit-bg.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + } + + BorderImage { + source: "images/lineedit-bg-focus.png" + width: parent.width; height: parent.height + border { left: 4; top: 4; right: 4; bottom: 4 } + visible: parent.activeFocus ? true : false + } + + Text { + id: typeSomething + anchors.fill: parent; anchors.leftMargin: 8 + verticalAlignment: Text.AlignVCenter + text: "Type something..." + color: "gray" + font.italic: true + } + + MouseArea { + anchors.fill: parent + onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); } + } + + TextInput { + id: textInput + anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter } + focus: true + selectByMouse: true + } + + Image { + id: clear + anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter } + source: "images/clear.png" + opacity: 0 + + MouseArea { + anchors.fill: parent + onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); } + } + } + + states: State { + name: "hasText"; when: textInput.text != '' + PropertyChanges { target: typeSomething; opacity: 0 } + PropertyChanges { target: clear; opacity: 1 } + } + + transitions: [ + Transition { + from: ""; to: "hasText" + NumberAnimation { exclude: typeSomething; properties: "opacity" } + }, + Transition { + from: "hasText"; to: "" + NumberAnimation { properties: "opacity" } + } + ] +} diff --git a/examples/tutorials/ui-components/searchbox/images/clear.png b/examples/tutorials/ui-components/searchbox/images/clear.png new file mode 100644 index 0000000000..91eb270695 Binary files /dev/null and b/examples/tutorials/ui-components/searchbox/images/clear.png differ diff --git a/examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.png new file mode 100644 index 0000000000..bbfac38d2d Binary files /dev/null and b/examples/tutorials/ui-components/searchbox/images/lineedit-bg-focus.png differ diff --git a/examples/tutorials/ui-components/searchbox/images/lineedit-bg.png b/examples/tutorials/ui-components/searchbox/images/lineedit-bg.png new file mode 100644 index 0000000000..9044226f85 Binary files /dev/null and b/examples/tutorials/ui-components/searchbox/images/lineedit-bg.png differ diff --git a/examples/tutorials/ui-components/searchbox/main.qml b/examples/tutorials/ui-components/searchbox/main.qml new file mode 100644 index 0000000000..6e9731cf9c --- /dev/null +++ b/examples/tutorials/ui-components/searchbox/main.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + width: 500; height: 250 + color: "#edecec" + + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } + Column { + anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } + spacing: 10 + + SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } + SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } + SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } + } +} diff --git a/examples/tutorials/ui-components/searchbox/searchbox.qmlproject b/examples/tutorials/ui-components/searchbox/searchbox.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/tutorials/ui-components/searchbox/searchbox.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/tutorials/ui-components/slideswitch/content/Switch.qml b/examples/tutorials/ui-components/slideswitch/content/Switch.qml new file mode 100644 index 0000000000..981fc16673 --- /dev/null +++ b/examples/tutorials/ui-components/slideswitch/content/Switch.qml @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: toggleswitch + width: background.width; height: background.height + +//![1] + property bool on: false +//![1] + +//![2] + function toggle() { + if (toggleswitch.state == "on") + toggleswitch.state = "off"; + else + toggleswitch.state = "on"; + } +//![2] + +//![3] + function releaseSwitch() { + if (knob.x == 1) { + if (toggleswitch.state == "off") return; + } + if (knob.x == 78) { + if (toggleswitch.state == "on") return; + } + toggle(); + } +//![3] + +//![4] + Image { + id: background + source: "background.png" + MouseArea { anchors.fill: parent; onClicked: toggle() } + } +//![4] + +//![5] + Image { + id: knob + x: 1; y: 2 + source: "knob.png" + + MouseArea { + anchors.fill: parent + drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78 + onClicked: toggle() + onReleased: releaseSwitch() + } + } +//![5] + +//![6] + states: [ + State { + name: "on" + PropertyChanges { target: knob; x: 78 } + PropertyChanges { target: toggleswitch; on: true } + }, + State { + name: "off" + PropertyChanges { target: knob; x: 1 } + PropertyChanges { target: toggleswitch; on: false } + } + ] +//![6] + +//![7] + transitions: Transition { + NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 } + } +//![7] +} +//![0] diff --git a/examples/tutorials/ui-components/slideswitch/content/background.png b/examples/tutorials/ui-components/slideswitch/content/background.png new file mode 100644 index 0000000000..d736815870 Binary files /dev/null and b/examples/tutorials/ui-components/slideswitch/content/background.png differ diff --git a/examples/tutorials/ui-components/slideswitch/content/background.svg b/examples/tutorials/ui-components/slideswitch/content/background.svg new file mode 100644 index 0000000000..f920d3e47a --- /dev/null +++ b/examples/tutorials/ui-components/slideswitch/content/background.svg @@ -0,0 +1,23 @@ + + + +]> + + + + + + + + + + + + + + diff --git a/examples/tutorials/ui-components/slideswitch/content/knob.png b/examples/tutorials/ui-components/slideswitch/content/knob.png new file mode 100644 index 0000000000..ee0a436f84 Binary files /dev/null and b/examples/tutorials/ui-components/slideswitch/content/knob.png differ diff --git a/examples/tutorials/ui-components/slideswitch/content/knob.svg b/examples/tutorials/ui-components/slideswitch/content/knob.svg new file mode 100644 index 0000000000..fb6933718e --- /dev/null +++ b/examples/tutorials/ui-components/slideswitch/content/knob.svg @@ -0,0 +1,867 @@ + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/tutorials/ui-components/slideswitch/slideswitch.qml b/examples/tutorials/ui-components/slideswitch/slideswitch.qml new file mode 100644 index 0000000000..60a331407c --- /dev/null +++ b/examples/tutorials/ui-components/slideswitch/slideswitch.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + color: "white" + width: 400; height: 250 + +//![0] + Switch { anchors.centerIn: parent; on: false } +//![0] +} diff --git a/examples/tutorials/ui-components/spinner/content/Spinner.qml b/examples/tutorials/ui-components/spinner/content/Spinner.qml new file mode 100644 index 0000000000..d7bbeb33ee --- /dev/null +++ b/examples/tutorials/ui-components/spinner/content/Spinner.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + property alias model: view.model + property alias delegate: view.delegate + property alias currentIndex: view.currentIndex + property real itemHeight: 30 + + source: "spinner-bg.png" + clip: true + + PathView { + id: view + anchors.fill: parent + + pathItemCount: height/itemHeight + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } + dragMargin: view.width/2 + + path: Path { + startX: view.width/2; startY: -itemHeight/2 + PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } + } + } + + Keys.onDownPressed: view.incrementCurrentIndex() + Keys.onUpPressed: view.decrementCurrentIndex() +} diff --git a/examples/tutorials/ui-components/spinner/content/spinner-bg.png b/examples/tutorials/ui-components/spinner/content/spinner-bg.png new file mode 100644 index 0000000000..b3556f1f9f Binary files /dev/null and b/examples/tutorials/ui-components/spinner/content/spinner-bg.png differ diff --git a/examples/tutorials/ui-components/spinner/content/spinner-select.png b/examples/tutorials/ui-components/spinner/content/spinner-select.png new file mode 100644 index 0000000000..95a17a1fe2 Binary files /dev/null and b/examples/tutorials/ui-components/spinner/content/spinner-select.png differ diff --git a/examples/tutorials/ui-components/spinner/main.qml b/examples/tutorials/ui-components/spinner/main.qml new file mode 100644 index 0000000000..7584c98396 --- /dev/null +++ b/examples/tutorials/ui-components/spinner/main.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 240; height: 320 + + Column { + y: 20; x: 20; spacing: 20 + + Spinner { + id: spinner + width: 200; height: 240 + focus: true + model: 20 + itemHeight: 30 + delegate: Text { font.pixelSize: 25; text: index; height: 30 } + } + + Text { text: "Current item index: " + spinner.currentIndex } + } +} diff --git a/examples/tutorials/ui-components/spinner/spinner.qmlproject b/examples/tutorials/ui-components/spinner/spinner.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/tutorials/ui-components/spinner/spinner.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/tutorials/ui-components/tabwidget/TabWidget.qml b/examples/tutorials/ui-components/tabwidget/TabWidget.qml new file mode 100644 index 0000000000..560ed1f58a --- /dev/null +++ b/examples/tutorials/ui-components/tabwidget/TabWidget.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: tabWidget + + // Setting the default property to stack.children means any child items + // of the TabWidget are actually added to the 'stack' item's children. + // See the "Property Binding" + // documentation for details on default properties. + default property alias content: stack.children + + property int current: 0 + + onCurrentChanged: setOpacities() + Component.onCompleted: setOpacities() + + function setOpacities() { + for (var i = 0; i < stack.children.length; ++i) { + stack.children[i].opacity = (i == current ? 1 : 0) + } + } + + Row { + id: header + + Repeater { + model: stack.children.length + delegate: Rectangle { + width: tabWidget.width / stack.children.length; height: 36 + + Rectangle { + width: parent.width; height: 1 + anchors { bottom: parent.bottom; bottomMargin: 1 } + color: "#acb2c2" + } + BorderImage { + anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } + border { left: 7; right: 7 } + source: "tab.png" + visible: tabWidget.current == index + } + Text { + horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter + anchors.fill: parent + text: stack.children[index].title + elide: Text.ElideRight + font.bold: tabWidget.current == index + } + MouseArea { + anchors.fill: parent + onClicked: tabWidget.current = index + } + } + } + } + + Item { + id: stack + width: tabWidget.width + anchors.top: header.bottom; anchors.bottom: tabWidget.bottom + } +} diff --git a/examples/tutorials/ui-components/tabwidget/main.qml b/examples/tutorials/ui-components/tabwidget/main.qml new file mode 100644 index 0000000000..df99c11b7d --- /dev/null +++ b/examples/tutorials/ui-components/tabwidget/main.qml @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +TabWidget { + id: tabs + width: 640; height: 480 + + Rectangle { + property string title: "Red" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#ff7f7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Roses are red" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Green" + anchors.fill: parent + color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#7fff7f" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Flower stems are green" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } + + Rectangle { + property string title: "Blue" + anchors.fill: parent; color: "#e3e3e3" + + Rectangle { + anchors.fill: parent; anchors.margins: 20 + color: "#7f7fff" + Text { + width: parent.width - 20 + anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter + text: "Violets are blue" + font.pixelSize: 20 + wrapMode: Text.WordWrap + } + } + } +} diff --git a/examples/tutorials/ui-components/tabwidget/tab.png b/examples/tutorials/ui-components/tabwidget/tab.png new file mode 100644 index 0000000000..ad8021605f Binary files /dev/null and b/examples/tutorials/ui-components/tabwidget/tab.png differ diff --git a/examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject b/examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject new file mode 100644 index 0000000000..e5a8bf02ca --- /dev/null +++ b/examples/tutorials/ui-components/tabwidget/tabwidget.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "main.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/window/Window.qml b/examples/window/Window.qml new file mode 100644 index 0000000000..48478458c6 --- /dev/null +++ b/examples/window/Window.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Window.Window { + width: 640 + height: 480 + visible: true //It's false by default + property Component self + Component.onCompleted: self = Qt.createComponent("Window.qml") + Text{ + text: "Hello World!" + anchors.centerIn: parent + } + MouseArea{ + anchors.fill: parent + onClicked: self.createObject(); + } +} diff --git a/examples/window/screen/screenInfo.qml b/examples/window/screen/screenInfo.qml new file mode 100644 index 0000000000..54299ba4e0 --- /dev/null +++ b/examples/window/screen/screenInfo.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Item { + id: root + width: 400 + height: 200 + Item { + id: main + state: "orientation " + Window.Screen.orientation + + property bool landscapeWindow: Window.Screen.primaryOrientation == Qt.LandscapeOrientation + property real baseWidth: landscapeWindow ? root.height : root.width + property real baseHeight: landscapeWindow ? root.width : root.height + property real rotationDelta: landscapeWindow ? -90 : 0 + + rotation: rotationDelta + width: main.baseWidth + height: main.baseHeight + anchors.centerIn: parent + + Text { + text: "Screen is " + Window.Screen.width + "x" + Window.Screen.height + " and primarily orientation " + Window.Screen.primaryOrientation + anchors.centerIn:parent + } + + + states: [ + State { + name: "orientation " + Qt.LandscapeOrientation + PropertyChanges { target: main; rotation: 90 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + }, + State { + name: "orientation " + Qt.InvertedPortraitOrientation + PropertyChanges { target: main; rotation: 180 + rotationDelta; } + }, + State { + name: "orientation " + Qt.InvertedLandscapeOrientation + PropertyChanges { target: main; rotation: 270 + rotationDelta; width: main.baseHeight; height: main.baseWidth } + } + ] + + transitions: Transition { + SequentialAnimation { + RotationAnimation { direction: RotationAnimation.Shortest; duration: 300; easing.type: Easing.InOutQuint } + NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: Easing.InOutQuint } + } + } + } +} diff --git a/examples/window/standalone.qml b/examples/window/standalone.qml new file mode 100644 index 0000000000..335cf7b635 --- /dev/null +++ b/examples/window/standalone.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 as Window + +Item { + width: 640 + height: 480 + Text { + anchors.centerIn: parent + text: "First Window" + } + MouseArea { + anchors.fill: parent + onClicked: Qt.quit() + } + Window.Window { + width: 640 + height: 480 + x: 640 + y: 480 + visible: true + color: "green" + Text { + anchors.centerIn: parent + text: "Second Window" + } + MouseArea{ + anchors.fill: parent + onClicked: Qt.quit() + } + } +} diff --git a/examples/window/window.cpp b/examples/window/window.cpp new file mode 100644 index 0000000000..4854256190 --- /dev/null +++ b/examples/window/window.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc, argv); + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine); + component.loadUrl(QUrl::fromLocalFile("Window.qml")); + if ( component.isReady() ) + component.create(); + else + qWarning() << component.errorString(); + return app.exec(); +} diff --git a/examples/window/window.pro b/examples/window/window.pro new file mode 100644 index 0000000000..74804bd776 --- /dev/null +++ b/examples/window/window.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +CONFIG += qt +QT += declarative + +SOURCES += window.cpp diff --git a/tests/auto/qtquick2/examples/tst_examples.cpp b/tests/auto/qtquick2/examples/tst_examples.cpp index 0e420f7277..ce8f214efd 100644 --- a/tests/auto/qtquick2/examples/tst_examples.cpp +++ b/tests/auto/qtquick2/examples/tst_examples.cpp @@ -89,32 +89,25 @@ tst_examples::tst_examples() excludedFiles << "doc/src/snippets/declarative/listmodel.qml"; //Just a ListModel, no root QQuickItem // Add directories you want excluded here - excludedDirs << "examples/declarative/text/fonts"; // QTBUG-21415 + excludedDirs << "examples/shared"; //Not an example + excludedDirs << "examples/qtquick/text/fonts"; // QTBUG-21415 excludedDirs << "doc/src/snippets/declarative/path"; //No root QQuickItem - // Not run in QQuickView - excludedDirs << "examples/declarative/qtquick1"; - // These snippets are not expected to run on their own. excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex"; excludedDirs << "doc/src/snippets/declarative/qtbinding"; excludedDirs << "doc/src/snippets/declarative/imports"; - excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex"; - excludedDirs << "doc/src/snippets/qtquick1/qtbinding"; - excludedDirs << "doc/src/snippets/qtquick1/imports"; #ifdef QT_NO_WEBKIT - excludedDirs << "examples/declarative/modelviews/webview"; - excludedDirs << "examples/declarative/webbrowser"; + excludedDirs << "examples/qtquick/modelviews/webview"; + excludedDirs << "examples/demos/webbrowser"; excludedDirs << "doc/src/snippets/declarative/webview"; - excludedDirs << "doc/src/snippets/qtquick1/webview"; #endif #ifdef QT_NO_XMLPATTERNS - excludedDirs << "examples/declarative/xml/xmldata"; - excludedDirs << "examples/declarative/twitter"; - excludedDirs << "examples/declarative/flickr"; - excludedDirs << "examples/declarative/photoviewer"; + excludedDirs << "examples/demos/twitter"; + excludedDirs << "examples/demos/flickr"; + excludedDirs << "examples/demos/photoviewer"; #endif } @@ -230,12 +223,10 @@ void tst_examples::sgexamples_data() { QTest::addColumn("file"); - QString examples = QLatin1String(SRCDIR) + "/../../../../examples/declarative/"; - QString tutorials = QLatin1String(SRCDIR) + "/../../../../examples/tutorials/"; //Only declarative tutorials since modularization + QString examples = QLatin1String(SRCDIR) + "/../../../../examples/"; QStringList files; files << findQmlFiles(QDir(examples)); - files << findQmlFiles(QDir(tutorials)); foreach (const QString &file, files) QTest::newRow(qPrintable(file)) << file; -- cgit v1.2.3 From 5cc9b79675c9d1e17e0153ca2ddf42771a09cfe3 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 24 Feb 2012 07:28:54 +0100 Subject: Revert resource releasing logic inside window managers. This was based on the assumption that exposure and visibility would take similar code paths, but this is not the case and the fallout of this change (like not releasing resources at all) is not worth it. This reverts ef6318ae38322b5a4a0619b581924290f114fa74 and most of 5f0013ee76605b9c7ceab168702b57e797b698e0 Change-Id: Ib2e29972502a8ec956cd6bd294a2a2bb50d8e76e Reviewed-by: Alan Alpert --- src/quick/items/qquickwindowmanager.cpp | 154 ++++++++------------------------ src/quick/items/qquickwindowmanager_p.h | 2 + 2 files changed, 39 insertions(+), 117 deletions(-) diff --git a/src/quick/items/qquickwindowmanager.cpp b/src/quick/items/qquickwindowmanager.cpp index b999e6f85d..16b6d92e22 100644 --- a/src/quick/items/qquickwindowmanager.cpp +++ b/src/quick/items/qquickwindowmanager.cpp @@ -48,8 +48,8 @@ #include #include -#include #include +#include #include @@ -145,6 +145,10 @@ DEFINE_BOOL_CONFIG_OPTION(qmlNoThreadedRenderer, QML_BAD_GUI_RENDER_LOOP); //#define THREAD_DEBUG +QQuickWindowManager::~QQuickWindowManager() +{ +} + class QQuickRenderThreadSingleContextWindowManager : public QThread, public QQuickWindowManager { Q_OBJECT @@ -165,7 +169,6 @@ public: , shouldExit(false) , hasExited(false) , isDeferredUpdatePosted(false) - , runToReleaseResources(false) , canvasToGrab(0) { sg->moveToThread(this); @@ -176,13 +179,10 @@ public: connect(animationDriver, SIGNAL(stopped()), this, SLOT(animationStopped())); } - ~QQuickRenderThreadSingleContextWindowManager() - { - releaseResources(); - } - QSGContext *sceneGraphContext() const { return sg; } + void releaseResources() { } + void show(QQuickCanvas *canvas); void hide(QQuickCanvas *canvas); @@ -201,8 +201,6 @@ public: void sync(bool guiAlreadyLocked); void initialize(); - void releaseResources(); - void releaseResourcesInThread(); bool *allowMainThreadProcessing() { return &allowMainThreadProcessingFlag; } @@ -258,7 +256,6 @@ private: uint shouldExit : 1; uint hasExited : 1; uint isDeferredUpdatePosted : 1; - uint runToReleaseResources : 1; QQuickCanvas *canvasToGrab; QImage grabContent; @@ -291,17 +288,12 @@ class QQuickTrivialWindowManager : public QObject, public QQuickWindowManager { public: QQuickTrivialWindowManager(); - ~QQuickTrivialWindowManager() - { - releaseResources(); - } void show(QQuickCanvas *canvas); void hide(QQuickCanvas *canvas); void canvasDestroyed(QQuickCanvas *canvas); - void releaseResources(); void initializeGL(); void renderCanvas(QQuickCanvas *canvas); void paint(QQuickCanvas *canvas); @@ -310,10 +302,11 @@ public: void maybeUpdate(QQuickCanvas *canvas); + void releaseResources() { } + bool *allowMainThreadProcessing(); QSGContext *sceneGraphContext() const; - QQuickCanvas *masterCanvas() const; bool event(QEvent *); @@ -564,18 +557,10 @@ void QQuickRenderThreadSingleContextWindowManager::run() #ifdef THREAD_DEBUG printf("QML Rendering Thread Started\n"); #endif - lock(); - - if (runToReleaseResources) { - releaseResourcesInThread(); - runToReleaseResources = false; - unlock(); - return; - } - - if (!gl) - initialize(); + lock(); + Q_ASSERT(!gl); + initialize(); // Wake GUI as it is waiting for the GL context to have appeared, as // an indication that the render thread is now running. wake(); @@ -772,6 +757,12 @@ void QQuickRenderThreadSingleContextWindowManager::run() m_removed_windows << m_rendered_windows.keys(); handleRemovedWindows(); + sg->invalidate(); + + gl->doneCurrent(); + delete gl; + gl = 0; + #ifdef THREAD_DEBUG printf(" RenderThread: render loop exited... Good Night!\n"); #endif @@ -790,59 +781,6 @@ void QQuickRenderThreadSingleContextWindowManager::run() #endif } -void QQuickRenderThreadSingleContextWindowManager::releaseResourcesInThread() -{ -#ifdef THREAD_DEBUG - printf(" RenderThread: releasing resources...\n"); -#endif - QQuickCanvas *canvas = masterCanvas(); - QWindow *tmpSurface = 0; - - if (canvas) { - gl->makeCurrent(canvas); - } else { - tmpSurface = new QWindow(); - tmpSurface->setSurfaceType(QSurface::OpenGLSurface); - tmpSurface->resize(4, 4); - tmpSurface->create(); - gl->makeCurrent(tmpSurface); - } - - sg->invalidate(); - gl->doneCurrent(); - delete gl; - gl = 0; - - if (tmpSurface) - delete tmpSurface; - - wake(); -} - -void QQuickRenderThreadSingleContextWindowManager::releaseResources() -{ -#ifdef THREAD_DEBUG - printf("GUI: releasing resources\n"); -#endif - - lockInGui(); - if (!isRunning() && gl) { - runToReleaseResources = true; - start(); - - while (isRunning()) { - wait(); - } - } -#ifdef THREAD_DEBUG - else { - printf("GUI: render thread running not releasing resources...\n"); - } -#endif - unlockInGui(); - -} - bool QQuickRenderThreadSingleContextWindowManager::event(QEvent *e) { Q_ASSERT(QThread::currentThread() == qApp->thread()); @@ -1074,6 +1012,7 @@ void QQuickRenderThreadSingleContextWindowManager::startRendering() animationTimer = -1; } + } @@ -1216,46 +1155,17 @@ void QQuickTrivialWindowManager::hide(QQuickCanvas *canvas) m_windows.remove(canvas); QQuickCanvasPrivate *cd = QQuickCanvasPrivate::get(canvas); cd->cleanupNodesOnShutdown(); -} - -void QQuickTrivialWindowManager::canvasDestroyed(QQuickCanvas *canvas) -{ - hide(canvas); -} - -void QQuickTrivialWindowManager::releaseResources() -{ - if (m_windows.size() == 0 && gl) { - QQuickCanvas *canvas = masterCanvas(); - QWindow *tmpSurface = 0; - - if (canvas) { - gl->makeCurrent(canvas); - } else { - tmpSurface = new QWindow(); - tmpSurface->setSurfaceType(QSurface::OpenGLSurface); - tmpSurface->resize(4, 4); - tmpSurface->create(); - gl->makeCurrent(tmpSurface); - } + if (m_windows.size() == 0) { sg->invalidate(); delete gl; gl = 0; - - delete tmpSurface; } } -QQuickCanvas *QQuickTrivialWindowManager::masterCanvas() const +void QQuickTrivialWindowManager::canvasDestroyed(QQuickCanvas *canvas) { - // Find a "proper surface" to bind... - for (QHash::const_iterator it = m_windows.constBegin(); - it != m_windows.constEnd(); ++it) { - if (it.key()->visible()) - return it.key(); - } - return 0; + hide(canvas); } void QQuickTrivialWindowManager::renderCanvas(QQuickCanvas *canvas) @@ -1265,20 +1175,30 @@ void QQuickTrivialWindowManager::renderCanvas(QQuickCanvas *canvas) CanvasData &data = const_cast(m_windows[canvas]); - QQuickCanvas *window = canvas->visible() ? canvas : masterCanvas(); + QQuickCanvas *masterCanvas = 0; + if (!canvas->visible()) { + // Find a "proper surface" to bind... + for (QHash::const_iterator it = m_windows.constBegin(); + it != m_windows.constEnd() && !masterCanvas; ++it) { + if (it.key()->visible()) + masterCanvas = it.key(); + } + } else { + masterCanvas = canvas; + } - if (!window) + if (!masterCanvas) return; if (!gl) { gl = new QOpenGLContext(); - gl->setFormat(window->requestedFormat()); + gl->setFormat(masterCanvas->requestedFormat()); gl->create(); - if (!gl->makeCurrent(window)) + if (!gl->makeCurrent(masterCanvas)) qWarning("QQuickCanvas: makeCurrent() failed..."); sg->initialize(gl); } else { - gl->makeCurrent(window); + gl->makeCurrent(masterCanvas); } bool alsoSwap = data.updatePending; diff --git a/src/quick/items/qquickwindowmanager_p.h b/src/quick/items/qquickwindowmanager_p.h index 014b38132e..86312655b3 100644 --- a/src/quick/items/qquickwindowmanager_p.h +++ b/src/quick/items/qquickwindowmanager_p.h @@ -52,6 +52,8 @@ class QSGContext; class QQuickWindowManager { public: + virtual ~QQuickWindowManager(); + virtual void show(QQuickCanvas *canvas) = 0; virtual void hide(QQuickCanvas *canvas) = 0; -- cgit v1.2.3 From 17790b069d5ce4ec4ca31f7ff1f00b268ddc0e29 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 24 Feb 2012 12:23:51 +0100 Subject: The plugin is cleaned up by the plugin loader so don't double-delete MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8bac5b6e1960cbc38575c76f02aa6c6c90700331 Reviewed-by: Samuel Rødal --- src/quick/scenegraph/qsgcontextplugin.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/quick/scenegraph/qsgcontextplugin.cpp b/src/quick/scenegraph/qsgcontextplugin.cpp index 026afb2d56..6382d42462 100644 --- a/src/quick/scenegraph/qsgcontextplugin.cpp +++ b/src/quick/scenegraph/qsgcontextplugin.cpp @@ -71,7 +71,6 @@ struct QSGAdaptionPluginData ~QSGAdaptionPluginData() { - delete factory; } bool tried; @@ -102,15 +101,15 @@ QSGAdaptionPluginData *contextFactory() if (!device.isEmpty()) { plugin->factory = qobject_cast(loader()->instance(device)); plugin->deviceName = device; - } #ifndef QT_NO_DEBUG - if (!device.isEmpty()) { - qWarning("Could not create scene graph context for device '%s'" - " - check that plugins are installed correctly in %s", - qPrintable(device), - qPrintable(QLibraryInfo::location(QLibraryInfo::PluginsPath))); - } + if (!plugin->factory) { + qWarning("Could not create scene graph context for device '%s'" + " - check that plugins are installed correctly in %s", + qPrintable(device), + qPrintable(QLibraryInfo::location(QLibraryInfo::PluginsPath))); + } #endif + } #endif // QT_NO_LIBRARY || QT_NO_SETTINGS } -- cgit v1.2.3 From a8929f5d300b73d6dacdc47e85401f3b9f6a1bf8 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 24 Feb 2012 13:22:31 +0000 Subject: Update license headers Change-Id: Id47c6b26ee2ac2b3d30c464adaa55b7a7c3e4442 Reviewed-by: Kent Hansen --- src/declarative/qml/v8/qjsconverter_p.h | 38 ++++++++++++++------ src/declarative/qml/v8/qjsengine.h | 38 ++++++++++++++------ src/declarative/qml/v8/qjsengine_p.h | 40 ++++++++++++++++------ src/declarative/qml/v8/qjsvalue.h | 38 ++++++++++++++------ src/declarative/qml/v8/qjsvalue_impl_p.h | 38 ++++++++++++++------ src/declarative/qml/v8/qjsvalue_p.h | 38 ++++++++++++++------ src/declarative/qml/v8/qjsvalueiterator.h | 40 ++++++++++++++++------ src/declarative/qml/v8/qjsvalueiterator_impl_p.h | 36 ++++++++++++++----- src/declarative/qml/v8/qjsvalueiterator_p.h | 36 ++++++++++++++----- src/declarative/qml/v8/qscript_impl_p.h | 40 ++++++++++++++++------ src/declarative/qml/v8/qscriptisolate_p.h | 38 ++++++++++++++------ .../qml/v8/qscriptoriginalglobalobject_p.h | 38 ++++++++++++++------ src/declarative/qml/v8/qscriptshareddata_p.h | 38 ++++++++++++++------ src/declarative/qml/v8/qscripttools_p.h | 38 ++++++++++++++------ src/declarative/qml/v8/qv8engine_impl_p.h | 36 ++++++++++++++----- 15 files changed, 420 insertions(+), 150 deletions(-) diff --git a/src/declarative/qml/v8/qjsconverter_p.h b/src/declarative/qml/v8/qjsconverter_p.h index 29fef3c700..12ec9350e4 100644 --- a/src/declarative/qml/v8/qjsconverter_p.h +++ b/src/declarative/qml/v8/qjsconverter_p.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qjsengine.h b/src/declarative/qml/v8/qjsengine.h index 94c4dffde4..884435f4e2 100644 --- a/src/declarative/qml/v8/qjsengine.h +++ b/src/declarative/qml/v8/qjsengine.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qjsengine_p.h b/src/declarative/qml/v8/qjsengine_p.h index ecd5f7cc86..fb66e94499 100644 --- a/src/declarative/qml/v8/qjsengine_p.h +++ b/src/declarative/qml/v8/qjsengine_p.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qjsvalue.h b/src/declarative/qml/v8/qjsvalue.h index 07fe3dcfac..5d915db9af 100644 --- a/src/declarative/qml/v8/qjsvalue.h +++ b/src/declarative/qml/v8/qjsvalue.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qjsvalue_impl_p.h b/src/declarative/qml/v8/qjsvalue_impl_p.h index cd33859c50..0b0cd0759a 100644 --- a/src/declarative/qml/v8/qjsvalue_impl_p.h +++ b/src/declarative/qml/v8/qjsvalue_impl_p.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qjsvalue_p.h b/src/declarative/qml/v8/qjsvalue_p.h index 3eccba64bd..3275f47b85 100644 --- a/src/declarative/qml/v8/qjsvalue_p.h +++ b/src/declarative/qml/v8/qjsvalue_p.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qjsvalueiterator.h b/src/declarative/qml/v8/qjsvalueiterator.h index 5f5446430e..5e2c3d4561 100644 --- a/src/declarative/qml/v8/qjsvalueiterator.h +++ b/src/declarative/qml/v8/qjsvalueiterator.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qjsvalueiterator_impl_p.h b/src/declarative/qml/v8/qjsvalueiterator_impl_p.h index 40814b1969..9a265e8d48 100644 --- a/src/declarative/qml/v8/qjsvalueiterator_impl_p.h +++ b/src/declarative/qml/v8/qjsvalueiterator_impl_p.h @@ -5,17 +5,35 @@ ** ** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qjsvalueiterator_p.h b/src/declarative/qml/v8/qjsvalueiterator_p.h index d1869506e9..1bfa5cb165 100644 --- a/src/declarative/qml/v8/qjsvalueiterator_p.h +++ b/src/declarative/qml/v8/qjsvalueiterator_p.h @@ -5,17 +5,35 @@ ** ** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qscript_impl_p.h b/src/declarative/qml/v8/qscript_impl_p.h index fdbf2f0097..1868fbc0de 100644 --- a/src/declarative/qml/v8/qscript_impl_p.h +++ b/src/declarative/qml/v8/qscript_impl_p.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qscriptisolate_p.h b/src/declarative/qml/v8/qscriptisolate_p.h index 4afa74756f..9adce9f8ab 100644 --- a/src/declarative/qml/v8/qscriptisolate_p.h +++ b/src/declarative/qml/v8/qscriptisolate_p.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qscriptoriginalglobalobject_p.h b/src/declarative/qml/v8/qscriptoriginalglobalobject_p.h index 12321cc71a..9a656a4ca1 100644 --- a/src/declarative/qml/v8/qscriptoriginalglobalobject_p.h +++ b/src/declarative/qml/v8/qscriptoriginalglobalobject_p.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qscriptshareddata_p.h b/src/declarative/qml/v8/qscriptshareddata_p.h index df95b26206..4dd56798f1 100644 --- a/src/declarative/qml/v8/qscriptshareddata_p.h +++ b/src/declarative/qml/v8/qscriptshareddata_p.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qscripttools_p.h b/src/declarative/qml/v8/qscripttools_p.h index fcea205f61..5b142d3900 100644 --- a/src/declarative/qml/v8/qscripttools_p.h +++ b/src/declarative/qml/v8/qscripttools_p.h @@ -3,19 +3,37 @@ ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** -** This file is part of the QtScript module of the Qt Toolkit. +** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** diff --git a/src/declarative/qml/v8/qv8engine_impl_p.h b/src/declarative/qml/v8/qv8engine_impl_p.h index 349589680a..ea8a0b1076 100644 --- a/src/declarative/qml/v8/qv8engine_impl_p.h +++ b/src/declarative/qml/v8/qv8engine_impl_p.h @@ -5,17 +5,35 @@ ** ** This file is part of the QtDeclarative module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL-ONLY$ +** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** ** -** If you have questions regarding the use of this file, please contact -** us via http://www.qt-project.org/. ** ** $QT_END_LICENSE$ ** -- cgit v1.2.3 From 4a170793828a7cc6ee29443d6b312551b29363a3 Mon Sep 17 00:00:00 2001 From: Yuchen Deng Date: Wed, 15 Feb 2012 08:31:48 +0800 Subject: Build fix when use '-no-stl' option error C3861: 'toupper': identifier not found error C2065: 'RAND_MAX' : undeclared identifier error C3861: 'rand': identifier not found error C2065: 'RAND_MAX' : undeclared identifier error C3861: 'rand': identifier not found Change-Id: Iaa0daf516c3d9f90d9119f958d79187ee2bb959c Reviewed-by: Lars Knoll --- src/declarative/qml/qdeclarativepropertycache.cpp | 2 ++ src/quick/particles/qquickangledirection.cpp | 1 + src/quick/particles/qquickellipseextruder.cpp | 1 + src/quick/particles/qquicklineextruder.cpp | 1 + src/quick/particles/qquickparticleextruder.cpp | 1 + src/quick/particles/qquickpointdirection.cpp | 1 + src/quick/particles/qquickrectangleextruder.cpp | 1 + 7 files changed, 8 insertions(+) diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index c8bfd98363..2d7644a7a8 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -50,6 +50,8 @@ #include +#include // for toupper + Q_DECLARE_METATYPE(QJSValue) Q_DECLARE_METATYPE(QDeclarativeV8Handle); diff --git a/src/quick/particles/qquickangledirection.cpp b/src/quick/particles/qquickangledirection.cpp index 48fc5a8273..726b6fa404 100644 --- a/src/quick/particles/qquickangledirection.cpp +++ b/src/quick/particles/qquickangledirection.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qquickangledirection_p.h" +#include #include QT_BEGIN_NAMESPACE const qreal CONV = 0.017453292519943295; diff --git a/src/quick/particles/qquickellipseextruder.cpp b/src/quick/particles/qquickellipseextruder.cpp index 3b80810773..63ce5786c5 100644 --- a/src/quick/particles/qquickellipseextruder.cpp +++ b/src/quick/particles/qquickellipseextruder.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qquickellipseextruder_p.h" +#include #include QT_BEGIN_NAMESPACE /*! diff --git a/src/quick/particles/qquicklineextruder.cpp b/src/quick/particles/qquicklineextruder.cpp index c98ce8d76b..b034c5293c 100644 --- a/src/quick/particles/qquicklineextruder.cpp +++ b/src/quick/particles/qquicklineextruder.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include "qquicklineextruder_p.h" +#include #include /*! diff --git a/src/quick/particles/qquickparticleextruder.cpp b/src/quick/particles/qquickparticleextruder.cpp index f5605ef4d4..fc985b0c8e 100644 --- a/src/quick/particles/qquickparticleextruder.cpp +++ b/src/quick/particles/qquickparticleextruder.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qquickparticleextruder_p.h" +#include QT_BEGIN_NAMESPACE diff --git a/src/quick/particles/qquickpointdirection.cpp b/src/quick/particles/qquickpointdirection.cpp index 79c3365f86..6184170aae 100644 --- a/src/quick/particles/qquickpointdirection.cpp +++ b/src/quick/particles/qquickpointdirection.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qquickpointdirection_p.h" +#include QT_BEGIN_NAMESPACE diff --git a/src/quick/particles/qquickrectangleextruder.cpp b/src/quick/particles/qquickrectangleextruder.cpp index 777d0f66f0..4127956e65 100644 --- a/src/quick/particles/qquickrectangleextruder.cpp +++ b/src/quick/particles/qquickrectangleextruder.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qquickrectangleextruder_p.h" +#include QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 316ede158401c0e939cae817388a67b3303ac59d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 24 Feb 2012 09:46:35 +1000 Subject: Get script benchmark compiling and running. Change-Id: Ifc433f6c430d430bfb8b2d8b47a84ad2688e4cb2 Reviewed-by: Chris Adams --- .../script/data/signal_heavyArgsAccess.qml | 51 ++++ .../script/data/signal_heavyIdAccess.qml | 54 +++++ tests/benchmarks/declarative/script/script.pro | 3 +- tests/benchmarks/declarative/script/tst_script.cpp | 261 ++++++++++++--------- 4 files changed, 262 insertions(+), 107 deletions(-) create mode 100644 tests/benchmarks/declarative/script/data/signal_heavyArgsAccess.qml create mode 100644 tests/benchmarks/declarative/script/data/signal_heavyIdAccess.qml diff --git a/tests/benchmarks/declarative/script/data/signal_heavyArgsAccess.qml b/tests/benchmarks/declarative/script/data/signal_heavyArgsAccess.qml new file mode 100644 index 0000000000..a9675c333b --- /dev/null +++ b/tests/benchmarks/declarative/script/data/signal_heavyArgsAccess.qml @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 1.0 + +TestObject { + onMySignalWithArgs: { + var a = 0; + for (var i = 0; i < 10000; ++i) + a += n; + return a; + } +} diff --git a/tests/benchmarks/declarative/script/data/signal_heavyIdAccess.qml b/tests/benchmarks/declarative/script/data/signal_heavyIdAccess.qml new file mode 100644 index 0000000000..e426ee5116 --- /dev/null +++ b/tests/benchmarks/declarative/script/data/signal_heavyIdAccess.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import Qt.test 1.0 + +TestObject { + id: obj + property real inc: 3 + + onMySignalWithArgs: { + var a = 0; + for (var i = 0; i < 10000; ++i) + a += obj.inc; + return a; + } +} diff --git a/tests/benchmarks/declarative/script/script.pro b/tests/benchmarks/declarative/script/script.pro index 310d17d3c9..6b454beed5 100644 --- a/tests/benchmarks/declarative/script/script.pro +++ b/tests/benchmarks/declarative/script/script.pro @@ -1,10 +1,11 @@ CONFIG += testcase TEMPLATE = app TARGET = tst_script -QT += declarative testlib macx:CONFIG -= app_bundle CONFIG += release SOURCES += tst_script.cpp +QT += core-private gui-private v8-private declarative-private quick-private testlib + DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp index 0e5d782134..77a0d36d3a 100644 --- a/tests/benchmarks/declarative/script/tst_script.cpp +++ b/tests/benchmarks/declarative/script/tst_script.cpp @@ -43,10 +43,9 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include class tst_script : public QObject { @@ -58,10 +57,13 @@ private slots: void initTestCase(); void property_js(); - void property_getter(); void property_getter_js(); - void property_getter_qobject(); - void property_getter_qmetaproperty(); +#if 0 + //no native functions for now + void property_getter(); + void property_getter_qobject(); + void property_getter_qmetaproperty(); +#endif void property_qobject(); void property_qmlobject(); @@ -69,12 +71,18 @@ private slots: void setproperty_qmlobject(); void function_js(); +#if 0 + //no native functions for now void function_cpp(); +#endif void function_qobject(); void function_qmlobject(); void function_args_js(); +#if 0 + //no native functions for now void function_args_cpp(); +#endif void function_args_qobject(); void function_args_qmlobject(); @@ -82,6 +90,8 @@ private slots: void signal_qml(); void signal_args(); void signal_unusedArgs(); + void signal_heavyArgsAccess(); + void signal_heavyIdAccess(); void slot_simple(); void slot_simple_js(); @@ -144,7 +154,7 @@ TestObject::TestObject(QObject *parent) { } -int TestObject::x() +int TestObject::x() { return m_x++; } @@ -166,14 +176,14 @@ void tst_script::initTestCase() void tst_script::property_js() { - QScriptEngine engine; + QJSEngine engine; - QScriptValue v = engine.newObject(); + QJSValue v = engine.newObject(); v.setProperty(QLatin1String("x"), 10); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -181,23 +191,24 @@ void tst_script::property_js() } } -static QScriptValue property_getter_method(QScriptContext *, QScriptEngine *engine) +#if 0 +static QJSValue property_getter_method(QScriptContext *, QJSEngine *engine) { static int x = 0; - return QScriptValue(engine,x++); + return QJSValue(engine,x++); } void tst_script::property_getter() { - QScriptEngine engine; + QJSEngine engine; - QScriptValue v = engine.newObject(); - v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_method), - QScriptValue::PropertyGetter); + QJSValue v = engine.newObject(); + v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_method), + QJSValue::PropertyGetter); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -206,44 +217,44 @@ void tst_script::property_getter() } static TestObject *property_getter_qobject_object = 0; -static QScriptValue property_getter_qobject_method(QScriptContext *, QScriptEngine *) +static QJSValue property_getter_qobject_method(QScriptContext *, QJSEngine *) { static int idx = -1; - if (idx == -1) + if (idx == -1) idx = TestObject::staticMetaObject.indexOfProperty("x"); int value = 0; void *args[] = { &value, 0 }; QMetaObject::metacall(property_getter_qobject_object, QMetaObject::ReadProperty, idx, args); - return QScriptValue(value); + return QJSValue(value); } -static QScriptValue property_getter_qmetaproperty_method(QScriptContext *, QScriptEngine *) +static QJSValue property_getter_qmetaproperty_method(QScriptContext *, QJSEngine *) { static int idx = -1; - if (idx == -1) + if (idx == -1) idx = TestObject::staticMetaObject.indexOfProperty("x"); int value = 0; value = property_getter_qobject_object->metaObject()->property(idx).read(property_getter_qobject_object).toInt(); - return QScriptValue(value); + return QJSValue(value); } void tst_script::property_getter_qobject() { - QScriptEngine engine; + QJSEngine engine; TestObject to; property_getter_qobject_object = &to; - QScriptValue v = engine.newObject(); - v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qobject_method), - QScriptValue::PropertyGetter); + QJSValue v = engine.newObject(); + v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qobject_method), + QJSValue::PropertyGetter); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -254,17 +265,17 @@ void tst_script::property_getter_qobject() void tst_script::property_getter_qmetaproperty() { - QScriptEngine engine; + QJSEngine engine; TestObject to; property_getter_qobject_object = &to; - QScriptValue v = engine.newObject(); - v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qmetaproperty_method), - QScriptValue::PropertyGetter); + QJSValue v = engine.newObject(); + v.setProperty(QLatin1String("x"), engine.newFunction(property_getter_qmetaproperty_method), + QJSValue::PropertyGetter); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -272,17 +283,17 @@ void tst_script::property_getter_qmetaproperty() } property_getter_qobject_object = 0; } - +#endif void tst_script::property_getter_js() { - QScriptEngine engine; - - QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.__defineGetter__(\"x\", function() { return this._x++; }); return o; })").call(); + QJSEngine engine; + + QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.__defineGetter__(\"x\", function() { return this._x++; }); return o; })").call(); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -292,14 +303,14 @@ void tst_script::property_getter_js() void tst_script::property_qobject() { - QScriptEngine engine; + QJSEngine engine; TestObject to; - QScriptValue v = engine.newQObject(&to); + QJSValue v = engine.newQObject(&to); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(PROPERTY_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(PROPERTY_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -311,14 +322,15 @@ void tst_script::property_qmlobject() { QDeclarativeEngine qmlengine; - QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine); TestObject to; + QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(&qmlengine); + v8::HandleScope handle_scope; + v8::Context::Scope scope(engine->context()); + QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to)); - QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); - - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine->evaluate(PROPERTY_PROGRAM).call(engine->globalObject(), args); + QJSValue prog = qmlengine.evaluate(PROPERTY_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -335,14 +347,14 @@ void tst_script::property_qmlobject() void tst_script::setproperty_js() { - QScriptEngine engine; + QJSEngine engine; - QScriptValue v = engine.newObject(); + QJSValue v = engine.newObject(); v.setProperty(QLatin1String("x"), 0); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(SETPROPERTY_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(SETPROPERTY_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -354,14 +366,16 @@ void tst_script::setproperty_qmlobject() { QDeclarativeEngine qmlengine; - QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine); TestObject to; - QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); + QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(&qmlengine); + v8::HandleScope handle_scope; + v8::Context::Scope scope(engine->context()); + QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to)); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine->evaluate(SETPROPERTY_PROGRAM).call(engine->globalObject(), args); + QJSValue prog = qmlengine.evaluate(SETPROPERTY_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -380,13 +394,13 @@ void tst_script::setproperty_qmlobject() void tst_script::function_js() { - QScriptEngine engine; - - QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.method = (function() { return this._x++; }); return o; })").call(); + QJSEngine engine; + + QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.method = (function() { return this._x++; }); return o; })").call(); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -394,39 +408,41 @@ void tst_script::function_js() } } -static QScriptValue function_method(QScriptContext *, QScriptEngine *) +#if 0 +static QJSValue function_method(QScriptContext *, QJSEngine *) { static int x = 0; - return QScriptValue(x++); + return QJSValue(x++); } void tst_script::function_cpp() { - QScriptEngine engine; + QJSEngine engine; - QScriptValue v = engine.newObject(); + QJSValue v = engine.newObject(); v.setProperty(QLatin1String("method"), engine.newFunction(function_method)); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args); prog.call(); QBENCHMARK { prog.call(); } } +#endif void tst_script::function_qobject() { - QScriptEngine engine; + QJSEngine engine; TestObject to; - QScriptValue v = engine.newQObject(&to); + QJSValue v = engine.newQObject(&to); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(FUNCTION_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(FUNCTION_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -438,14 +454,16 @@ void tst_script::function_qmlobject() { QDeclarativeEngine qmlengine; - QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine); TestObject to; - QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); + QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(&qmlengine); + v8::HandleScope handle_scope; + v8::Context::Scope scope(engine->context()); + QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to)); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine->evaluate(FUNCTION_PROGRAM).call(engine->globalObject(), args); + QJSValue prog = qmlengine.evaluate(FUNCTION_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -464,13 +482,13 @@ void tst_script::function_qmlobject() void tst_script::function_args_js() { - QScriptEngine engine; - - QScriptValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.methodArgs = (function(a) { return a + this._x++; }); return o; })").call(); + QJSEngine engine; - QScriptValueList args; + QJSValue v = engine.evaluate("(function() { var o = new Object; o._x = 0; o.methodArgs = (function(a) { return a + this._x++; }); return o; })").call(); + + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -478,39 +496,41 @@ void tst_script::function_args_js() } } -static QScriptValue function_args_method(QScriptContext *ctxt, QScriptEngine *) +#if 0 +static QJSValue function_args_method(QScriptContext *ctxt, QJSEngine *) { static int x = 0; - return QScriptValue(ctxt->argument(0).toNumber() + x++); + return QJSValue(ctxt->argument(0).toNumber() + x++); } void tst_script::function_args_cpp() { - QScriptEngine engine; + QJSEngine engine; - QScriptValue v = engine.newObject(); + QJSValue v = engine.newObject(); v.setProperty(QLatin1String("methodArgs"), engine.newFunction(function_args_method)); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args); prog.call(); QBENCHMARK { prog.call(); } } +#endif void tst_script::function_args_qobject() { - QScriptEngine engine; + QJSEngine engine; TestObject to; - QScriptValue v = engine.newQObject(&to); + QJSValue v = engine.newQObject(&to); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(engine.globalObject(), args); + QJSValue prog = engine.evaluate(FUNCTION_ARGS_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -522,14 +542,16 @@ void tst_script::function_args_qmlobject() { QDeclarativeEngine qmlengine; - QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine); TestObject to; - QScriptValue v = QDeclarativeEnginePrivate::get(&qmlengine)->objectClass->newQObject(&to); + QV8Engine *engine = QDeclarativeEnginePrivate::getV8Engine(&qmlengine); + v8::HandleScope handle_scope; + v8::Context::Scope scope(engine->context()); + QJSValue v = engine->scriptValueFromInternal(engine->qobjectWrapper()->newQObject(&to)); - QScriptValueList args; + QJSValueList args; args << v; - QScriptValue prog = engine->evaluate(FUNCTION_ARGS_PROGRAM).call(engine->globalObject(), args); + QJSValue prog = qmlengine.evaluate(FUNCTION_ARGS_PROGRAM).call(args); prog.call(); QBENCHMARK { @@ -593,6 +615,34 @@ void tst_script::signal_unusedArgs() delete object; } +void tst_script::signal_heavyArgsAccess() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, TEST_FILE("signal_heavyArgsAccess.qml")); + TestObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignalWithArgs(11); + } + + delete object; +} + +void tst_script::signal_heavyIdAccess() +{ + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, TEST_FILE("signal_heavyIdAccess.qml")); + TestObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QBENCHMARK { + object->emitMySignalWithArgs(11); + } + + delete object; +} + void tst_script::slot_simple() { QDeclarativeEngine engine; @@ -662,7 +712,7 @@ void tst_script::block() QFETCH(QString, methodName); QDeclarativeEngine engine; QDeclarativeComponent component(&engine, TEST_FILE("block.qml")); - QDeclarativeRectangle *rect = qobject_cast(component.create()); + QQuickRectangle *rect = qobject_cast(component.create()); QVERIFY(rect != 0); int index = rect->metaObject()->indexOfMethod(methodName.toUtf8()); @@ -685,9 +735,9 @@ void tst_script::block() void tst_script::global_property_js() { - QScriptEngine engine; + QJSEngine engine; - QScriptValue prog = engine.evaluate(GLOBALPROPERTY_PROGRAM); + QJSValue prog = engine.evaluate(GLOBALPROPERTY_PROGRAM); prog.call(); QBENCHMARK { @@ -699,8 +749,7 @@ void tst_script::global_property_qml() { QDeclarativeEngine qmlengine; - QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine); - QScriptValue prog = engine->evaluate(GLOBALPROPERTY_PROGRAM); + QJSValue prog = qmlengine.evaluate(GLOBALPROPERTY_PROGRAM); prog.call(); QBENCHMARK { @@ -712,7 +761,7 @@ void tst_script::global_property_qml_js() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml")); - QDeclarativeRectangle *rect = qobject_cast(component.create()); + QQuickRectangle *rect = qobject_cast(component.create()); QVERIFY(rect != 0); int index = rect->metaObject()->indexOfMethod("triggered()"); @@ -730,7 +779,7 @@ void tst_script::scriptfile_property() { QDeclarativeEngine engine; QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml")); - QDeclarativeRectangle *rect = qobject_cast(component.create()); + QQuickRectangle *rect = qobject_cast(component.create()); QVERIFY(rect != 0); int index = rect->metaObject()->indexOfMethod("incrementTriggered()"); -- cgit v1.2.3 From 86b14cf97081cad1e32b8b5261f771184300f8af Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 23 Feb 2012 10:12:52 +1000 Subject: Remove unused member. Change-Id: Ibfcc7a78e442c2be5bab6933e2e85ed39344e6c2 Reviewed-by: Kim M. Kalland --- src/quick/scenegraph/qsgcontext.cpp | 2 +- src/quick/scenegraph/qsgdefaultrectanglenode.cpp | 3 +-- src/quick/scenegraph/qsgdefaultrectanglenode_p.h | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/quick/scenegraph/qsgcontext.cpp b/src/quick/scenegraph/qsgcontext.cpp index 03afed293a..877278116f 100644 --- a/src/quick/scenegraph/qsgcontext.cpp +++ b/src/quick/scenegraph/qsgcontext.cpp @@ -238,7 +238,7 @@ void QSGContext::renderNextFrame(QSGRenderer *renderer, GLuint fboId) */ QSGRectangleNode *QSGContext::createRectangleNode() { - return new QSGDefaultRectangleNode(this); + return new QSGDefaultRectangleNode; } /*! diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp index cb385f6dd0..3d15f6944d 100644 --- a/src/quick/scenegraph/qsgdefaultrectanglenode.cpp +++ b/src/quick/scenegraph/qsgdefaultrectanglenode.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE -QSGDefaultRectangleNode::QSGDefaultRectangleNode(QSGContext *context) +QSGDefaultRectangleNode::QSGDefaultRectangleNode() : m_border(0) , m_radius(0) , m_pen_width(0) @@ -62,7 +62,6 @@ QSGDefaultRectangleNode::QSGDefaultRectangleNode(QSGContext *context) , m_gradient_is_opaque(true) , m_dirty_geometry(false) , m_default_geometry(QSGGeometry::defaultAttributes_Point2D(), 4) - , m_context(context) { setGeometry(&m_default_geometry); setMaterial(&m_fill_material); diff --git a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h index 49ca3771c1..a5e43f8581 100644 --- a/src/quick/scenegraph/qsgdefaultrectanglenode_p.h +++ b/src/quick/scenegraph/qsgdefaultrectanglenode_p.h @@ -57,7 +57,7 @@ class QSGContext; class QSGDefaultRectangleNode : public QSGRectangleNode { public: - QSGDefaultRectangleNode(QSGContext *context); + QSGDefaultRectangleNode(); ~QSGDefaultRectangleNode(); virtual void setRect(const QRectF &rect); @@ -95,8 +95,6 @@ private: uint m_material_type : 2; // Only goes up to 3 QSGGeometry m_default_geometry; - - QSGContext *m_context; }; QT_END_NAMESPACE -- cgit v1.2.3 From 6c08b232f31430896e332b9222f3ded2b3e73c7a Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 24 Feb 2012 18:05:35 +1000 Subject: Stabilise tests Change-Id: I2227fede52f5b0d59bd0dd9b10ab0151318d61dd Reviewed-by: Martin Jones --- .../qquicklistview/data/multipleTransitions.qml | 2 +- .../qtquick2/qquicklistview/tst_qquicklistview.cpp | 26 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml index 50ffbc53c3..3e3248535b 100644 --- a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml +++ b/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml @@ -10,7 +10,7 @@ Rectangle { // interrupting transitions will still produce the correct result) property int timeBetweenActions: duration / 2 - property int duration: 100 + property int duration: 300 property int count: list.count diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index eb7efd6d33..959bb2b265 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -490,6 +490,7 @@ void tst_QQuickListView::inserted_more() canvas->setSource(testFileUrl("listviewtest.qml")); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -643,6 +644,7 @@ void tst_QQuickListView::insertBeforeVisible() canvas->setSource(testFileUrl("listviewtest.qml")); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -733,6 +735,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) canvas->setSource(source); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -922,6 +925,7 @@ void tst_QQuickListView::removed_more(const QUrl &source) canvas->setSource(source); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -1143,6 +1147,7 @@ void tst_QQuickListView::moved(const QUrl &source) canvas->setSource(source); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -1369,6 +1374,7 @@ void tst_QQuickListView::multipleChanges() canvas->setSource(testFileUrl("listviewtest.qml")); canvas->show(); qApp->processEvents(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -4813,6 +4819,7 @@ void tst_QQuickListView::populateTransitions() canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia); canvas->setSource(testFileUrl("populateTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview); @@ -4950,6 +4957,7 @@ void tst_QQuickListView::addTransitions() ctxt->setContextProperty("testObject", testObject); canvas->setSource(testFileUrl("addTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -5144,6 +5152,7 @@ void tst_QQuickListView::moveTransitions() ctxt->setContextProperty("testObject", testObject); canvas->setSource(testFileUrl("moveTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -5346,6 +5355,7 @@ void tst_QQuickListView::removeTransitions() ctxt->setContextProperty("testObject", testObject); canvas->setSource(testFileUrl("removeTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -5537,6 +5547,7 @@ void tst_QQuickListView::multipleTransitions() ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom); canvas->setSource(testFileUrl("multipleTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickListView *listview = findItem(canvas->rootObject(), "list"); QTRY_VERIFY(listview != 0); @@ -5603,20 +5614,9 @@ void tst_QQuickListView::multipleTransitions() } QCOMPARE(listview->count(), model.count()); - QList items = findItems(contentItem, "wrapper"); - int firstVisibleIndex = -1; - for (int i=0; iy() >= contentY) { - QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); - firstVisibleIndex = e.evaluate().toInt(); - break; - } - } - QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); - // verify all items moved to the correct final positions - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) { + QList items = findItems(contentItem, "wrapper"); + for (int i=0; i < model.count() && i < items.count(); ++i) { QQuickItem *item = findItem(contentItem, "wrapper", i); QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); QTRY_COMPARE(item->x(), 0.0); -- cgit v1.2.3 From cd6cabc6ccd2499662ddb3b5748561557360843b Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 27 Feb 2012 11:08:15 +1000 Subject: Improve test coverage for anchors. Change-Id: I2705407b16ef678ed5b3cbfa7116ae6b18366688 Reviewed-by: Yann Bodson --- tests/auto/qtquick2/qquickanchors/data/stretch.qml | 39 ++++++++++++++++++++ .../qtquick2/qquickanchors/tst_qquickanchors.cpp | 41 ++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 tests/auto/qtquick2/qquickanchors/data/stretch.qml diff --git a/tests/auto/qtquick2/qquickanchors/data/stretch.qml b/tests/auto/qtquick2/qquickanchors/data/stretch.qml new file mode 100644 index 0000000000..64e23e30b5 --- /dev/null +++ b/tests/auto/qtquick2/qquickanchors/data/stretch.qml @@ -0,0 +1,39 @@ +import QtQuick 2.0 + +Rectangle { + width: 400; height: 400 + + Rectangle { + id: rect1 + x: 20; y: 20; + height: 360; width: 360; + + Rectangle { + id: rect2; objectName: "stretcher" + anchors.verticalCenter: rect1.verticalCenter + anchors.bottom: rect3.top + anchors.horizontalCenter: rect1.horizontalCenter + anchors.left: rect3.left + } + + Rectangle { + id: rect3 + x: 160; y: 230 + width: 10 + height: 10 + } + + Rectangle { + id: rect4; objectName: "stretcher2" + anchors.verticalCenter: rect1.verticalCenter + anchors.top: rect5.top + } + + Rectangle { + id: rect5 + x: 160; y: 130 + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp b/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp index 8d82abc53b..af43686e27 100644 --- a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp +++ b/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp @@ -83,6 +83,7 @@ private slots: void fillRTL(); void margins(); void marginsRTL(); + void stretch(); }; void tst_qquickanchors::basicAnchors() @@ -472,6 +473,10 @@ void tst_qquickanchors::fill() qApp->processEvents(); QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QCOMPARE(rectPrivate->anchors()->leftMargin(), 10.0); + QCOMPARE(rectPrivate->anchors()->topMargin(), 30.0); + QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0); + QCOMPARE(rectPrivate->anchors()->bottomMargin(), 40.0); QCOMPARE(rect->x(), 0.0 + 10.0); QCOMPARE(rect->y(), 0.0 + 30.0); QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); @@ -481,6 +486,10 @@ void tst_qquickanchors::fill() rectPrivate->anchors()->setRightMargin(0.0); rectPrivate->anchors()->setBottomMargin(0.0); rectPrivate->anchors()->setTopMargin(10.0); + QCOMPARE(rectPrivate->anchors()->leftMargin(), 20.0); + QCOMPARE(rectPrivate->anchors()->topMargin(), 10.0); + QCOMPARE(rectPrivate->anchors()->rightMargin(), 0.0); + QCOMPARE(rectPrivate->anchors()->bottomMargin(), 0.0); QCOMPARE(rect->x(), 0.0 + 20.0); QCOMPARE(rect->y(), 0.0 + 10.0); QCOMPARE(rect->width(), 200.0 - 20.0); @@ -523,11 +532,15 @@ void tst_qquickanchors::centerIn() QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), 10.0); + QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), 30.0); QCOMPARE(rect->x(), 75.0 + 10); QCOMPARE(rect->y(), 75.0 + 30); //Alter Offsets (tests QTBUG-6631) rectPrivate->anchors()->setHorizontalCenterOffset(-20.0); rectPrivate->anchors()->setVerticalCenterOffset(-10.0); + QCOMPARE(rectPrivate->anchors()->horizontalCenterOffset(), -20.0); + QCOMPARE(rectPrivate->anchors()->verticalCenterOffset(), -10.0); QCOMPARE(rect->x(), 75.0 - 20.0); QCOMPARE(rect->y(), 75.0 - 10.0); @@ -623,6 +636,11 @@ void tst_qquickanchors::margins() qApp->processEvents(); QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect); + QCOMPARE(rectPrivate->anchors()->margins(), 10.0); + QCOMPARE(rectPrivate->anchors()->topMargin(), 6.0); + QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0); + QCOMPARE(rectPrivate->anchors()->bottomMargin(), 10.0); + QCOMPARE(rectPrivate->anchors()->rightMargin(), 10.0); QCOMPARE(rect->x(), 5.0); QCOMPARE(rect->y(), 6.0); QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); @@ -631,6 +649,12 @@ void tst_qquickanchors::margins() rectPrivate->anchors()->setTopMargin(0.0); rectPrivate->anchors()->setMargins(20.0); + QCOMPARE(rectPrivate->anchors()->margins(), 20.0); + QEXPECT_FAIL("","QTBUG-24515", Continue); + QCOMPARE(rectPrivate->anchors()->topMargin(), 0.0); + QCOMPARE(rectPrivate->anchors()->leftMargin(), 5.0); + QCOMPARE(rectPrivate->anchors()->bottomMargin(), 20.0); + QCOMPARE(rectPrivate->anchors()->rightMargin(), 20.0); QCOMPARE(rect->x(), 5.0); QCOMPARE(rect->y(), 20.0); QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0); @@ -663,6 +687,23 @@ void tst_qquickanchors::marginsRTL() delete view; } +void tst_qquickanchors::stretch() +{ + QQuickView *view = new QQuickView(testFileUrl("stretch.qml")); + + qApp->processEvents(); + QQuickRectangle* rect = findItem(view->rootObject(), QLatin1String("stretcher")); + QCOMPARE(rect->x(), 160.0); + QCOMPARE(rect->y(), 130.0); + QCOMPARE(rect->width(), 40.0); + QCOMPARE(rect->height(), 100.0); + + QQuickRectangle* rect2 = findItem(view->rootObject(), QLatin1String("stretcher2")); + QCOMPARE(rect2->y(), 130.0); + QCOMPARE(rect2->height(), 100.0); + + delete view; +} QTEST_MAIN(tst_qquickanchors) -- cgit v1.2.3 From de02b0f6ba4c422ff617308617b32804b15d1f7e Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Fri, 24 Feb 2012 16:14:12 +1000 Subject: Ensure importing module API in js import works This commit adds a unit test to ensure that a property of a module api can be accessed in a JavaScript import. Change-Id: Iecba76a9db0400ece1777256f19803d4bad53438 Reviewed-by: Alan Alpert --- .../qdeclarativeecmascript/data/jsimport/importModuleApi.js | 5 +++++ .../data/jsimport/testImportModuleApi.qml | 10 ++++++++++ .../qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 7 +++++++ 3 files changed, 22 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importModuleApi.js create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportModuleApi.qml diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importModuleApi.js b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importModuleApi.js new file mode 100644 index 0000000000..7a4f434665 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importModuleApi.js @@ -0,0 +1,5 @@ +.import Qt.test 1.0 as QObjectModuleApi + +function testFunc() { + return QObjectModuleApi.qobjectTestProperty +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportModuleApi.qml b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportModuleApi.qml new file mode 100644 index 0000000000..b3e545dd7c --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportModuleApi.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import "importModuleApi.js" as Script + +Item { + property variant testValue: 5 + + Component.onCompleted: { + testValue = Script.testFunc(); + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 7fc137e38d..6905252107 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -3267,6 +3267,13 @@ void tst_qdeclarativeecmascript::importScripts_data() << QStringList() << (QStringList() << QLatin1String("testValue")) << (QVariantList() << QVariant(18)); + + QTest::newRow("import module api into js import") + << testFileUrl("jsimport/testImportModuleApi.qml") + << QString() + << QStringList() + << (QStringList() << QLatin1String("testValue")) + << (QVariantList() << QVariant(20)); } void tst_qdeclarativeecmascript::importScripts() -- cgit v1.2.3 From d2921ffc52fed380326f8abb86d6d659cc47f9d1 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Fri, 24 Feb 2012 14:40:11 +1000 Subject: Check engine equality condition inside null ptr check Previously, we asserted if the engine associated with the two external resources from the arguments to the object comparison callback were not equal, prior to checking that the external resources were non-null. Task-number: QTBUG-24489 Change-Id: I4b2bd2377fcf38163d1341e43e056b1405ab72ac Reviewed-by: Yunqiao Yin Reviewed-by: Michael Brasser --- src/declarative/qml/v8/qv8engine.cpp | 6 ++++-- .../qdeclarativevaluetypes/data/nonValueTypeComparison.qml | 10 ++++++++++ .../qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp | 13 +++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/nonValueTypeComparison.qml diff --git a/src/declarative/qml/v8/qv8engine.cpp b/src/declarative/qml/v8/qv8engine.cpp index 04589fe244..70e6528f0a 100644 --- a/src/declarative/qml/v8/qv8engine.cpp +++ b/src/declarative/qml/v8/qv8engine.cpp @@ -75,12 +75,14 @@ static bool ObjectComparisonCallback(v8::Local lhs, v8::Local(lhs->GetExternalResource()); QV8ObjectResource *rhsr = static_cast(rhs->GetExternalResource()); - Q_ASSERT(lhsr->engine == rhsr->engine); - if (lhsr && rhsr) { + Q_ASSERT(lhsr->engine == rhsr->engine); QV8ObjectResource::ResourceType lhst = lhsr->resourceType(); QV8ObjectResource::ResourceType rhst = rhsr->resourceType(); diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/nonValueTypeComparison.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/nonValueTypeComparison.qml new file mode 100644 index 0000000000..0ffa5eb666 --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/nonValueTypeComparison.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +Item { + property variant somepoint: Qt.point(1,2) + property variant randomjsobj: {"some": 1, "thing": 2} + property bool test1: somepoint != randomjsobj + + property variant similar: {"x":1, "y":2} + property bool test2: somepoint != similar +} diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 72ec7a5abf..e701efa2a4 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -93,6 +93,7 @@ private slots: void returnValues(); void varAssignment(); void bindingsSpliceCorrectly(); + void nonValueTypeComparison(); private: QDeclarativeEngine engine; @@ -1301,6 +1302,18 @@ void tst_qdeclarativevaluetypes::bindingsSpliceCorrectly() } } +void tst_qdeclarativevaluetypes::nonValueTypeComparison() +{ + QDeclarativeComponent component(&engine, testFileUrl("nonValueTypeComparison.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + + delete object; +} + QTEST_MAIN(tst_qdeclarativevaluetypes) #include "tst_qdeclarativevaluetypes.moc" -- cgit v1.2.3 From 15dac112df4f44ba8b15047720e1570fd4096f26 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 23 Feb 2012 16:57:06 +1000 Subject: Don't create a separate section header for currentItem The currentItem FxViewItem contained it's own section item, which when created would cause the current item delegate to be repositioned. This change associates the section item with the delegate item, via the attached object. Change-Id: Ie675d545539b56d0f1cf5a9b4ea26668978a5e72 Reviewed-by: Bea Lam --- src/quick/items/qquickitemview.cpp | 15 +-- src/quick/items/qquickitemview_p_p.h | 8 +- src/quick/items/qquicklistview.cpp | 112 +++++++++++---------- src/quick/items/qquicklistview_p.h | 3 +- .../qquicklistview/data/sectionpropertychange.qml | 92 +++++++++++++++++ .../qtquick2/qquicklistview/tst_qquicklistview.cpp | 53 +++++++++- 6 files changed, 217 insertions(+), 66 deletions(-) create mode 100644 tests/auto/qtquick2/qquicklistview/data/sectionpropertychange.qml diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index 533e1f6852..f62fa94f5e 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -46,11 +46,12 @@ QT_BEGIN_NAMESPACE FxViewItem::FxViewItem(QQuickItem *i, bool own) - : item(i), ownItem(own), index(-1), releaseAfterTransition(false) - , transition(0) - , nextTransitionType(FxViewItemTransitionManager::NoTransition) + : item(i), ownItem(own), releaseAfterTransition(false) , isTransitionTarget(false) , nextTransitionToSet(false) + , index(-1) + , transition(0) + , nextTransitionType(FxViewItemTransitionManager::NoTransition) { } @@ -2768,21 +2769,23 @@ void QQuickItemView::destroyingItem(QQuickItem *item) d->unrequestedItems.remove(item); } -void QQuickItemViewPrivate::releaseItem(FxViewItem *item) +bool QQuickItemViewPrivate::releaseItem(FxViewItem *item) { Q_Q(QQuickItemView); if (!item || !model) - return; + return true; if (trackedItem == item) trackedItem = 0; QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item->item); itemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Geometry); - if (model->release(item->item) == 0) { + QQuickVisualModel::ReleaseFlags flags = model->release(item->item); + if (flags == 0) { // item was not destroyed, and we no longer reference it. item->item->setVisible(false); unrequestedItems.insert(item->item, model->indexOf(item->item, q)); } delete item; + return flags != QQuickVisualModel::Referenced; } QQuickItem *QQuickItemViewPrivate::createHighlightItem() diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h index 05927c0d68..fce6e4eba5 100644 --- a/src/quick/items/qquickitemview_p_p.h +++ b/src/quick/items/qquickitemview_p_p.h @@ -117,15 +117,15 @@ public: QQuickItem *item; bool ownItem; - int index; bool releaseAfterTransition; + bool isTransitionTarget; + bool nextTransitionToSet; + int index; QQuickItemViewAttached *attached; FxViewItemTransitionManager *transition; QPointF nextTransitionTo; FxViewItemTransitionManager::TransitionType nextTransitionType; - bool isTransitionTarget; - bool nextTransitionToSet; protected: void moveTo(const QPointF &pos); @@ -225,7 +225,7 @@ public: void mirrorChange(); FxViewItem *createItem(int modelIndex, bool asynchronous = false); - virtual void releaseItem(FxViewItem *item); + virtual bool releaseItem(FxViewItem *item); QQuickItem *createHighlightItem(); QQuickItem *createComponentItem(QDeclarativeComponent *component, bool receiveItemGeometryChanges, bool createDefault = false); diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 6324c7d2ff..0e643a13e3 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -93,7 +93,7 @@ public: virtual FxViewItem *newViewItem(int index, QQuickItem *item); virtual void initializeViewItem(FxViewItem *item); - virtual void releaseItem(FxViewItem *item); + virtual bool releaseItem(FxViewItem *item); virtual void repositionItemAt(FxViewItem *item, int index, qreal sizeBuffer); virtual void repositionPackageItemAt(QQuickItem *item, int index); virtual void resetFirstItemPosition(qreal pos = 0.0); @@ -236,7 +236,7 @@ void QQuickViewSection::setLabelPositioning(int l) class FxListItemSG : public FxViewItem { public: - FxListItemSG(QQuickItem *i, QQuickListView *v, bool own) : FxViewItem(i, own), section(0), view(v) { + FxListItemSG(QQuickItem *i, QQuickListView *v, bool own) : FxViewItem(i, own), view(v) { attached = static_cast(qmlAttachedPropertiesObject(item)); if (attached) static_cast(attached)->setView(view); @@ -244,12 +244,21 @@ public: ~FxListItemSG() {} + inline QQuickItem *section() const { + return attached ? static_cast(attached)->m_sectionItem : 0; + } + void setSection(QQuickItem *s) { + if (!attached) + attached = static_cast(qmlAttachedPropertiesObject(item)); + static_cast(attached)->m_sectionItem = s; + } + qreal position() const { - if (section) { + if (section()) { if (view->orientation() == QQuickListView::Vertical) - return section->y(); + return section()->y(); else - return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -section->width()-section->x() : section->x()); + return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -section()->width()-section()->x() : section()->x()); } else { return itemPosition(); } @@ -261,8 +270,8 @@ public: return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -item->width()-itemX() : itemX()); } qreal size() const { - if (section) - return (view->orientation() == QQuickListView::Vertical ? item->height()+section->height() : item->width()+section->width()); + if (section()) + return (view->orientation() == QQuickListView::Vertical ? item->height()+section()->height() : item->width()+section()->width()); else return (view->orientation() == QQuickListView::Vertical ? item->height() : item->width()); } @@ -270,8 +279,8 @@ public: return (view->orientation() == QQuickListView::Vertical ? item->height() : item->width()); } qreal sectionSize() const { - if (section) - return (view->orientation() == QQuickListView::Vertical ? section->height() : section->width()); + if (section()) + return (view->orientation() == QQuickListView::Vertical ? section()->height() : section()->width()); return 0.0; } qreal endPosition() const { @@ -285,14 +294,14 @@ public: } void setPosition(qreal pos) { // position the section immediately even if there is a transition - if (section) { + if (section()) { if (view->orientation() == QQuickListView::Vertical) { - section->setY(pos); + section()->setY(pos); } else { if (view->effectiveLayoutDirection() == Qt::RightToLeft) - section->setX(-section->width()-pos); + section()->setX(-section()->width()-pos); else - section->setX(pos); + section()->setX(pos); } } moveTo(pointForPosition(pos)); @@ -311,23 +320,22 @@ public: return view; } - QQuickItem *section; QQuickListView *view; private: QPointF pointForPosition(qreal pos) const { if (view->orientation() == QQuickListView::Vertical) { - if (section) - pos += section->height(); + if (section()) + pos += section()->height(); return QPointF(itemX(), pos); } else { if (view->effectiveLayoutDirection() == Qt::RightToLeft) { - if (section) - pos += section->width(); + if (section()) + pos += section()->width(); return QPointF(-item->width() - pos, itemY()); } else { - if (section) - pos += section->width(); + if (section()) + pos += section()->width(); return QPointF(pos, itemY()); } } @@ -566,25 +574,31 @@ void QQuickListViewPrivate::initializeViewItem(FxViewItem *item) } } -void QQuickListViewPrivate::releaseItem(FxViewItem *item) +bool QQuickListViewPrivate::releaseItem(FxViewItem *item) { - if (item) { - FxListItemSG* listItem = static_cast(item); - if (listItem->section) { - int i = 0; - do { - if (!sectionCache[i]) { - sectionCache[i] = listItem->section; - sectionCache[i]->setVisible(false); - listItem->section = 0; - break; - } - ++i; - } while (i < sectionCacheSize); - delete listItem->section; - } + if (!item || !model) + return true; + + QQuickListViewAttached *att = static_cast(item->attached); + + bool released = QQuickItemViewPrivate::releaseItem(item); + if (released && att && att->m_sectionItem) { + // We hold no more references to this item + int i = 0; + do { + if (!sectionCache[i]) { + sectionCache[i] = att->m_sectionItem; + sectionCache[i]->setVisible(false); + att->m_sectionItem = 0; + break; + } + ++i; + } while (i < sectionCacheSize); + delete att->m_sectionItem; + att->m_sectionItem = 0; } - QQuickItemViewPrivate::releaseItem(item); + + return released; } bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool doBuffer) @@ -944,18 +958,18 @@ void QQuickListViewPrivate::updateInlineSection(FxListItemSG *listItem) if (listItem->attached->m_prevSection != listItem->attached->m_section && (sectionCriteria->labelPositioning() & QQuickViewSection::InlineLabels || (listItem->index == 0 && sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart))) { - if (!listItem->section) { + if (!listItem->section()) { qreal pos = listItem->position(); - listItem->section = getSectionItem(listItem->attached->m_section); + listItem->setSection(getSectionItem(listItem->attached->m_section)); listItem->setPosition(pos); } else { - QDeclarativeContext *context = QDeclarativeEngine::contextForObject(listItem->section)->parentContext(); + QDeclarativeContext *context = QDeclarativeEngine::contextForObject(listItem->section())->parentContext(); context->setContextProperty(QLatin1String("section"), listItem->attached->m_section); } - } else if (listItem->section) { + } else if (listItem->section()) { qreal pos = listItem->position(); - releaseSectionItem(listItem->section); - listItem->section = 0; + releaseSectionItem(listItem->section()); + listItem->setSection(0); listItem->setPosition(pos); } } @@ -972,7 +986,7 @@ void QQuickListViewPrivate::updateStickySections() QQuickItem *lastSectionItem = 0; int index = 0; while (index < visibleItems.count()) { - if (QQuickItem *section = static_cast(visibleItems.at(index))->section) { + if (QQuickItem *section = static_cast(visibleItems.at(index))->section()) { // Find the current section header and last visible section header // and hide them if they will overlap a static section header. qreal sectionPos = orient == QQuickListView::Vertical ? section->y() : section->x(); @@ -1173,9 +1187,9 @@ void QQuickListViewPrivate::initializeCurrentItem() if (currentItem) { FxListItemSG *listItem = static_cast(currentItem); - // don't reposition the item if it's about to be transitioned to another position + // don't reposition the item if it is already in the visibleItems list FxViewItem *actualItem = visibleItem(currentIndex); - if ((!actualItem || !actualItem->transitionScheduledOrRunning())) { + if (!actualItem) { if (currentIndex == visibleIndex - 1 && visibleItems.count()) { // We can calculate exact postion in this case listItem->setPosition(visibleItems.first()->position() - currentItem->size() - spacing); @@ -1186,12 +1200,6 @@ void QQuickListViewPrivate::initializeCurrentItem() } } - // Avoid showing section delegate twice. We still need the section heading so that - // currentItem positioning works correctly. - // This is slightly sub-optimal, but section heading caching minimizes the impact. - if (listItem->section) - listItem->section->setVisible(false); - if (visibleItems.isEmpty()) averageSize = listItem->size(); } diff --git a/src/quick/items/qquicklistview_p.h b/src/quick/items/qquicklistview_p.h index bffd935616..058c50f4d7 100644 --- a/src/quick/items/qquicklistview_p.h +++ b/src/quick/items/qquicklistview_p.h @@ -181,7 +181,7 @@ class QQuickListViewAttached : public QQuickItemViewAttached public: QQuickListViewAttached(QObject *parent) - : QQuickItemViewAttached(parent), m_view(0) {} + : QQuickItemViewAttached(parent), m_view(0), m_sectionItem(0) {} ~QQuickListViewAttached() {} Q_PROPERTY(QQuickListView *view READ view NOTIFY viewChanged) @@ -198,6 +198,7 @@ Q_SIGNALS: public: QDeclarativeGuard m_view; + QQuickItem *m_sectionItem; }; diff --git a/tests/auto/qtquick2/qquicklistview/data/sectionpropertychange.qml b/tests/auto/qtquick2/qquicklistview/data/sectionpropertychange.qml new file mode 100644 index 0000000000..f4679b5af0 --- /dev/null +++ b/tests/auto/qtquick2/qquicklistview/data/sectionpropertychange.qml @@ -0,0 +1,92 @@ +import QtQuick 2.0 + +Rectangle { + width: 320; height: 480 + + Rectangle { + id: groupButtons + width: 300; height: 30 + color: "yellow" + border.width: 1 + Text { + anchors.centerIn: parent + text: "swap" + } + anchors { + top: parent.top + horizontalCenter: parent.horizontalCenter + } + MouseArea { + anchors.fill: parent + onClicked: switchGroups() + } + } + + function switchGroups() { + if ("title" === myListView.groupBy) + myListView.groupBy = "genre" + else + myListView.groupBy = "title" + } + + Component.onCompleted: { + myListView.model = generateModel(myListView) + } + + ListView { + id: myListView + objectName: "list" + + clip: true + property string groupBy: "title" + + anchors { + top: groupButtons.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + + delegate: Item { + objectName: "wrapper" + height: 50 + width: 320 + Text { id: t; text: model.title } + Text { text: model.author; font.pixelSize: 10; anchors.top: t.bottom } + Text { text: parent.y; anchors.right: parent.right } + } + + onGroupByChanged: { + model.move(0,1,1) + section.property = groupBy + } + + section { + criteria: ViewSection.FullString + delegate: Rectangle { width: 320; height: 25; color: "lightblue" + objectName: "sect" + Text {text: section } + Text { text: parent.y; anchors.right: parent.right } + } + property: "title" + } + } + + function generateModel(theParent) + { + var books = [ + { "author": "Billy Bob", "genre": "Anarchism", "title": "Frogs and Love" }, + { "author": "Lefty Smith", "genre": "Horror", "title": "Chainsaws for Noobs" } + ]; + + var model = Qt.createQmlObject("import QtQuick 2.0; ListModel {}", theParent); + + for (var i = 0; i < books.length; ++i) { + var book = books[i]; + model.append(book); + } + return model; + } + +} + diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index 959bb2b265..253df3295f 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -125,6 +125,7 @@ private slots: void qAbstractItemModel_sections(); void sectionsPositioning(); void sectionsDelegate(); + void sectionPropertyChange(); void cacheBuffer(); void positionViewAtIndex(); void resetModel(); @@ -2095,9 +2096,9 @@ void tst_QQuickListView::sectionsPositioning() QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); model.removeItem(5); QTRY_COMPARE(listview->count(), model.count()); - for (int i = 0; i < 3; ++i) { - QQuickItem *item = findItem(contentItem, - "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); + for (int i = 1; i < 3; ++i) { + QQuickItem *item = findVisibleChild(contentItem, + "sect_" + QString::number(i)); QVERIFY(item); QTRY_COMPARE(item->y(), qreal(i*20*6)); } @@ -2135,6 +2136,52 @@ void tst_QQuickListView::sectionsPositioning() delete canvas; } +void tst_QQuickListView::sectionPropertyChange() +{ + QQuickView *canvas = createView(); + + canvas->setSource(testFileUrl("sectionpropertychange.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + for (int i = 0; i < 2; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), qreal(25. + i*75.)); + } + + QMetaObject::invokeMethod(canvas->rootObject(), "switchGroups"); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + for (int i = 0; i < 2; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), qreal(25. + i*75.)); + } + + QMetaObject::invokeMethod(canvas->rootObject(), "switchGroups"); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + // Confirm items positioned correctly + for (int i = 0; i < 2; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), qreal(25. + i*75.)); + } + + delete canvas; +} + void tst_QQuickListView::currentIndex_delayedItemCreation() { QFETCH(bool, setCurrentToZero); -- cgit v1.2.3 From 4fc0df58b8458052a818e3e970a97457882808e6 Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Fri, 24 Feb 2012 13:33:59 +1000 Subject: Force to send defer deletion events before deleting QQuickCanvas Also change the assert in QDeclarativeEnginePrivate::~QDeclarativeEnginePrivate() to a warning message. Change-Id: Ic1fb7e0b7ffe4a54458a0f3a65127b1afd6dda53 Reviewed-by: Michael Brasser --- src/declarative/qml/qdeclarativeengine.cpp | 3 ++- src/quick/items/qquickcanvas.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 2031bc424a..dca0ef2faf 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -355,7 +355,8 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e) QDeclarativeEnginePrivate::~QDeclarativeEnginePrivate() { - Q_ASSERT(inProgressCreations == 0); + if (inProgressCreations) + qWarning() << QDeclarativeEngine::tr("There are still \"%1\" items in the process of being created at engine destruction.").arg(inProgressCreations); while (cleanup) { QDeclarativeCleanup *c = cleanup; diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp index a9df484a98..6b0eb5b96b 100644 --- a/src/quick/items/qquickcanvas.cpp +++ b/src/quick/items/qquickcanvas.cpp @@ -746,6 +746,7 @@ QQuickCanvas::~QQuickCanvas() QQuickItemPrivate *rootItemPrivate = QQuickItemPrivate::get(d->rootItem); rootItemPrivate->removeFromDirtyList(); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); delete d->incubationController; d->incubationController = 0; delete d->rootItem; d->rootItem = 0; -- cgit v1.2.3 From 8e3284135d2be23ca1be79569271f39092d6d6b4 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 27 Feb 2012 17:37:57 +1000 Subject: Skip test case for now Change-Id: I06128c544c1ee03d4528f6f86fc776e09be87316 Reviewed-by: Bea Lam --- tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp | 2 ++ tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index cc76b7b401..5765a67b77 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -1272,6 +1272,8 @@ void tst_QQuickGridView::moved_data() void tst_QQuickGridView::multipleChanges() { + QSKIP("QTBUG-24523"); + QFETCH(int, startCount); QFETCH(QList, changes); QFETCH(int, newCount); diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index 253df3295f..04da3f732f 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -5566,6 +5566,8 @@ void tst_QQuickListView::removeTransitions_data() void tst_QQuickListView::multipleTransitions() { + QSKIP("QTBUG-24523"); + // Tests that if you interrupt a transition in progress with another action that // cancels the previous transition, the resulting items are still placed correctly. -- cgit v1.2.3 From cfad9eb4df8b8e389143b138ca4536bca0d163eb Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Mon, 27 Feb 2012 13:01:03 +0100 Subject: QmlProfiler: send v8 profiling started signal Change-Id: Ie26bd47c9b79a7f524b9c5bc59146be1ea93761d Reviewed-by: Kai Koehne --- src/declarative/debugger/qv8profilerservice.cpp | 14 ++++++++++++++ src/declarative/debugger/qv8profilerservice_p.h | 1 + .../debugger/qv8profilerservice/tst_qv8profilerservice.cpp | 14 ++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/src/declarative/debugger/qv8profilerservice.cpp b/src/declarative/debugger/qv8profilerservice.cpp index 5ae2d01cc2..7a8a3507cf 100644 --- a/src/declarative/debugger/qv8profilerservice.cpp +++ b/src/declarative/debugger/qv8profilerservice.cpp @@ -187,6 +187,13 @@ void QV8ProfilerService::startProfiling(const QString &title) v8::CpuProfiler::StartProfiling(v8title); d->m_ongoing.append(title); + + // indicate profiling started + QByteArray data; + QDataStream ds(&data, QIODevice::WriteOnly); + ds << (int)QV8ProfilerService::V8Started; + + sendMessage(data); } void QV8ProfilerService::stopProfiling(const QString &title) @@ -205,6 +212,13 @@ void QV8ProfilerService::stopProfiling(const QString &title) // can happen at start const v8::CpuProfileNode *rootNode = cpuProfile->GetTopDownRoot(); d->printProfileTree(rootNode); + } else { + // indicate completion, even without data + QByteArray data; + QDataStream ds(&data, QIODevice::WriteOnly); + ds << (int)QV8ProfilerService::V8Complete; + + sendMessage(data); } } diff --git a/src/declarative/debugger/qv8profilerservice_p.h b/src/declarative/debugger/qv8profilerservice_p.h index 706907ae23..3762845fd3 100644 --- a/src/declarative/debugger/qv8profilerservice_p.h +++ b/src/declarative/debugger/qv8profilerservice_p.h @@ -85,6 +85,7 @@ public: V8Complete, V8SnapshotChunk, V8SnapshotComplete, + V8Started, V8MaximumMessage }; diff --git a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp index 92b893afc6..165783fed5 100644 --- a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp +++ b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp @@ -91,6 +91,7 @@ public: QList snapshotMessages; signals: + void started(); void complete(); void snapshot(); @@ -158,6 +159,9 @@ void QV8ProfilerClient::messageReceived(const QByteArray &message) case QV8ProfilerService::V8SnapshotComplete: emit snapshot(); break; + case QV8ProfilerService::V8Started: + emit started(); + break; default: QString failMessage = QString("Unknown message type: %1").arg(messageType); QFAIL(qPrintable(failMessage)); @@ -208,6 +212,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceEnabled() QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); m_client->startProfiling(""); + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -225,6 +231,8 @@ void tst_QV8ProfilerService::blockingConnectWithTraceDisabled() QFAIL(qPrintable(failMsg)); } m_client->startProfiling(""); + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -236,6 +244,8 @@ void tst_QV8ProfilerService::nonBlockingConnect() QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); m_client->startProfiling(""); + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); m_client->stopProfiling(""); QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -257,6 +267,8 @@ void tst_QV8ProfilerService::profileOnExit() QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled); m_client->startProfiling(""); + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); @@ -270,6 +282,8 @@ void tst_QV8ProfilerService::console() m_client->stopProfiling(""); + QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(started())), + "No start signal received in time."); QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); QVERIFY(!m_client->traceMessages.isEmpty()); -- cgit v1.2.3 From ccd859d2c47e926415c5b1307e84efd4197583c4 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 27 Feb 2012 10:19:01 +1000 Subject: Skip c++ examples in sgexamples test They should be tested separately, QTBUG-24516 has been raised to implement this. Change-Id: Ic90bc8327e6c07164ed34b3d02f2612561491ec0 Reviewed-by: Michael Brasser --- tests/auto/qtquick2/examples/tst_examples.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/auto/qtquick2/examples/tst_examples.cpp b/tests/auto/qtquick2/examples/tst_examples.cpp index ce8f214efd..e80bfec0e2 100644 --- a/tests/auto/qtquick2/examples/tst_examples.cpp +++ b/tests/auto/qtquick2/examples/tst_examples.cpp @@ -88,10 +88,11 @@ tst_examples::tst_examples() // Add files to exclude here excludedFiles << "doc/src/snippets/declarative/listmodel.qml"; //Just a ListModel, no root QQuickItem - // Add directories you want excluded here - excludedDirs << "examples/shared"; //Not an example - excludedDirs << "examples/qtquick/text/fonts"; // QTBUG-21415 + // Add directories you want excluded here (don't add examples/, because they install to examples/qtdeclarative/) + excludedDirs << "shared"; //Not an example + excludedDirs << "qtquick/text/fonts"; // QTBUG-21415 excludedDirs << "doc/src/snippets/declarative/path"; //No root QQuickItem + excludedDirs << "tutorials/gettingStartedQml"; //C++ example, but no cpp files in root dir // These snippets are not expected to run on their own. excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex"; @@ -99,15 +100,15 @@ tst_examples::tst_examples() excludedDirs << "doc/src/snippets/declarative/imports"; #ifdef QT_NO_WEBKIT - excludedDirs << "examples/qtquick/modelviews/webview"; - excludedDirs << "examples/demos/webbrowser"; + excludedDirs << "qtquick/modelviews/webview"; + excludedDirs << "demos/webbrowser"; excludedDirs << "doc/src/snippets/declarative/webview"; #endif #ifdef QT_NO_XMLPATTERNS - excludedDirs << "examples/demos/twitter"; - excludedDirs << "examples/demos/flickr"; - excludedDirs << "examples/demos/photoviewer"; + excludedDirs << "demos/twitter"; + excludedDirs << "demos/flickr"; + excludedDirs << "demos/photoviewer"; #endif } -- cgit v1.2.3 From 929935dd693058d898b57c98c97cf5e7401c42ec Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 27 Feb 2012 08:40:31 +1000 Subject: Examples refactor rebase Automatic rebase did not move some new files to where they should have gone. Change-Id: I25515d29d8992acde15db0df1bb5972e35573e60 Reviewed-by: Martin Jones --- examples/declarative/cppextensions/imageprovider/imageprovider.json | 1 - examples/declarative/cppextensions/plugins/plugin.json | 1 - examples/declarative/cppextensions/qwidgets/qwidgets.json | 1 - .../painteditem/textballoons/TextBalloonPlugin/textballoon.json | 1 - .../declarative/tutorials/extending/chapter6-plugins/chartsplugin.json | 1 - examples/qml/cppextensions/imageprovider/imageprovider.json | 1 + examples/qml/cppextensions/plugins/plugin.json | 1 + examples/qtquick/painteditem/textballoons/textballoon.json | 1 + examples/tutorials/extending/chapter6-plugins/chartsplugin.json | 1 + 9 files changed, 4 insertions(+), 5 deletions(-) delete mode 100644 examples/declarative/cppextensions/imageprovider/imageprovider.json delete mode 100644 examples/declarative/cppextensions/plugins/plugin.json delete mode 100644 examples/declarative/cppextensions/qwidgets/qwidgets.json delete mode 100644 examples/declarative/painteditem/textballoons/TextBalloonPlugin/textballoon.json delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.json create mode 100644 examples/qml/cppextensions/imageprovider/imageprovider.json create mode 100644 examples/qml/cppextensions/plugins/plugin.json create mode 100644 examples/qtquick/painteditem/textballoons/textballoon.json create mode 100644 examples/tutorials/extending/chapter6-plugins/chartsplugin.json diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.json b/examples/declarative/cppextensions/imageprovider/imageprovider.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/declarative/cppextensions/plugins/plugin.json b/examples/declarative/cppextensions/plugins/plugin.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/declarative/cppextensions/plugins/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/declarative/cppextensions/qwidgets/qwidgets.json b/examples/declarative/cppextensions/qwidgets/qwidgets.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/declarative/cppextensions/qwidgets/qwidgets.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/textballoon.json b/examples/declarative/painteditem/textballoons/TextBalloonPlugin/textballoon.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/declarative/painteditem/textballoons/TextBalloonPlugin/textballoon.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.json b/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.json deleted file mode 100644 index 0967ef424b..0000000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chartsplugin.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/qml/cppextensions/imageprovider/imageprovider.json b/examples/qml/cppextensions/imageprovider/imageprovider.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/qml/cppextensions/imageprovider/imageprovider.json @@ -0,0 +1 @@ +{} diff --git a/examples/qml/cppextensions/plugins/plugin.json b/examples/qml/cppextensions/plugins/plugin.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/qml/cppextensions/plugins/plugin.json @@ -0,0 +1 @@ +{} diff --git a/examples/qtquick/painteditem/textballoons/textballoon.json b/examples/qtquick/painteditem/textballoons/textballoon.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/qtquick/painteditem/textballoons/textballoon.json @@ -0,0 +1 @@ +{} diff --git a/examples/tutorials/extending/chapter6-plugins/chartsplugin.json b/examples/tutorials/extending/chapter6-plugins/chartsplugin.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/tutorials/extending/chapter6-plugins/chartsplugin.json @@ -0,0 +1 @@ +{} -- cgit v1.2.3 From af42c1821f4be7f0b1032221a9e40be6a87cc43c Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 24 Feb 2012 15:35:46 +1000 Subject: Don't create unnecessary shadow data Shadow data was being made by accident for uninitialized datums, because they had not yet had the ImageParticle set as the datum owner. Change-Id: Ia1d55610d845627cdb9c83bfda1d7ed4c024f703 Reviewed-by: Michael Brasser --- src/quick/particles/qquickimageparticle.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/quick/particles/qquickimageparticle.cpp b/src/quick/particles/qquickimageparticle.cpp index 2936935f3f..83687ae234 100644 --- a/src/quick/particles/qquickimageparticle.cpp +++ b/src/quick/particles/qquickimageparticle.cpp @@ -1237,6 +1237,9 @@ void QQuickImageParticle::clearShadows() //Only call if you need to, may initialize the whole array first time QQuickParticleData* QQuickImageParticle::getShadowDatum(QQuickParticleData* datum) { + //Will return datum if the datum is a sentinel or uninitialized, to centralize that one check + if (datum->systemIndex == -1) + return datum; QQuickParticleGroupData* gd = m_system->groupData[datum->group]; if (!m_shadowData.contains(datum->group)) { QVector data; -- cgit v1.2.3 From 0bf62c44ab5bc53162ef0d7efea38764e2df8318 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 28 Feb 2012 09:48:27 +1000 Subject: Correctly set duration and easing for AnchorAnimation. Task-number: QTBUG-24532 Change-Id: I3aad9cd8281b954896c2c1d44b2dcae68f913928 Reviewed-by: Yunqiao Yin --- src/quick/items/qquickanimation.cpp | 2 ++ .../qdeclarativeanimations/tst_qdeclarativeanimations.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/quick/items/qquickanimation.cpp b/src/quick/items/qquickanimation.cpp index 4880190697..641fbb2d37 100644 --- a/src/quick/items/qquickanimation.cpp +++ b/src/quick/items/qquickanimation.cpp @@ -551,6 +551,8 @@ QAbstractAnimationJob* QQuickAnchorAnimation::transition(QDeclarativeStateAction delete data; } + animator->setDuration(d->duration); + animator->setEasingCurve(d->easing); return initInstance(animator); } diff --git a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index c7a0717dd3..348586cea8 100644 --- a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -105,6 +106,7 @@ private slots: void pauseBindingBug(); void pauseBug(); void loopingBug(); + void anchorBug(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -1314,6 +1316,19 @@ void tst_qdeclarativeanimations::loopingBug() delete obj; } +//QTBUG-24532 +void tst_qdeclarativeanimations::anchorBug() +{ + QQuickAnchorAnimation animation; + animation.setDuration(5000); + animation.setEasing(QEasingCurve(QEasingCurve::InOutBack)); + animation.start(); + animation.pause(); + + QCOMPARE(animation.qtAnimation()->duration(), 5000); + QCOMPARE(static_cast(animation.qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::InOutBack)); +} + QTEST_MAIN(tst_qdeclarativeanimations) #include "tst_qdeclarativeanimations.moc" -- cgit v1.2.3 From f2c5c77777b61c8fe54a1107e67283d576301a69 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 27 Feb 2012 15:54:16 +1000 Subject: Incubators are not async with the threaded renderer. The threaded incubator relies on the event loop spinning to signal item updates. This change ensures that the event loop is processed while items are being created and that the render loop is woken if it is sleeping. Also cancel delegate incubation correctly during destruction. Change-Id: Ib5bb55c788411490e0959c75933da587fdfd4b8c Reviewed-by: Yunqiao Yin Reviewed-by: Michael Brasser --- src/declarative/qml/qdeclarativeincubator.cpp | 7 ++++--- src/declarative/qml/qdeclarativeincubator.h | 2 +- src/declarative/qml/qdeclarativevme_p.h | 24 +++++++++++------------- src/quick/items/qquickcanvas.cpp | 7 ++++--- src/quick/items/qquickitemview.cpp | 6 ++++++ src/quick/items/qquickvisualdatamodel.cpp | 21 +++++++++++++++++++-- src/quick/items/qquickvisualdatamodel_p.h | 1 + src/quick/items/qquickvisualitemmodel_p.h | 1 + src/quick/items/qquickwindowmanager.cpp | 22 +++++++++++++++++----- src/quick/items/qquickwindowmanager_p.h | 3 ++- 10 files changed, 66 insertions(+), 28 deletions(-) diff --git a/src/declarative/qml/qdeclarativeincubator.cpp b/src/declarative/qml/qdeclarativeincubator.cpp index 38f172f795..6d39fc763a 100644 --- a/src/declarative/qml/qdeclarativeincubator.cpp +++ b/src/declarative/qml/qdeclarativeincubator.cpp @@ -376,17 +376,18 @@ void QDeclarativeIncubationController::incubateFor(int msecs) /*! Incubate objects while the bool pointed to by \a flag is true, or until there are no -more objects to incubate. +more objects to incubate, or up to msecs if msecs is not zero. Generally this method is used in conjunction with a thread or a UNIX signal that sets the bool pointed to by \a flag to false when it wants incubation to be interrupted. */ -void QDeclarativeIncubationController::incubateWhile(bool *flag) +void QDeclarativeIncubationController::incubateWhile(volatile bool *flag, int msecs) { if (!d || d->incubatorCount == 0) return; - QDeclarativeVME::Interrupt i(flag); + QDeclarativeVME::Interrupt i(flag, msecs * 1000000); + i.reset(); do { QDeclarativeIncubatorPrivate *p = (QDeclarativeIncubatorPrivate*)d->incubatorList.first(); p->incubate(i); diff --git a/src/declarative/qml/qdeclarativeincubator.h b/src/declarative/qml/qdeclarativeincubator.h index cabd7e2b28..dca5c3a6bc 100644 --- a/src/declarative/qml/qdeclarativeincubator.h +++ b/src/declarative/qml/qdeclarativeincubator.h @@ -110,7 +110,7 @@ public: int incubatingObjectCount() const; void incubateFor(int msecs); - void incubateWhile(bool *flag); + void incubateWhile(volatile bool *flag, int msecs=0); protected: virtual void incubatingObjectCountChanged(int); diff --git a/src/declarative/qml/qdeclarativevme_p.h b/src/declarative/qml/qdeclarativevme_p.h index d413555847..1f2f861314 100644 --- a/src/declarative/qml/qdeclarativevme_p.h +++ b/src/declarative/qml/qdeclarativevme_p.h @@ -97,7 +97,7 @@ public: class Interrupt { public: inline Interrupt(); - inline Interrupt(bool *runWhile); + inline Interrupt(volatile bool *runWhile, int nsecs=0); inline Interrupt(int nsecs); inline void reset(); @@ -105,13 +105,11 @@ public: private: enum Mode { None, Time, Flag }; Mode mode; - union { - struct { - QElapsedTimer timer; - int nsecs; - }; - bool *runWhile; + struct { + QElapsedTimer timer; + int nsecs; }; + volatile bool *runWhile; }; QDeclarativeVME() : data(0), componentAttached(0) {} @@ -202,23 +200,23 @@ private: }; QDeclarativeVME::Interrupt::Interrupt() -: mode(None) + : mode(None), nsecs(0), runWhile(0) { } -QDeclarativeVME::Interrupt::Interrupt(bool *runWhile) -: mode(Flag), runWhile(runWhile) +QDeclarativeVME::Interrupt::Interrupt(volatile bool *runWhile, int nsecs) + : mode(Flag), nsecs(nsecs), runWhile(runWhile) { } QDeclarativeVME::Interrupt::Interrupt(int nsecs) -: mode(Time), nsecs(nsecs) + : mode(Time), nsecs(nsecs), runWhile(0) { } void QDeclarativeVME::Interrupt::reset() { - if (mode == Time) + if (mode == Time || nsecs) timer.start(); } @@ -229,7 +227,7 @@ bool QDeclarativeVME::Interrupt::shouldInterrupt() const } else if (mode == Time) { return timer.nsecsElapsed() > nsecs; } else if (mode == Flag) { - return !*runWhile; + return !*runWhile || (nsecs && timer.nsecsElapsed() > nsecs); } else { return false; } diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp index 6b0eb5b96b..e6a3e87401 100644 --- a/src/quick/items/qquickcanvas.cpp +++ b/src/quick/items/qquickcanvas.cpp @@ -94,11 +94,10 @@ protected: { if (e->type() == QEvent::User) { Q_ASSERT(m_eventSent); - - bool *amtp = m_canvas->windowManager->allowMainThreadProcessing(); + volatile bool *amtp = m_canvas->windowManager->allowMainThreadProcessing(); while (incubatingObjectCount()) { if (amtp) - incubateWhile(amtp); + incubateWhile(amtp, 2); else incubateFor(5); QCoreApplication::processEvents(); @@ -115,6 +114,8 @@ protected: m_eventSent = true; QCoreApplication::postEvent(this, new QEvent(QEvent::User)); } + // If no animations are running, the renderer may be waiting + m_canvas->windowManager->wakeup(); } private: diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index f62fa94f5e..d5ce567590 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -2162,6 +2162,12 @@ void QQuickItemViewPrivate::clear() createHighlight(); trackedItem = 0; + if (requestedIndex >= 0 && requestedAsync) { + if (model) + model->cancel(requestedIndex); + requestedIndex = -1; + } + markExtentsDirty(); itemCount = 0; } diff --git a/src/quick/items/qquickvisualdatamodel.cpp b/src/quick/items/qquickvisualdatamodel.cpp index 4fdcc98602..0bdf0cb5af 100644 --- a/src/quick/items/qquickvisualdatamodel.cpp +++ b/src/quick/items/qquickvisualdatamodel.cpp @@ -450,6 +450,21 @@ QQuickVisualDataModel::ReleaseFlags QQuickVisualDataModel::release(QQuickItem *i return stat; } +// Cancel a requested async item +void QQuickVisualDataModel::cancel(int index) +{ + Q_D(QQuickVisualDataModel); + if (!d->m_delegate || index < 0 || index >= d->m_compositor.count(d->m_compositorGroup)) { + qWarning() << "VisualDataModel::cancel: index out range" << index << d->m_compositor.count(d->m_compositorGroup); + return; + } + + Compositor::iterator it = d->m_compositor.find(d->m_compositorGroup, index); + QQuickVisualDataModelItem *cacheItem = it->inCache() ? d->m_cache.at(it.cacheIndex) : 0; + if (cacheItem && cacheItem->incubationTask) + d->releaseIncubator(cacheItem->incubationTask); +} + void QQuickVisualDataModelPrivate::group_append( QDeclarativeListProperty *property, QQuickVisualDataGroup *group) { @@ -708,8 +723,10 @@ void QQuickVisualDataModelPrivate::incubatorStatusChanged(QVDMIncubationTask *in incubationTask->incubatingContext = 0; if (!cacheItem->isReferenced()) { int cidx = m_cache.indexOf(cacheItem); - m_compositor.clearFlags(Compositor::Cache, cidx, 1, Compositor::CacheFlag); - m_cache.removeAt(cidx); + if (cidx >= 0) { + m_compositor.clearFlags(Compositor::Cache, cidx, 1, Compositor::CacheFlag); + m_cache.removeAt(cidx); + } delete cacheItem; Q_ASSERT(m_cache.count() == m_compositor.count(Compositor::Cache)); } diff --git a/src/quick/items/qquickvisualdatamodel_p.h b/src/quick/items/qquickvisualdatamodel_p.h index 54cc16d660..043fcfd8a9 100644 --- a/src/quick/items/qquickvisualdatamodel_p.h +++ b/src/quick/items/qquickvisualdatamodel_p.h @@ -106,6 +106,7 @@ public: bool isValid() const { return delegate() != 0; } QQuickItem *item(int index, bool asynchronous=false); ReleaseFlags release(QQuickItem *item); + void cancel(int index); virtual QString stringValue(int index, const QString &role); virtual void setWatchedRoles(QList roles); diff --git a/src/quick/items/qquickvisualitemmodel_p.h b/src/quick/items/qquickvisualitemmodel_p.h index f1c9d066be..7d2b79f718 100644 --- a/src/quick/items/qquickvisualitemmodel_p.h +++ b/src/quick/items/qquickvisualitemmodel_p.h @@ -69,6 +69,7 @@ public: virtual bool isValid() const = 0; virtual QQuickItem *item(int index, bool asynchronous=false) = 0; virtual ReleaseFlags release(QQuickItem *item) = 0; + virtual void cancel(int) {} virtual QString stringValue(int, const QString &) = 0; virtual void setWatchedRoles(QList roles) = 0; diff --git a/src/quick/items/qquickwindowmanager.cpp b/src/quick/items/qquickwindowmanager.cpp index 16b6d92e22..79fd266e1e 100644 --- a/src/quick/items/qquickwindowmanager.cpp +++ b/src/quick/items/qquickwindowmanager.cpp @@ -193,6 +193,7 @@ public: void resize(QQuickCanvas *canvas, const QSize &size); void handleDeferredUpdate(); void maybeUpdate(QQuickCanvas *canvas); + void wakeup(); void startRendering(); void stopRendering(); @@ -202,7 +203,7 @@ public: void initialize(); - bool *allowMainThreadProcessing() { return &allowMainThreadProcessingFlag; } + volatile bool *allowMainThreadProcessing() { return &allowMainThreadProcessingFlag; } bool event(QEvent *); @@ -243,7 +244,7 @@ private: QMutex mutex; QWaitCondition condition; - bool allowMainThreadProcessingFlag; + volatile bool allowMainThreadProcessingFlag; int isGuiLocked; uint animationRunning: 1; @@ -299,12 +300,13 @@ public: void paint(QQuickCanvas *canvas); QImage grab(QQuickCanvas *canvas); void resize(QQuickCanvas *canvas, const QSize &size); + void wakeup(); void maybeUpdate(QQuickCanvas *canvas); void releaseResources() { } - bool *allowMainThreadProcessing(); + volatile bool *allowMainThreadProcessing(); QSGContext *sceneGraphContext() const; @@ -1129,6 +1131,14 @@ void QQuickRenderThreadSingleContextWindowManager::maybeUpdate(QQuickCanvas *) } +void QQuickRenderThreadSingleContextWindowManager::wakeup() +{ + lockInGui(); + if (isRenderBlocked) + wake(); + unlockInGui(); +} + QQuickTrivialWindowManager::QQuickTrivialWindowManager() : gl(0) , eventPending(false) @@ -1268,9 +1278,11 @@ void QQuickTrivialWindowManager::maybeUpdate(QQuickCanvas *canvas) } } +void QQuickTrivialWindowManager::wakeup() +{ +} - -bool *QQuickTrivialWindowManager::allowMainThreadProcessing() +volatile bool *QQuickTrivialWindowManager::allowMainThreadProcessing() { return 0; } diff --git a/src/quick/items/qquickwindowmanager_p.h b/src/quick/items/qquickwindowmanager_p.h index 86312655b3..a0bdf08a91 100644 --- a/src/quick/items/qquickwindowmanager_p.h +++ b/src/quick/items/qquickwindowmanager_p.h @@ -64,8 +64,9 @@ public: virtual void resize(QQuickCanvas *canvas, const QSize &size) = 0; virtual void maybeUpdate(QQuickCanvas *canvas) = 0; + virtual void wakeup() = 0; - virtual bool *allowMainThreadProcessing() = 0; + virtual volatile bool *allowMainThreadProcessing() = 0; virtual QSGContext *sceneGraphContext() const = 0; -- cgit v1.2.3 From e6c5e06c0879a80ecff01b316a4fc148b3646437 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Tue, 28 Feb 2012 14:04:38 +1000 Subject: Fix crash in QDeclarativePixmapStore global static dtor Due to the undefined ordering of global static dtors, the QDPS dtor could run after the texture factories were deleted. Thus, the QDPS dtor cannot call the cost() method of the pixmap data during its destructor, as this could cause a crash. Change-Id: I5d23066dc57e1992cf9d1c13d514f06c431bc752 Reviewed-by: Alan Alpert --- src/declarative/qml/qdeclarativeimageprovider.h | 2 +- src/quick/util/qdeclarativepixmapcache.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/declarative/qml/qdeclarativeimageprovider.h b/src/declarative/qml/qdeclarativeimageprovider.h index 55a5ca2d23..16af45282c 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.h +++ b/src/declarative/qml/qdeclarativeimageprovider.h @@ -58,7 +58,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextureFactory : public QObject { public: QDeclarativeTextureFactory(); - ~QDeclarativeTextureFactory(); + virtual ~QDeclarativeTextureFactory(); virtual QSGTexture *createTexture(QQuickCanvas *canvas) const = 0; virtual QSize textureSize() const = 0; diff --git a/src/quick/util/qdeclarativepixmapcache.cpp b/src/quick/util/qdeclarativepixmapcache.cpp index 95cbd361b8..1f187a7f03 100644 --- a/src/quick/util/qdeclarativepixmapcache.cpp +++ b/src/quick/util/qdeclarativepixmapcache.cpp @@ -762,6 +762,8 @@ void QDeclarativePixmapStore::unreferencePixmap(QDeclarativePixmapData *data) data->nextUnreferenced = m_unreferencedPixmaps; data->prevUnreferencedPtr = &m_unreferencedPixmaps; + if (!m_destroying) // the texture factories may have been cleaned up already. + m_unreferencedCost += data->cost(); m_unreferencedPixmaps = data; if (m_unreferencedPixmaps->nextUnreferenced) { @@ -772,8 +774,6 @@ void QDeclarativePixmapStore::unreferencePixmap(QDeclarativePixmapData *data) if (!m_lastUnreferencedPixmap) m_lastUnreferencedPixmap = data; - m_unreferencedCost += data->cost(); - shrinkCache(-1); // Shrink the cache incase it has become larger than cache_limit if (m_timerId == -1 && m_unreferencedPixmaps && !m_destroying) @@ -810,8 +810,10 @@ void QDeclarativePixmapStore::shrinkCache(int remove) data->prevUnreferencedPtr = 0; data->prevUnreferenced = 0; - remove -= data->cost(); - m_unreferencedCost -= data->cost(); + if (!m_destroying) { + remove -= data->cost(); + m_unreferencedCost -= data->cost(); + } data->removeFromCache(); delete data; } -- cgit v1.2.3 From e38096931ba81bafe6d8737d6fc9737b77ab8723 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Mon, 6 Feb 2012 14:05:58 +0100 Subject: Move distance field util functions to QtGui These distance field generation functions have been moved to QtGui. Change-Id: I78d9015c8776717ede2d1299c2ef3787d165e0b9 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/scenegraph/qsgadaptationlayer.cpp | 1 + .../qsgdefaultdistancefieldglyphcache.cpp | 1 + src/quick/scenegraph/qsgpathsimplifier.cpp | 1673 -------------------- src/quick/scenegraph/qsgpathsimplifier_p.h | 68 - src/quick/scenegraph/scenegraph.pri | 2 - src/quick/scenegraph/util/qsgdistancefieldutil.cpp | 714 --------- src/quick/scenegraph/util/qsgdistancefieldutil_p.h | 24 - 7 files changed, 2 insertions(+), 2481 deletions(-) delete mode 100644 src/quick/scenegraph/qsgpathsimplifier.cpp delete mode 100644 src/quick/scenegraph/qsgpathsimplifier_p.h diff --git a/src/quick/scenegraph/qsgadaptationlayer.cpp b/src/quick/scenegraph/qsgadaptationlayer.cpp index 08e85ab8cb..2795d4d9a8 100644 --- a/src/quick/scenegraph/qsgadaptationlayer.cpp +++ b/src/quick/scenegraph/qsgadaptationlayer.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp index ef5b24d1fd..08f05075da 100644 --- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp @@ -41,6 +41,7 @@ #include "qsgdefaultdistancefieldglyphcache_p.h" +#include #include #include diff --git a/src/quick/scenegraph/qsgpathsimplifier.cpp b/src/quick/scenegraph/qsgpathsimplifier.cpp deleted file mode 100644 index 21e5d473f0..0000000000 --- a/src/quick/scenegraph/qsgpathsimplifier.cpp +++ /dev/null @@ -1,1673 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsgpathsimplifier_p.h" - -#include -#include -#include -#include - -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -#define Q_FIXED_POINT_SCALE 256 -#define Q_TRIANGULATE_END_OF_POLYGON quint32(-1) - - -namespace { - -//============================================================================// -// QPoint // -//============================================================================// - -inline bool operator < (const QPoint &a, const QPoint &b) -{ - return a.y() < b.y() || (a.y() == b.y() && a.x() < b.x()); -} - -inline bool operator > (const QPoint &a, const QPoint &b) -{ - return b < a; -} - -inline bool operator <= (const QPoint &a, const QPoint &b) -{ - return !(a > b); -} - -inline bool operator >= (const QPoint &a, const QPoint &b) -{ - return !(a < b); -} - -inline int cross(const QPoint &u, const QPoint &v) -{ - return u.x() * v.y() - u.y() * v.x(); -} - -inline int dot(const QPoint &u, const QPoint &v) -{ - return u.x() * v.x() + u.y() * v.y(); -} - -//============================================================================// -// Fraction // -//============================================================================// - -// Fraction must be in the range [0, 1) -struct Fraction -{ - bool isValid() const { return denominator != 0; } - - // numerator and denominator must not have common denominators. - unsigned int numerator, denominator; -}; - -inline unsigned int gcd(unsigned int x, unsigned int y) -{ - while (y != 0) { - unsigned int z = y; - y = x % y; - x = z; - } - return x; -} - -// Fraction must be in the range [0, 1) -// Assume input is valid. -Fraction fraction(unsigned int n, unsigned int d) { - Fraction result; - if (n == 0) { - result.numerator = 0; - result.denominator = 1; - } else { - unsigned int g = gcd(n, d); - result.numerator = n / g; - result.denominator = d / g; - } - return result; -} - -//============================================================================// -// Rational // -//============================================================================// - -struct Rational -{ - bool isValid() const { return fraction.isValid(); } - int integer; - Fraction fraction; -}; - -//============================================================================// -// IntersectionPoint // -//============================================================================// - -struct IntersectionPoint -{ - bool isValid() const { return x.fraction.isValid() && y.fraction.isValid(); } - QPoint round() const; - bool isAccurate() const { return x.fraction.numerator == 0 && y.fraction.numerator == 0; } - - Rational x; // 8:8 signed, 32/32 - Rational y; // 8:8 signed, 32/32 -}; - -QPoint IntersectionPoint::round() const -{ - QPoint result(x.integer, y.integer); - if (2 * x.fraction.numerator >= x.fraction.denominator) - ++result.rx(); - if (2 * y.fraction.numerator >= y.fraction.denominator) - ++result.ry(); - return result; -} - -// Return positive value if 'p' is to the right of the line 'v1'->'v2', negative if left of the -// line and zero if exactly on the line. -// The returned value is the z-component of the qCross product between 'v2-v1' and 'p-v1', -// which is twice the signed area of the triangle 'p'->'v1'->'v2' (positive for CW order). -inline int pointDistanceFromLine(const QPoint &p, const QPoint &v1, const QPoint &v2) -{ - return cross(v2 - v1, p - v1); -} - -IntersectionPoint intersectionPoint(const QPoint &u1, const QPoint &u2, - const QPoint &v1, const QPoint &v2) -{ - IntersectionPoint result = {{0, {0, 0}}, {0, {0, 0}}}; - - QPoint u = u2 - u1; - QPoint v = v2 - v1; - int d1 = cross(u, v1 - u1); - int d2 = cross(u, v2 - u1); - int det = d2 - d1; - int d3 = cross(v, u1 - v1); - int d4 = d3 - det; //qCross(v, u2 - v1); - - // Check that the math is correct. - Q_ASSERT(d4 == cross(v, u2 - v1)); - - // The intersection point can be expressed as: - // v1 - v * d1/det - // v2 - v * d2/det - // u1 + u * d3/det - // u2 + u * d4/det - - // I'm only interested in lines that are crossing, so ignore parallel lines even if they overlap. - if (det == 0) - return result; - - if (det < 0) { - det = -det; - d1 = -d1; - d2 = -d2; - d3 = -d3; - d4 = -d4; - } - - // I'm only interested in lines intersecting at their interior, not at their end points. - // The lines intersect at their interior if and only if 'd1 < 0', 'd2 > 0', 'd3 < 0' and 'd4 > 0'. - if (d1 >= 0 || d2 <= 0 || d3 <= 0 || d4 >= 0) - return result; - - // Calculate the intersection point as follows: - // v1 - v * d1/det | v1 <= v2 (component-wise) - // v2 - v * d2/det | v2 < v1 (component-wise) - - // Assuming 16 bits per vector component. - if (v.x() >= 0) { - result.x.integer = v1.x() + int(qint64(-v.x()) * d1 / det); - result.x.fraction = fraction((unsigned int)(qint64(-v.x()) * d1 % det), (unsigned int)det); - } else { - result.x.integer = v2.x() + int(qint64(-v.x()) * d2 / det); - result.x.fraction = fraction((unsigned int)(qint64(-v.x()) * d2 % det), (unsigned int)det); - } - - if (v.y() >= 0) { - result.y.integer = v1.y() + int(qint64(-v.y()) * d1 / det); - result.y.fraction = fraction((unsigned int)(qint64(-v.y()) * d1 % det), (unsigned int)det); - } else { - result.y.integer = v2.y() + int(qint64(-v.y()) * d2 / det); - result.y.fraction = fraction((unsigned int)(qint64(-v.y()) * d2 % det), (unsigned int)det); - } - - Q_ASSERT(result.x.fraction.isValid()); - Q_ASSERT(result.y.fraction.isValid()); - return result; -} - -//============================================================================// -// PathSimplifier // -//============================================================================// - -class PathSimplifier -{ -public: - PathSimplifier(const QVectorPath &path, QDataBuffer &vertices, - QDataBuffer &indices, const QTransform &matrix); - -private: - struct Element; - - class BoundingVolumeHierarchy - { - public: - struct Node - { - enum Type - { - Leaf, - Split - }; - Type type; - QPoint minimum; - QPoint maximum; - union { - Element *element; // type == Leaf - Node *left; // type == Split - }; - Node *right; - }; - - BoundingVolumeHierarchy(); - ~BoundingVolumeHierarchy(); - void allocate(int nodeCount); - void free(); - Node *newNode(); - - Node *root; - private: - void freeNode(Node *n); - - Node *nodeBlock; - int blockSize; - int firstFree; - }; - - struct Element - { - enum Degree - { - Line = 1, - Quadratic = 2, - Cubic = 3 - }; - - quint32 &upperIndex() { return indices[pointingUp ? degree : 0]; } - quint32 &lowerIndex() { return indices[pointingUp ? 0 : degree]; } - quint32 upperIndex() const { return indices[pointingUp ? degree : 0]; } - quint32 lowerIndex() const { return indices[pointingUp ? 0 : degree]; } - void flip(); - - QPoint middle; - quint32 indices[4]; // index to points - Element *next, *previous; // used in connectElements() - int winding; // used in connectElements() - union { - QRBTree::Node *edgeNode; // used in connectElements() - BoundingVolumeHierarchy::Node *bvhNode; - }; - Degree degree : 8; - uint processed : 1; // initially false, true when the element has been checked for intersections. - uint pointingUp : 1; // used in connectElements() - uint originallyPointingUp : 1; // used in connectElements() - }; - - class ElementAllocator - { - public: - ElementAllocator(); - ~ElementAllocator(); - void allocate(int count); - Element *newElement(); - private: - struct ElementBlock - { - ElementBlock *next; - int blockSize; - int firstFree; - Element elements[1]; - } *blocks; - }; - - struct Event - { - enum Type { Upper, Lower }; - bool operator < (const Event &other) const; - - QPoint point; - Type type; - Element *element; - }; - - typedef QRBTree::Node RBNode; - typedef BoundingVolumeHierarchy::Node BVHNode; - - void initElements(const QVectorPath &path, const QTransform &matrix); - void removeIntersections(); - void connectElements(); - void fillIndices(); - BVHNode *buildTree(Element **elements, int elementCount); - bool intersectNodes(QDataBuffer &elements, BVHNode *elementNode, BVHNode *treeNode); - bool equalElements(const Element *e1, const Element *e2); - bool splitLineAt(QDataBuffer &elements, BVHNode *node, quint32 pointIndex, bool processAgain); - void appendSeparatingAxes(QVarLengthArray &axes, Element *element); - QPair calculateSeparatingAxisRange(const QPoint &axis, Element *element); - void splitCurve(QDataBuffer &elements, BVHNode *node); - bool setElementToQuadratic(Element *element, quint32 pointIndex1, const QPoint &ctrl, quint32 pointIndex2); - bool setElementToCubic(Element *element, quint32 pointIndex1, const QPoint &ctrl1, const QPoint &ctrl2, quint32 pointIndex2); - void setElementToCubicAndSimplify(Element *element, quint32 pointIndex1, const QPoint &ctrl1, const QPoint &ctrl2, quint32 pointIndex2); - RBNode *findElementLeftOf(const Element *element, const QPair &bounds); - bool elementIsLeftOf(const Element *left, const Element *right); - QPair outerBounds(const QPoint &point); - static bool flattenQuadratic(const QPoint &u, const QPoint &v, const QPoint &w); - static bool flattenCubic(const QPoint &u, const QPoint &v, const QPoint &w, const QPoint &q); - static bool splitQuadratic(const QPoint &u, const QPoint &v, const QPoint &w, QPoint *result); - static bool splitCubic(const QPoint &u, const QPoint &v, const QPoint &w, const QPoint &q, QPoint *result); - void subDivQuadratic(const QPoint &u, const QPoint &v, const QPoint &w); - void subDivCubic(const QPoint &u, const QPoint &v, const QPoint &w, const QPoint &q); - static void sortEvents(Event *events, int count); - - ElementAllocator m_elementAllocator; - QDataBuffer m_elements; - QDataBuffer *m_points; - BoundingVolumeHierarchy m_bvh; - QDataBuffer *m_indices; - QRBTree m_elementList; - uint m_hints; -}; - -inline PathSimplifier::BoundingVolumeHierarchy::BoundingVolumeHierarchy() - : root(0) - , nodeBlock(0) - , blockSize(0) - , firstFree(0) -{ -} - -inline PathSimplifier::BoundingVolumeHierarchy::~BoundingVolumeHierarchy() -{ - free(); -} - -inline void PathSimplifier::BoundingVolumeHierarchy::allocate(int nodeCount) -{ - Q_ASSERT(nodeBlock == 0); - Q_ASSERT(firstFree == 0); - nodeBlock = new Node[blockSize = nodeCount]; -} - -inline void PathSimplifier::BoundingVolumeHierarchy::free() -{ - freeNode(root); - delete[] nodeBlock; - nodeBlock = 0; - firstFree = blockSize = 0; - root = 0; -} - -inline PathSimplifier::BVHNode *PathSimplifier::BoundingVolumeHierarchy::newNode() -{ - if (firstFree < blockSize) - return &nodeBlock[firstFree++]; - return new Node; -} - -inline void PathSimplifier::BoundingVolumeHierarchy::freeNode(Node *n) -{ - if (!n) - return; - Q_ASSERT(n->type == Node::Split || n->type == Node::Leaf); - if (n->type == Node::Split) { - freeNode(n->left); - freeNode(n->right); - } - if (!(n >= nodeBlock && n < nodeBlock + blockSize)) - delete n; -} - -inline PathSimplifier::ElementAllocator::ElementAllocator() - : blocks(0) -{ -} - -inline PathSimplifier::ElementAllocator::~ElementAllocator() -{ - while (blocks) { - ElementBlock *block = blocks; - blocks = blocks->next; - free(block); - } -} - -inline void PathSimplifier::ElementAllocator::allocate(int count) -{ - Q_ASSERT(blocks == 0); - Q_ASSERT(count > 0); - blocks = (ElementBlock *)malloc(sizeof(ElementBlock) + (count - 1) * sizeof(Element)); - blocks->blockSize = count; - blocks->next = 0; - blocks->firstFree = 0; -} - -inline PathSimplifier::Element *PathSimplifier::ElementAllocator::newElement() -{ - Q_ASSERT(blocks); - if (blocks->firstFree < blocks->blockSize) - return &blocks->elements[blocks->firstFree++]; - ElementBlock *oldBlock = blocks; - blocks = (ElementBlock *)malloc(sizeof(ElementBlock) + (oldBlock->blockSize - 1) * sizeof(Element)); - blocks->blockSize = oldBlock->blockSize; - blocks->next = oldBlock; - blocks->firstFree = 0; - return &blocks->elements[blocks->firstFree++]; -} - - -inline bool PathSimplifier::Event::operator < (const Event &other) const -{ - if (point == other.point) - return type < other.type; - return other.point < point; -} - -inline void PathSimplifier::Element::flip() -{ - for (int i = 0; i < (degree + 1) >> 1; ++i) { - Q_ASSERT(degree >= Line && degree <= Cubic); - Q_ASSERT(i >= 0 && i < degree); - qSwap(indices[i], indices[degree - i]); - } - pointingUp = !pointingUp; - Q_ASSERT(next == 0 && previous == 0); -} - -PathSimplifier::PathSimplifier(const QVectorPath &path, QDataBuffer &vertices, - QDataBuffer &indices, const QTransform &matrix) - : m_elements(0) - , m_points(&vertices) - , m_indices(&indices) -{ - m_points->reset(); - m_indices->reset(); - initElements(path, matrix); - if (!m_elements.isEmpty()) { - removeIntersections(); - connectElements(); - fillIndices(); - } -} - -void PathSimplifier::initElements(const QVectorPath &path, const QTransform &matrix) -{ - m_hints = path.hints(); - int pathElementCount = path.elementCount(); - if (pathElementCount == 0) - return; - m_elements.reserve(2 * pathElementCount); - m_elementAllocator.allocate(2 * pathElementCount); - m_points->reserve(2 * pathElementCount); - const QPainterPath::ElementType *e = path.elements(); - const qreal *p = path.points(); - if (e) { - qreal x, y; - quint32 moveToIndex = 0; - quint32 previousIndex = 0; - for (int i = 0; i < pathElementCount; ++i, ++e, p += 2) { - switch (*e) { - case QPainterPath::MoveToElement: - { - if (!m_points->isEmpty()) { - const QPoint &from = m_points->at(previousIndex); - const QPoint &to = m_points->at(moveToIndex); - if (from != to) { - Element *element = m_elementAllocator.newElement(); - element->degree = Element::Line; - element->indices[0] = previousIndex; - element->indices[1] = moveToIndex; - element->middle.rx() = (from.x() + to.x()) >> 1; - element->middle.ry() = (from.y() + to.y()) >> 1; - m_elements.add(element); - } - } - previousIndex = moveToIndex = m_points->size(); - matrix.map(p[0], p[1], &x, &y); - QPoint to(qRound(x * Q_FIXED_POINT_SCALE), qRound(y * Q_FIXED_POINT_SCALE)); - m_points->add(to); - } - break; - case QPainterPath::LineToElement: - Q_ASSERT(!m_points->isEmpty()); - { - matrix.map(p[0], p[1], &x, &y); - QPoint to(qRound(x * Q_FIXED_POINT_SCALE), qRound(y * Q_FIXED_POINT_SCALE)); - const QPoint &from = m_points->last(); - if (to != from) { - Element *element = m_elementAllocator.newElement(); - element->degree = Element::Line; - element->indices[0] = previousIndex; - element->indices[1] = quint32(m_points->size()); - element->middle.rx() = (from.x() + to.x()) >> 1; - element->middle.ry() = (from.y() + to.y()) >> 1; - m_elements.add(element); - previousIndex = m_points->size(); - m_points->add(to); - } - } - break; - case QPainterPath::CurveToElement: - Q_ASSERT(i + 2 < pathElementCount); - Q_ASSERT(!m_points->isEmpty()); - Q_ASSERT(e[1] == QPainterPath::CurveToDataElement); - Q_ASSERT(e[2] == QPainterPath::CurveToDataElement); - { - quint32 startPointIndex = previousIndex; - matrix.map(p[4], p[5], &x, &y); - QPoint end(qRound(x * Q_FIXED_POINT_SCALE), qRound(y * Q_FIXED_POINT_SCALE)); - previousIndex = m_points->size(); - m_points->add(end); - - // See if this cubic bezier is really quadratic. - qreal x1 = p[-2] + qreal(1.5) * (p[0] - p[-2]); - qreal y1 = p[-1] + qreal(1.5) * (p[1] - p[-1]); - qreal x2 = p[4] + qreal(1.5) * (p[2] - p[4]); - qreal y2 = p[5] + qreal(1.5) * (p[3] - p[5]); - - Element *element = m_elementAllocator.newElement(); - if (qAbs(x1 - x2) < qreal(1e-3) && qAbs(y1 - y2) < qreal(1e-3)) { - // The bezier curve is quadratic. - matrix.map(x1, y1, &x, &y); - QPoint ctrl(qRound(x * Q_FIXED_POINT_SCALE), - qRound(y * Q_FIXED_POINT_SCALE)); - setElementToQuadratic(element, startPointIndex, ctrl, previousIndex); - } else { - // The bezier curve is cubic. - matrix.map(p[0], p[1], &x, &y); - QPoint ctrl1(qRound(x * Q_FIXED_POINT_SCALE), - qRound(y * Q_FIXED_POINT_SCALE)); - matrix.map(p[2], p[3], &x, &y); - QPoint ctrl2(qRound(x * Q_FIXED_POINT_SCALE), - qRound(y * Q_FIXED_POINT_SCALE)); - setElementToCubicAndSimplify(element, startPointIndex, ctrl1, ctrl2, - previousIndex); - } - m_elements.add(element); - } - i += 2; - e += 2; - p += 4; - - break; - default: - Q_ASSERT_X(0, "QSGPathSimplifier::initialize", "Unexpected element type."); - break; - } - } - if (!m_points->isEmpty()) { - const QPoint &from = m_points->at(previousIndex); - const QPoint &to = m_points->at(moveToIndex); - if (from != to) { - Element *element = m_elementAllocator.newElement(); - element->degree = Element::Line; - element->indices[0] = previousIndex; - element->indices[1] = moveToIndex; - element->middle.rx() = (from.x() + to.x()) >> 1; - element->middle.ry() = (from.y() + to.y()) >> 1; - m_elements.add(element); - } - } - } else { - qreal x, y; - - for (int i = 0; i < pathElementCount; ++i, p += 2) { - matrix.map(p[0], p[1], &x, &y); - QPoint to(qRound(x * Q_FIXED_POINT_SCALE), qRound(y * Q_FIXED_POINT_SCALE)); - if (to != m_points->last()) - m_points->add(to); - } - - while (!m_points->isEmpty() && m_points->last() == m_points->first()) - m_points->pop_back(); - - if (m_points->isEmpty()) - return; - - quint32 prev = quint32(m_points->size() - 1); - for (int i = 0; i < m_points->size(); ++i) { - QPoint &to = m_points->at(i); - QPoint &from = m_points->at(prev); - Element *element = m_elementAllocator.newElement(); - element->degree = Element::Line; - element->indices[0] = prev; - element->indices[1] = quint32(i); - element->middle.rx() = (from.x() + to.x()) >> 1; - element->middle.ry() = (from.y() + to.y()) >> 1; - m_elements.add(element); - prev = i; - } - } - - for (int i = 0; i < m_elements.size(); ++i) - m_elements.at(i)->processed = false; -} - -void PathSimplifier::removeIntersections() -{ - Q_ASSERT(!m_elements.isEmpty()); - QDataBuffer elements(m_elements.size()); - for (int i = 0; i < m_elements.size(); ++i) - elements.add(m_elements.at(i)); - m_bvh.allocate(2 * m_elements.size()); - m_bvh.root = buildTree(elements.data(), elements.size()); - - elements.reset(); - for (int i = 0; i < m_elements.size(); ++i) - elements.add(m_elements.at(i)); - - while (!elements.isEmpty()) { - Element *element = elements.last(); - elements.pop_back(); - BVHNode *node = element->bvhNode; - Q_ASSERT(node->type == BVHNode::Leaf); - Q_ASSERT(node->element == element); - if (!element->processed) { - if (!intersectNodes(elements, node, m_bvh.root)) - element->processed = true; - } - } - - m_bvh.free(); // The bounding volume hierarchy is not needed anymore. -} - -void PathSimplifier::connectElements() -{ - Q_ASSERT(!m_elements.isEmpty()); - QDataBuffer events(m_elements.size() * 2); - for (int i = 0; i < m_elements.size(); ++i) { - Element *element = m_elements.at(i); - element->next = element->previous = 0; - element->winding = 0; - element->edgeNode = 0; - const QPoint &u = m_points->at(element->indices[0]); - const QPoint &v = m_points->at(element->indices[element->degree]); - if (u != v) { - element->pointingUp = element->originallyPointingUp = v < u; - - Event event; - event.element = element; - event.point = u; - event.type = element->pointingUp ? Event::Lower : Event::Upper; - events.add(event); - event.point = v; - event.type = element->pointingUp ? Event::Upper : Event::Lower; - events.add(event); - } - } - QVarLengthArray orderedElements; - if (!events.isEmpty()) - sortEvents(events.data(), events.size()); - while (!events.isEmpty()) { - const Event *event = &events.last(); - QPoint eventPoint = event->point; - - // Find all elements passing through the event point. - QPair bounds = outerBounds(eventPoint); - - // Special case: single element above and single element below event point. - int eventCount = events.size(); - if (event->type == Event::Lower && eventCount > 2) { - QPair range; - range.first = bounds.first ? m_elementList.next(bounds.first) - : m_elementList.front(m_elementList.root); - range.second = bounds.second ? m_elementList.previous(bounds.second) - : m_elementList.back(m_elementList.root); - - const Event *event2 = &events.at(eventCount - 2); - const Event *event3 = &events.at(eventCount - 3); - Q_ASSERT(event2->point == eventPoint); // There are always at least two events at a point. - if (range.first == range.second && event2->type == Event::Upper && event3->point != eventPoint) { - Element *element = event->element; - Element *element2 = event2->element; - element->edgeNode->data = event2->element; - element2->edgeNode = element->edgeNode; - element->edgeNode = 0; - - events.pop_back(); - events.pop_back(); - - if (element2->pointingUp != element->pointingUp) - element2->flip(); - element2->winding = element->winding; - int winding = element->winding; - if (element->originallyPointingUp) - ++winding; - if (winding == 0 || winding == 1) { - if (element->pointingUp) { - element->previous = event2->element; - element2->next = event->element; - } else { - element->next = event2->element; - element2->previous = event->element; - } - } - continue; - } - } - orderedElements.clear(); - - // First, find the ones above the event point. - if (m_elementList.root) { - RBNode *current = bounds.first ? m_elementList.next(bounds.first) - : m_elementList.front(m_elementList.root); - while (current != bounds.second) { - Element *element = current->data; - Q_ASSERT(element->edgeNode == current); - int winding = element->winding; - if (element->originallyPointingUp) - ++winding; - const QPoint &lower = m_points->at(element->lowerIndex()); - if (lower == eventPoint) { - if (winding == 0 || winding == 1) - orderedElements.append(current->data); - } else { - // The element is passing through 'event.point'. - Q_ASSERT(m_points->at(element->upperIndex()) != eventPoint); - Q_ASSERT(element->degree == Element::Line); - // Split the line. - Element *eventElement = event->element; - int indexIndex = (event->type == Event::Upper) == eventElement->pointingUp - ? eventElement->degree : 0; - quint32 pointIndex = eventElement->indices[indexIndex]; - Q_ASSERT(eventPoint == m_points->at(pointIndex)); - - Element *upperElement = m_elementAllocator.newElement(); - *upperElement = *element; - upperElement->lowerIndex() = element->upperIndex() = pointIndex; - upperElement->edgeNode = 0; - element->next = element->previous = 0; - if (upperElement->next) - upperElement->next->previous = upperElement; - else if (upperElement->previous) - upperElement->previous->next = upperElement; - if (element->pointingUp != element->originallyPointingUp) - element->flip(); - if (winding == 0 || winding == 1) - orderedElements.append(upperElement); - m_elements.add(upperElement); - } - current = m_elementList.next(current); - } - } - while (!events.isEmpty() && events.last().point == eventPoint) { - event = &events.last(); - if (event->type == Event::Upper) { - Q_ASSERT(event->point == m_points->at(event->element->upperIndex())); - RBNode *left = findElementLeftOf(event->element, bounds); - RBNode *node = m_elementList.newNode(); - node->data = event->element; - Q_ASSERT(event->element->edgeNode == 0); - event->element->edgeNode = node; - m_elementList.attachAfter(left, node); - } else { - Q_ASSERT(event->type == Event::Lower); - Q_ASSERT(event->point == m_points->at(event->element->lowerIndex())); - Element *element = event->element; - Q_ASSERT(element->edgeNode); - m_elementList.deleteNode(element->edgeNode); - Q_ASSERT(element->edgeNode == 0); - } - events.pop_back(); - } - - if (m_elementList.root) { - RBNode *current = bounds.first ? m_elementList.next(bounds.first) - : m_elementList.front(m_elementList.root); - int winding = bounds.first ? bounds.first->data->winding : 0; - - // Calculate winding numbers and flip elements if necessary. - while (current != bounds.second) { - Element *element = current->data; - Q_ASSERT(element->edgeNode == current); - int ccw = winding & 1; - Q_ASSERT(element->pointingUp == element->originallyPointingUp); - if (element->originallyPointingUp) { - --winding; - } else { - ++winding; - ccw ^= 1; - } - element->winding = winding; - if (ccw == 0) - element->flip(); - current = m_elementList.next(current); - } - - // Pick elements with correct winding number. - current = bounds.second ? m_elementList.previous(bounds.second) - : m_elementList.back(m_elementList.root); - while (current != bounds.first) { - Element *element = current->data; - Q_ASSERT(element->edgeNode == current); - Q_ASSERT(m_points->at(element->upperIndex()) == eventPoint); - int winding = element->winding; - if (element->originallyPointingUp) - ++winding; - if (winding == 0 || winding == 1) - orderedElements.append(current->data); - current = m_elementList.previous(current); - } - } - - if (!orderedElements.isEmpty()) { - Q_ASSERT((orderedElements.size() & 1) == 0); - int i = 0; - Element *firstElement = orderedElements.at(0); - if (m_points->at(firstElement->indices[0]) != eventPoint) { - orderedElements.append(firstElement); - i = 1; - } - for (; i < orderedElements.size(); i += 2) { - Q_ASSERT(i + 1 < orderedElements.size()); - Element *next = orderedElements.at(i); - Element *previous = orderedElements.at(i + 1); - Q_ASSERT(next->previous == 0); - Q_ASSERT(previous->next == 0); - next->previous = previous; - previous->next = next; - } - } - } -#ifndef QT_NO_DEBUG - for (int i = 0; i < m_elements.size(); ++i) { - const Element *element = m_elements.at(i); - Q_ASSERT(element->next == 0 || element->next->previous == element); - Q_ASSERT(element->previous == 0 || element->previous->next == element); - Q_ASSERT((element->next == 0) == (element->previous == 0)); - } -#endif -} - -void PathSimplifier::fillIndices() -{ - for (int i = 0; i < m_elements.size(); ++i) - m_elements.at(i)->processed = false; - for (int i = 0; i < m_elements.size(); ++i) { - Element *element = m_elements.at(i); - if (element->processed || element->next == 0) - continue; - do { - m_indices->add(element->indices[0]); - switch (element->degree) { - case Element::Quadratic: - { - QPoint pts[] = { - m_points->at(element->indices[0]), - m_points->at(element->indices[1]), - m_points->at(element->indices[2]) - }; - subDivQuadratic(pts[0], pts[1], pts[2]); - } - break; - case Element::Cubic: - { - QPoint pts[] = { - m_points->at(element->indices[0]), - m_points->at(element->indices[1]), - m_points->at(element->indices[2]), - m_points->at(element->indices[3]) - }; - subDivCubic(pts[0], pts[1], pts[2], pts[3]); - } - break; - default: - break; - } - Q_ASSERT(element->next); - element->processed = true; - element = element->next; - } while (element != m_elements.at(i)); - m_indices->add(Q_TRIANGULATE_END_OF_POLYGON); - } -} - -PathSimplifier::BVHNode *PathSimplifier::buildTree(Element **elements, int elementCount) -{ - Q_ASSERT(elementCount > 0); - BVHNode *node = m_bvh.newNode(); - if (elementCount == 1) { - Element *element = *elements; - element->bvhNode = node; - node->type = BVHNode::Leaf; - node->element = element; - node->minimum = node->maximum = m_points->at(element->indices[0]); - for (int i = 1; i <= element->degree; ++i) { - const QPoint &p = m_points->at(element->indices[i]); - node->minimum.rx() = qMin(node->minimum.x(), p.x()); - node->minimum.ry() = qMin(node->minimum.y(), p.y()); - node->maximum.rx() = qMax(node->maximum.x(), p.x()); - node->maximum.ry() = qMax(node->maximum.y(), p.y()); - } - return node; - } - - node->type = BVHNode::Split; - - QPoint minimum, maximum; - minimum = maximum = elements[0]->middle; - - for (int i = 1; i < elementCount; ++i) { - const QPoint &p = elements[i]->middle; - minimum.rx() = qMin(minimum.x(), p.x()); - minimum.ry() = qMin(minimum.y(), p.y()); - maximum.rx() = qMax(maximum.x(), p.x()); - maximum.ry() = qMax(maximum.y(), p.y()); - } - - int comp, pivot; - if (maximum.x() - minimum.x() > maximum.y() - minimum.y()) { - comp = 0; - pivot = (maximum.x() + minimum.x()) >> 1; - } else { - comp = 1; - pivot = (maximum.y() + minimum.y()) >> 1; - } - - int lo = 0; - int hi = elementCount - 1; - while (lo < hi) { - while (lo < hi && (&elements[lo]->middle.rx())[comp] <= pivot) - ++lo; - while (lo < hi && (&elements[hi]->middle.rx())[comp] > pivot) - --hi; - if (lo < hi) - qSwap(elements[lo], elements[hi]); - } - - if (lo == elementCount) { - // All points are the same. - Q_ASSERT(minimum.x() == maximum.x() && minimum.y() == maximum.y()); - lo = elementCount >> 1; - } - - node->left = buildTree(elements, lo); - node->right = buildTree(elements + lo, elementCount - lo); - - const BVHNode *left = node->left; - const BVHNode *right = node->right; - node->minimum.rx() = qMin(left->minimum.x(), right->minimum.x()); - node->minimum.ry() = qMin(left->minimum.y(), right->minimum.y()); - node->maximum.rx() = qMax(left->maximum.x(), right->maximum.x()); - node->maximum.ry() = qMax(left->maximum.y(), right->maximum.y()); - - return node; -} - -bool PathSimplifier::intersectNodes(QDataBuffer &elements, BVHNode *elementNode, - BVHNode *treeNode) -{ - if (elementNode->minimum.x() >= treeNode->maximum.x() - || elementNode->minimum.y() >= treeNode->maximum.y() - || elementNode->maximum.x() <= treeNode->minimum.x() - || elementNode->maximum.y() <= treeNode->minimum.y()) - { - return false; - } - - Q_ASSERT(elementNode->type == BVHNode::Leaf); - Element *element = elementNode->element; - Q_ASSERT(!element->processed); - - if (treeNode->type == BVHNode::Leaf) { - Element *nodeElement = treeNode->element; - if (!nodeElement->processed) - return false; - - if (treeNode->element == elementNode->element) - return false; - - if (equalElements(treeNode->element, elementNode->element)) - return false; // element doesn't split itself. - - if (element->degree == Element::Line && nodeElement->degree == Element::Line) { - const QPoint &u1 = m_points->at(element->indices[0]); - const QPoint &u2 = m_points->at(element->indices[1]); - const QPoint &v1 = m_points->at(nodeElement->indices[0]); - const QPoint &v2 = m_points->at(nodeElement->indices[1]); - IntersectionPoint intersection = intersectionPoint(u1, u2, v1, v2); - if (!intersection.isValid()) - return false; - - Q_ASSERT(intersection.x.integer >= qMin(u1.x(), u2.x())); - Q_ASSERT(intersection.y.integer >= qMin(u1.y(), u2.y())); - Q_ASSERT(intersection.x.integer >= qMin(v1.x(), v2.x())); - Q_ASSERT(intersection.y.integer >= qMin(v1.y(), v2.y())); - - Q_ASSERT(intersection.x.integer <= qMax(u1.x(), u2.x())); - Q_ASSERT(intersection.y.integer <= qMax(u1.y(), u2.y())); - Q_ASSERT(intersection.x.integer <= qMax(v1.x(), v2.x())); - Q_ASSERT(intersection.y.integer <= qMax(v1.y(), v2.y())); - - m_points->add(intersection.round()); - splitLineAt(elements, treeNode, m_points->size() - 1, !intersection.isAccurate()); - return splitLineAt(elements, elementNode, m_points->size() - 1, false); - } else { - QVarLengthArray axes; - appendSeparatingAxes(axes, elementNode->element); - appendSeparatingAxes(axes, treeNode->element); - for (int i = 0; i < axes.size(); ++i) { - QPair range1 = calculateSeparatingAxisRange(axes.at(i), elementNode->element); - QPair range2 = calculateSeparatingAxisRange(axes.at(i), treeNode->element); - if (range1.first >= range2.second || range1.second <= range2.first) { - return false; // Separating axis found. - } - } - // Bounding areas overlap. - if (nodeElement->degree > Element::Line) - splitCurve(elements, treeNode); - if (element->degree > Element::Line) { - splitCurve(elements, elementNode); - } else { - // The element was not split, so it can be processed further. - if (intersectNodes(elements, elementNode, treeNode->left)) - return true; - if (intersectNodes(elements, elementNode, treeNode->right)) - return true; - return false; - } - return true; - } - } else { - if (intersectNodes(elements, elementNode, treeNode->left)) - return true; - if (intersectNodes(elements, elementNode, treeNode->right)) - return true; - return false; - } -} - -bool PathSimplifier::equalElements(const Element *e1, const Element *e2) -{ - Q_ASSERT(e1 != e2); - if (e1->degree != e2->degree) - return false; - - // Possibly equal and in the same direction. - bool equalSame = true; - for (int i = 0; i <= e1->degree; ++i) - equalSame &= m_points->at(e1->indices[i]) == m_points->at(e2->indices[i]); - - // Possibly equal and in opposite directions. - bool equalOpposite = true; - for (int i = 0; i <= e1->degree; ++i) - equalOpposite &= m_points->at(e1->indices[e1->degree - i]) == m_points->at(e2->indices[i]); - - return equalSame || equalOpposite; -} - -bool PathSimplifier::splitLineAt(QDataBuffer &elements, BVHNode *node, - quint32 pointIndex, bool processAgain) -{ - Q_ASSERT(node->type == BVHNode::Leaf); - Element *element = node->element; - Q_ASSERT(element->degree == Element::Line); - const QPoint &u = m_points->at(element->indices[0]); - const QPoint &v = m_points->at(element->indices[1]); - const QPoint &p = m_points->at(pointIndex); - if (u == p || v == p) - return false; // No split needed. - - if (processAgain) - element->processed = false; // Needs to be processed again. - - Element *first = node->element; - Element *second = m_elementAllocator.newElement(); - *second = *first; - first->indices[1] = second->indices[0] = pointIndex; - first->middle.rx() = (u.x() + p.x()) >> 1; - first->middle.ry() = (u.y() + p.y()) >> 1; - second->middle.rx() = (v.x() + p.x()) >> 1; - second->middle.ry() = (v.y() + p.y()) >> 1; - m_elements.add(second); - - BVHNode *left = m_bvh.newNode(); - BVHNode *right = m_bvh.newNode(); - left->type = right->type = BVHNode::Leaf; - left->element = first; - right->element = second; - left->minimum = right->minimum = node->minimum; - left->maximum = right->maximum = node->maximum; - if (u.x() < v.x()) - left->maximum.rx() = right->minimum.rx() = p.x(); - else - left->minimum.rx() = right->maximum.rx() = p.x(); - if (u.y() < v.y()) - left->maximum.ry() = right->minimum.ry() = p.y(); - else - left->minimum.ry() = right->maximum.ry() = p.y(); - left->element->bvhNode = left; - right->element->bvhNode = right; - - node->type = BVHNode::Split; - node->left = left; - node->right = right; - - if (!first->processed) { - elements.add(left->element); - elements.add(right->element); - } - return true; -} - -void PathSimplifier::appendSeparatingAxes(QVarLengthArray &axes, Element *element) -{ - switch (element->degree) { - case Element::Cubic: - { - const QPoint &u = m_points->at(element->indices[0]); - const QPoint &v = m_points->at(element->indices[1]); - const QPoint &w = m_points->at(element->indices[2]); - const QPoint &q = m_points->at(element->indices[3]); - QPoint ns[] = { - QPoint(u.y() - v.y(), v.x() - u.x()), - QPoint(v.y() - w.y(), w.x() - v.x()), - QPoint(w.y() - q.y(), q.x() - w.x()), - QPoint(q.y() - u.y(), u.x() - q.x()), - QPoint(u.y() - w.y(), w.x() - u.x()), - QPoint(v.y() - q.y(), q.x() - v.x()) - }; - for (int i = 0; i < 6; ++i) { - if (ns[i].x() || ns[i].y()) - axes.append(ns[i]); - } - } - break; - case Element::Quadratic: - { - const QPoint &u = m_points->at(element->indices[0]); - const QPoint &v = m_points->at(element->indices[1]); - const QPoint &w = m_points->at(element->indices[2]); - QPoint ns[] = { - QPoint(u.y() - v.y(), v.x() - u.x()), - QPoint(v.y() - w.y(), w.x() - v.x()), - QPoint(w.y() - u.y(), u.x() - w.x()) - }; - for (int i = 0; i < 3; ++i) { - if (ns[i].x() || ns[i].y()) - axes.append(ns[i]); - } - } - break; - case Element::Line: - { - const QPoint &u = m_points->at(element->indices[0]); - const QPoint &v = m_points->at(element->indices[1]); - QPoint n(u.y() - v.y(), v.x() - u.x()); - if (n.x() || n.y()) - axes.append(n); - } - break; - default: - Q_ASSERT_X(0, "QSGPathSimplifier::appendSeparatingAxes", "Unexpected element type."); - break; - } -} - -QPair PathSimplifier::calculateSeparatingAxisRange(const QPoint &axis, Element *element) -{ - QPair range(0x7fffffff, -0x7fffffff); - for (int i = 0; i <= element->degree; ++i) { - const QPoint &p = m_points->at(element->indices[i]); - int dist = dot(axis, p); - range.first = qMin(range.first, dist); - range.second = qMax(range.second, dist); - } - return range; -} - -void PathSimplifier::splitCurve(QDataBuffer &elements, BVHNode *node) -{ - Q_ASSERT(node->type == BVHNode::Leaf); - - Element *first = node->element; - Element *second = m_elementAllocator.newElement(); - *second = *first; - m_elements.add(second); - Q_ASSERT(first->degree > Element::Line); - - bool accurate = true; - const QPoint &u = m_points->at(first->indices[0]); - const QPoint &v = m_points->at(first->indices[1]); - const QPoint &w = m_points->at(first->indices[2]); - - if (first->degree == Element::Quadratic) { - QPoint pts[3]; - accurate = splitQuadratic(u, v, w, pts); - int pointIndex = m_points->size(); - m_points->add(pts[1]); - accurate &= setElementToQuadratic(first, first->indices[0], pts[0], pointIndex); - accurate &= setElementToQuadratic(second, pointIndex, pts[2], second->indices[2]); - } else { - Q_ASSERT(first->degree == Element::Cubic); - const QPoint &q = m_points->at(first->indices[3]); - QPoint pts[5]; - accurate = splitCubic(u, v, w, q, pts); - int pointIndex = m_points->size(); - m_points->add(pts[2]); - accurate &= setElementToCubic(first, first->indices[0], pts[0], pts[1], pointIndex); - accurate &= setElementToCubic(second, pointIndex, pts[3], pts[4], second->indices[3]); - } - - if (!accurate) - first->processed = second->processed = false; // Needs to be processed again. - - BVHNode *left = m_bvh.newNode(); - BVHNode *right = m_bvh.newNode(); - left->type = right->type = BVHNode::Leaf; - left->element = first; - right->element = second; - - left->minimum.rx() = left->minimum.ry() = right->minimum.rx() = right->minimum.ry() = INT_MAX; - left->maximum.rx() = left->maximum.ry() = right->maximum.rx() = right->maximum.ry() = INT_MIN; - - for (int i = 0; i <= first->degree; ++i) { - QPoint &p = m_points->at(first->indices[i]); - left->minimum.rx() = qMin(left->minimum.x(), p.x()); - left->minimum.ry() = qMin(left->minimum.y(), p.y()); - left->maximum.rx() = qMax(left->maximum.x(), p.x()); - left->maximum.ry() = qMax(left->maximum.y(), p.y()); - } - for (int i = 0; i <= second->degree; ++i) { - QPoint &p = m_points->at(second->indices[i]); - right->minimum.rx() = qMin(right->minimum.x(), p.x()); - right->minimum.ry() = qMin(right->minimum.y(), p.y()); - right->maximum.rx() = qMax(right->maximum.x(), p.x()); - right->maximum.ry() = qMax(right->maximum.y(), p.y()); - } - left->element->bvhNode = left; - right->element->bvhNode = right; - - node->type = BVHNode::Split; - node->left = left; - node->right = right; - - if (!first->processed) { - elements.add(left->element); - elements.add(right->element); - } -} - -bool PathSimplifier::setElementToQuadratic(Element *element, quint32 pointIndex1, - const QPoint &ctrl, quint32 pointIndex2) -{ - const QPoint &p1 = m_points->at(pointIndex1); - const QPoint &p2 = m_points->at(pointIndex2); - if (flattenQuadratic(p1, ctrl, p2)) { - // Insert line. - element->degree = Element::Line; - element->indices[0] = pointIndex1; - element->indices[1] = pointIndex2; - element->middle.rx() = (p1.x() + p2.x()) >> 1; - element->middle.ry() = (p1.y() + p2.y()) >> 1; - return false; - } else { - // Insert bezier. - element->degree = Element::Quadratic; - element->indices[0] = pointIndex1; - element->indices[1] = m_points->size(); - element->indices[2] = pointIndex2; - element->middle.rx() = (p1.x() + ctrl.x() + p2.x()) / 3; - element->middle.ry() = (p1.y() + ctrl.y() + p2.y()) / 3; - m_points->add(ctrl); - return true; - } -} - -bool PathSimplifier::setElementToCubic(Element *element, quint32 pointIndex1, const QPoint &v, - const QPoint &w, quint32 pointIndex2) -{ - const QPoint &u = m_points->at(pointIndex1); - const QPoint &q = m_points->at(pointIndex2); - if (flattenCubic(u, v, w, q)) { - // Insert line. - element->degree = Element::Line; - element->indices[0] = pointIndex1; - element->indices[1] = pointIndex2; - element->middle.rx() = (u.x() + q.x()) >> 1; - element->middle.ry() = (u.y() + q.y()) >> 1; - return false; - } else { - // Insert bezier. - element->degree = Element::Cubic; - element->indices[0] = pointIndex1; - element->indices[1] = m_points->size(); - element->indices[2] = m_points->size() + 1; - element->indices[3] = pointIndex2; - element->middle.rx() = (u.x() + v.x() + w.x() + q.x()) >> 2; - element->middle.ry() = (u.y() + v.y() + w.y() + q.y()) >> 2; - m_points->add(v); - m_points->add(w); - return true; - } -} - -void PathSimplifier::setElementToCubicAndSimplify(Element *element, quint32 pointIndex1, - const QPoint &v, const QPoint &w, - quint32 pointIndex2) -{ - const QPoint &u = m_points->at(pointIndex1); - const QPoint &q = m_points->at(pointIndex2); - if (flattenCubic(u, v, w, q)) { - // Insert line. - element->degree = Element::Line; - element->indices[0] = pointIndex1; - element->indices[1] = pointIndex2; - element->middle.rx() = (u.x() + q.x()) >> 1; - element->middle.ry() = (u.y() + q.y()) >> 1; - return; - } - - bool intersecting = (u == q) || intersectionPoint(u, v, w, q).isValid(); - if (!intersecting) { - // Insert bezier. - element->degree = Element::Cubic; - element->indices[0] = pointIndex1; - element->indices[1] = m_points->size(); - element->indices[2] = m_points->size() + 1; - element->indices[3] = pointIndex2; - element->middle.rx() = (u.x() + v.x() + w.x() + q.x()) >> 2; - element->middle.ry() = (u.y() + v.y() + w.y() + q.y()) >> 2; - m_points->add(v); - m_points->add(w); - return; - } - - QPoint pts[5]; - splitCubic(u, v, w, q, pts); - int pointIndex = m_points->size(); - m_points->add(pts[2]); - Element *element2 = m_elementAllocator.newElement(); - m_elements.add(element2); - setElementToCubicAndSimplify(element, pointIndex1, pts[0], pts[1], pointIndex); - setElementToCubicAndSimplify(element2, pointIndex, pts[3], pts[4], pointIndex2); -} - -PathSimplifier::RBNode *PathSimplifier::findElementLeftOf(const Element *element, - const QPair &bounds) -{ - if (!m_elementList.root) - return 0; - RBNode *current = bounds.first; - Q_ASSERT(!current || !elementIsLeftOf(element, current->data)); - if (!current) - current = m_elementList.front(m_elementList.root); - Q_ASSERT(current); - RBNode *result = 0; - while (current != bounds.second && !elementIsLeftOf(element, current->data)) { - result = current; - current = m_elementList.next(current); - } - return result; -} - -bool PathSimplifier::elementIsLeftOf(const Element *left, const Element *right) -{ - const QPoint &leftU = m_points->at(left->upperIndex()); - const QPoint &leftL = m_points->at(left->lowerIndex()); - const QPoint &rightU = m_points->at(right->upperIndex()); - const QPoint &rightL = m_points->at(right->lowerIndex()); - Q_ASSERT(leftL >= rightU && rightL >= leftU); - if (leftU.x() < qMin(rightL.x(), rightU.x())) - return true; - if (leftU.x() > qMax(rightL.x(), rightU.x())) - return false; - int d = pointDistanceFromLine(leftU, rightL, rightU); - // d < 0: left, d > 0: right, d == 0: on top - if (d == 0) { - d = pointDistanceFromLine(leftL, rightL, rightU); - if (d == 0) { - if (right->degree > Element::Line) { - d = pointDistanceFromLine(leftL, rightL, m_points->at(right->indices[1])); - if (d == 0) - d = pointDistanceFromLine(leftL, rightL, m_points->at(right->indices[2])); - } else if (left->degree > Element::Line) { - d = pointDistanceFromLine(m_points->at(left->indices[1]), rightL, rightU); - if (d == 0) - d = pointDistanceFromLine(m_points->at(left->indices[2]), rightL, rightU); - } - } - } - return d < 0; -} - -QPair PathSimplifier::outerBounds(const QPoint &point) -{ - RBNode *current = m_elementList.root; - QPair result(0, 0); - - while (current) { - const Element *element = current->data; - Q_ASSERT(element->edgeNode == current); - const QPoint &v1 = m_points->at(element->lowerIndex()); - const QPoint &v2 = m_points->at(element->upperIndex()); - Q_ASSERT(point >= v2 && point <= v1); - if (point == v1 || point == v2) - break; - int d = pointDistanceFromLine(point, v1, v2); - if (d == 0) { - if (element->degree == Element::Line) - break; - d = pointDistanceFromLine(point, v1, m_points->at(element->indices[1])); - if (d == 0) - d = pointDistanceFromLine(point, v1, m_points->at(element->indices[2])); - Q_ASSERT(d != 0); - } - if (d < 0) { - result.second = current; - current = current->left; - } else { - result.first = current; - current = current->right; - } - } - - if (!current) - return result; - - RBNode *mid = current; - - current = mid->left; - while (current) { - const Element *element = current->data; - Q_ASSERT(element->edgeNode == current); - const QPoint &v1 = m_points->at(element->lowerIndex()); - const QPoint &v2 = m_points->at(element->upperIndex()); - Q_ASSERT(point >= v2 && point <= v1); - bool equal = (point == v1 || point == v2); - if (!equal) { - int d = pointDistanceFromLine(point, v1, v2); - Q_ASSERT(d >= 0); - equal = (d == 0 && element->degree == Element::Line); - } - if (equal) { - current = current->left; - } else { - result.first = current; - current = current->right; - } - } - - current = mid->right; - while (current) { - const Element *element = current->data; - Q_ASSERT(element->edgeNode == current); - const QPoint &v1 = m_points->at(element->lowerIndex()); - const QPoint &v2 = m_points->at(element->upperIndex()); - Q_ASSERT(point >= v2 && point <= v1); - bool equal = (point == v1 || point == v2); - if (!equal) { - int d = pointDistanceFromLine(point, v1, v2); - Q_ASSERT(d <= 0); - equal = (d == 0 && element->degree == Element::Line); - } - if (equal) { - current = current->right; - } else { - result.second = current; - current = current->left; - } - } - - return result; -} - -inline bool PathSimplifier::flattenQuadratic(const QPoint &u, const QPoint &v, const QPoint &w) -{ - QPoint deltas[2] = { v - u, w - v }; - int d = qAbs(cross(deltas[0], deltas[1])); - int l = qAbs(deltas[0].x()) + qAbs(deltas[0].y()) + qAbs(deltas[1].x()) + qAbs(deltas[1].y()); - return d < (Q_FIXED_POINT_SCALE * Q_FIXED_POINT_SCALE * 3 / 2) || l <= Q_FIXED_POINT_SCALE * 2; -} - -inline bool PathSimplifier::flattenCubic(const QPoint &u, const QPoint &v, - const QPoint &w, const QPoint &q) -{ - QPoint deltas[] = { v - u, w - v, q - w, q - u }; - int d = qAbs(cross(deltas[0], deltas[1])) + qAbs(cross(deltas[1], deltas[2])) - + qAbs(cross(deltas[0], deltas[3])) + qAbs(cross(deltas[3], deltas[2])); - int l = qAbs(deltas[0].x()) + qAbs(deltas[0].y()) + qAbs(deltas[1].x()) + qAbs(deltas[1].y()) - + qAbs(deltas[2].x()) + qAbs(deltas[2].y()); - return d < (Q_FIXED_POINT_SCALE * Q_FIXED_POINT_SCALE * 3) || l <= Q_FIXED_POINT_SCALE * 2; -} - -inline bool PathSimplifier::splitQuadratic(const QPoint &u, const QPoint &v, - const QPoint &w, QPoint *result) -{ - result[0] = u + v; - result[2] = v + w; - result[1] = result[0] + result[2]; - bool accurate = ((result[0].x() | result[0].y() | result[2].x() | result[2].y()) & 1) == 0 - && ((result[1].x() | result[1].y()) & 3) == 0; - result[0].rx() >>= 1; - result[0].ry() >>= 1; - result[1].rx() >>= 2; - result[1].ry() >>= 2; - result[2].rx() >>= 1; - result[2].ry() >>= 1; - return accurate; -} - -inline bool PathSimplifier::splitCubic(const QPoint &u, const QPoint &v, - const QPoint &w, const QPoint &q, QPoint *result) -{ - result[0] = u + v; - result[2] = v + w; - result[4] = w + q; - result[1] = result[0] + result[2]; - result[3] = result[2] + result[4]; - result[2] = result[1] + result[3]; - bool accurate = ((result[0].x() | result[0].y() | result[4].x() | result[4].y()) & 1) == 0 - && ((result[1].x() | result[1].y() | result[3].x() | result[3].y()) & 3) == 0 - && ((result[2].x() | result[2].y()) & 7) == 0; - result[0].rx() >>= 1; - result[0].ry() >>= 1; - result[1].rx() >>= 2; - result[1].ry() >>= 2; - result[2].rx() >>= 3; - result[2].ry() >>= 3; - result[3].rx() >>= 2; - result[3].ry() >>= 2; - result[4].rx() >>= 1; - result[4].ry() >>= 1; - return accurate; -} - -inline void PathSimplifier::subDivQuadratic(const QPoint &u, const QPoint &v, const QPoint &w) -{ - if (flattenQuadratic(u, v, w)) - return; - QPoint pts[3]; - splitQuadratic(u, v, w, pts); - subDivQuadratic(u, pts[0], pts[1]); - m_indices->add(m_points->size()); - m_points->add(pts[1]); - subDivQuadratic(pts[1], pts[2], w); -} - -inline void PathSimplifier::subDivCubic(const QPoint &u, const QPoint &v, - const QPoint &w, const QPoint &q) -{ - if (flattenCubic(u, v, w, q)) - return; - QPoint pts[5]; - splitCubic(u, v, w, q, pts); - subDivCubic(u, pts[0], pts[1], pts[2]); - m_indices->add(m_points->size()); - m_points->add(pts[2]); - subDivCubic(pts[2], pts[3], pts[4], q); -} - -void PathSimplifier::sortEvents(Event *events, int count) -{ - // Bucket sort + insertion sort. - Q_ASSERT(count > 0); - QDataBuffer buffer(count); - buffer.resize(count); - QScopedArrayPointer bins(new int[count]); - int counts[0x101]; - memset(counts, 0, sizeof(counts)); - - int minimum, maximum; - minimum = maximum = events[0].point.y(); - for (int i = 1; i < count; ++i) { - minimum = qMin(minimum, events[i].point.y()); - maximum = qMax(maximum, events[i].point.y()); - } - - for (int i = 0; i < count; ++i) { - bins[i] = ((maximum - events[i].point.y()) << 8) / (maximum - minimum + 1); - Q_ASSERT(bins[i] >= 0 && bins[i] < 0x100); - ++counts[bins[i]]; - } - - for (int i = 1; i < 0x100; ++i) - counts[i] += counts[i - 1]; - counts[0x100] = counts[0xff]; - Q_ASSERT(counts[0x100] == count); - - for (int i = 0; i < count; ++i) - buffer.at(--counts[bins[i]]) = events[i]; - - int j = 0; - for (int i = 0; i < 0x100; ++i) { - for (; j < counts[i + 1]; ++j) { - int k = j; - while (k > 0 && (buffer.at(j) < events[k - 1])) { - events[k] = events[k - 1]; - --k; - } - events[k] = buffer.at(j); - } - } -} - -} // end anonymous namespace - - -void qSimplifyPath(const QVectorPath &path, QDataBuffer &vertices, - QDataBuffer &indices, const QTransform &matrix) -{ - PathSimplifier(path, vertices, indices, matrix); -} - -void qSimplifyPath(const QPainterPath &path, QDataBuffer &vertices, - QDataBuffer &indices, const QTransform &matrix) -{ - qSimplifyPath(qtVectorPathForPath(path), vertices, indices, matrix); -} - - -QT_END_NAMESPACE diff --git a/src/quick/scenegraph/qsgpathsimplifier_p.h b/src/quick/scenegraph/qsgpathsimplifier_p.h deleted file mode 100644 index e60dc4fe37..0000000000 --- a/src/quick/scenegraph/qsgpathsimplifier_p.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSGPATHSIMPLIFIER_P_H -#define QSGPATHSIMPLIFIER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -// The returned vertices are in 8:8 fixed point format. The path is assumed to be in the range (-128, 128)x(-128, 128). -void qSimplifyPath(const QVectorPath &path, QDataBuffer &vertices, QDataBuffer &indices, const QTransform &matrix = QTransform()); -void qSimplifyPath(const QPainterPath &path, QDataBuffer &vertices, QDataBuffer &indices, const QTransform &matrix = QTransform()); - -QT_END_NAMESPACE - -#endif diff --git a/src/quick/scenegraph/scenegraph.pri b/src/quick/scenegraph/scenegraph.pri index dae4a3b8a8..f5fa18f87a 100644 --- a/src/quick/scenegraph/scenegraph.pri +++ b/src/quick/scenegraph/scenegraph.pri @@ -64,7 +64,6 @@ HEADERS += \ $$PWD/qsgdefaultimagenode_p.h \ $$PWD/qsgdefaultrectanglenode_p.h \ $$PWD/qsgflashnode_p.h \ - $$PWD/qsgpathsimplifier_p.h \ $$PWD/qsgshareddistancefieldglyphcache_p.h SOURCES += \ @@ -79,7 +78,6 @@ SOURCES += \ $$PWD/qsgdefaultimagenode.cpp \ $$PWD/qsgdefaultrectanglenode.cpp \ $$PWD/qsgflashnode.cpp \ - $$PWD/qsgpathsimplifier.cpp \ $$PWD/qsgshareddistancefieldglyphcache.cpp diff --git a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp index be4673bdca..a8d73ed7d1 100644 --- a/src/quick/scenegraph/util/qsgdistancefieldutil.cpp +++ b/src/quick/scenegraph/util/qsgdistancefieldutil.cpp @@ -41,8 +41,6 @@ #include "qsgdistancefieldutil_p.h" -#include -#include #include #include #include @@ -64,718 +62,6 @@ static float defaultAntialiasingSpreadFunc(float glyphScale) return range / glyphScale; } -namespace -{ - enum FillHDir - { - LeftToRight, - RightToLeft - }; - - enum FillVDir - { - TopDown, - BottomUp - }; - - enum FillClip - { - NoClip, - Clip - }; -} - -template -inline void fillLine(qint32 *, int, int, int, qint32, qint32) -{ -} - -template <> -inline void fillLine(qint32 *line, int width, int lx, int rx, qint32 d, qint32 dd) -{ - int fromX = qMax(0, lx >> 8); - int toX = qMin(width, rx >> 8); - int x = toX - fromX; - if (x <= 0) - return; - qint32 val = d + (((fromX << 8) + 0xff - lx) * dd >> 8); - line += fromX; - do { - *line = abs(val) < abs(*line) ? val : *line; - val += dd; - ++line; - } while (--x); -} - -template <> -inline void fillLine(qint32 *line, int width, int lx, int rx, qint32 d, qint32 dd) -{ - int fromX = qMax(0, lx >> 8); - int toX = qMin(width, rx >> 8); - int x = toX - fromX; - if (x <= 0) - return; - qint32 val = d + (((toX << 8) + 0xff - rx) * dd >> 8); - line += toX; - do { - val -= dd; - --line; - *line = abs(val) < abs(*line) ? val : *line; - } while (--x); -} - -template <> -inline void fillLine(qint32 *line, int, int lx, int rx, qint32 d, qint32 dd) -{ - int fromX = lx >> 8; - int toX = rx >> 8; - int x = toX - fromX; - if (x <= 0) - return; - qint32 val = d + ((~lx & 0xff) * dd >> 8); - line += fromX; - do { - *line = abs(val) < abs(*line) ? val : *line; - val += dd; - ++line; - } while (--x); -} - -template <> -inline void fillLine(qint32 *line, int, int lx, int rx, qint32 d, qint32 dd) -{ - int fromX = lx >> 8; - int toX = rx >> 8; - int x = toX - fromX; - if (x <= 0) - return; - qint32 val = d + ((~rx & 0xff) * dd >> 8); - line += toX; - do { - val -= dd; - --line; - *line = abs(val) < abs(*line) ? val : *line; - } while (--x); -} - -template -inline void fillLines(qint32 *bits, int width, int height, int upperY, int lowerY, - int &lx, int ldx, int &rx, int rdx, qint32 &d, qint32 ddy, qint32 ddx) -{ - Q_UNUSED(height); - Q_ASSERT(upperY < lowerY); - int y = lowerY - upperY; - if (vDir == TopDown) { - qint32 *line = bits + upperY * width; - do { - fillLine(line, width, lx, rx, d, ddx); - lx += ldx; - d += ddy; - rx += rdx; - line += width; - } while (--y); - } else { - qint32 *line = bits + lowerY * width; - do { - lx -= ldx; - d -= ddy; - rx -= rdx; - line -= width; - fillLine(line, width, lx, rx, d, ddx); - } while (--y); - } -} - -template -void drawTriangle(qint32 *bits, int width, int height, const QPoint *center, - const QPoint *v1, const QPoint *v2, qint32 value) -{ - const int y1 = clip == Clip ? qBound(0, v1->y() >> 8, height) : v1->y() >> 8; - const int y2 = clip == Clip ? qBound(0, v2->y() >> 8, height) : v2->y() >> 8; - const int yC = clip == Clip ? qBound(0, center->y() >> 8, height) : center->y() >> 8; - - const int v1Frac = clip == Clip ? (y1 << 8) + 0xff - v1->y() : ~v2->y() & 0xff; - const int v2Frac = clip == Clip ? (y2 << 8) + 0xff - v2->y() : ~v1->y() & 0xff; - const int centerFrac = clip == Clip ? (yC << 8) + 0xff - center->y() : ~center->y() & 0xff; - - int dx1 = 0, x1 = 0, dx2 = 0, x2 = 0; - qint32 dd1, d1, dd2, d2; - if (v1->y() != center->y()) { - dx1 = ((v1->x() - center->x()) << 8) / (v1->y() - center->y()); - x1 = center->x() + centerFrac * (v1->x() - center->x()) / (v1->y() - center->y()); - } - if (v2->y() != center->y()) { - dx2 = ((v2->x() - center->x()) << 8) / (v2->y() - center->y()); - x2 = center->x() + centerFrac * (v2->x() - center->x()) / (v2->y() - center->y()); - } - - const qint32 div = (v2->x() - center->x()) * (v1->y() - center->y()) - - (v2->y() - center->y()) * (v1->x() - center->x()); - const qint32 dd = div ? qint32((qint64(value * (v1->y() - v2->y())) << 8) / div) : 0; - - if (y2 < yC) { - if (y1 < yC) { - // Center at the bottom. - if (y2 < y1) { - // y2 < y1 < yC - // Long right edge. - d1 = centerFrac * value / (v1->y() - center->y()); - dd1 = ((value << 8) / (v1->y() - center->y())); - fillLines(bits, width, height, y1, yC, x1, dx1, - x2, dx2, d1, dd1, dd); - dx1 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); - x1 = v1->x() + v1Frac * (v1->x() - v2->x()) / (v1->y() - v2->y()); - fillLines(bits, width, height, y2, y1, x1, dx1, - x2, dx2, value, 0, dd); - } else { - // y1 <= y2 < yC - // Long left edge. - d2 = centerFrac * value / (v2->y() - center->y()); - dd2 = ((value << 8) / (v2->y() - center->y())); - fillLines(bits, width, height, y2, yC, x1, dx1, - x2, dx2, d2, dd2, dd); - if (y1 != y2) { - dx2 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); - x2 = v2->x() + v2Frac * (v1->x() - v2->x()) / (v1->y() - v2->y()); - fillLines(bits, width, height, y1, y2, x1, dx1, - x2, dx2, value, 0, dd); - } - } - } else { - // y2 < yC <= y1 - // Center to the right. - int dx = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); - int xUp, xDn; - xUp = xDn = v2->x() + (clip == Clip ? (yC << 8) + 0xff - v2->y() - : (center->y() | 0xff) - v2->y()) - * (v1->x() - v2->x()) / (v1->y() - v2->y()); - fillLines(bits, width, height, y2, yC, xUp, dx, - x2, dx2, value, 0, dd); - if (yC != y1) - fillLines(bits, width, height, yC, y1, xDn, dx, - x1, dx1, value, 0, dd); - } - } else { - if (y1 < yC) { - // y1 < yC <= y2 - // Center to the left. - int dx = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); - int xUp, xDn; - xUp = xDn = v1->x() + (clip == Clip ? (yC << 8) + 0xff - v1->y() - : (center->y() | 0xff) - v1->y()) - * (v1->x() - v2->x()) / (v1->y() - v2->y()); - fillLines(bits, width, height, y1, yC, x1, dx1, - xUp, dx, value, 0, dd); - if (yC != y2) - fillLines(bits, width, height, yC, y2, x2, dx2, - xDn, dx, value, 0, dd); - } else { - // Center at the top. - if (y2 < y1) { - // yC <= y2 < y1 - // Long right edge. - if (yC != y2) { - d2 = centerFrac * value / (v2->y() - center->y()); - dd2 = ((value << 8) / (v2->y() - center->y())); - fillLines(bits, width, height, yC, y2, x2, dx2, - x1, dx1, d2, dd2, dd); - } - dx2 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); - x2 = v2->x() + v2Frac * (v1->x() - v2->x()) / (v1->y() - v2->y()); - fillLines(bits, width, height, y2, y1, x2, dx2, - x1, dx1, value, 0, dd); - } else { - // Long left edge. - // yC <= y1 <= y2 - if (yC != y1) { - d1 = centerFrac * value / (v1->y() - center->y()); - dd1 = ((value << 8) / (v1->y() - center->y())); - fillLines(bits, width, height, yC, y1, x2, dx2, - x1, dx1, d1, dd1, dd); - } - if (y1 != y2) { - dx1 = ((v1->x() - v2->x()) << 8) / (v1->y() - v2->y()); - x1 = v1->x() + v1Frac * (v1->x() - v2->x()) / (v1->y() - v2->y()); - fillLines(bits, width, height, y1, y2, x2, dx2, - x1, dx1, value, 0, dd); - } - } - } - } -} - -template -void drawRectangle(qint32 *bits, int width, int height, - const QPoint *int1, const QPoint *center1, const QPoint *ext1, - const QPoint *int2, const QPoint *center2, const QPoint *ext2, - qint32 extValue) -{ - if (center1->y() > center2->y()) { - qSwap(center1, center2); - qSwap(int1, ext2); - qSwap(ext1, int2); - extValue = -extValue; - } - - Q_ASSERT(ext1->x() - center1->x() == center1->x() - int1->x()); - Q_ASSERT(ext1->y() - center1->y() == center1->y() - int1->y()); - Q_ASSERT(ext2->x() - center2->x() == center2->x() - int2->x()); - Q_ASSERT(ext2->y() - center2->y() == center2->y() - int2->y()); - - const int yc1 = clip == Clip ? qBound(0, center1->y() >> 8, height) : center1->y() >> 8; - const int yc2 = clip == Clip ? qBound(0, center2->y() >> 8, height) : center2->y() >> 8; - const int yi1 = clip == Clip ? qBound(0, int1->y() >> 8, height) : int1->y() >> 8; - const int yi2 = clip == Clip ? qBound(0, int2->y() >> 8, height) : int2->y() >> 8; - const int ye1 = clip == Clip ? qBound(0, ext1->y() >> 8, height) : ext1->y() >> 8; - const int ye2 = clip == Clip ? qBound(0, ext2->y() >> 8, height) : ext2->y() >> 8; - - const int center1Frac = clip == Clip ? (yc1 << 8) + 0xff - center1->y() : ~center1->y() & 0xff; - const int center2Frac = clip == Clip ? (yc2 << 8) + 0xff - center2->y() : ~center2->y() & 0xff; - const int int1Frac = clip == Clip ? (yi1 << 8) + 0xff - int1->y() : ~int1->y() & 0xff; - const int ext1Frac = clip == Clip ? (ye1 << 8) + 0xff - ext1->y() : ~ext1->y() & 0xff; - - int dxC = 0, dxE = 0; // cap slope, edge slope - qint32 ddC = 0; - if (ext1->y() != int1->y()) { - dxC = ((ext1->x() - int1->x()) << 8) / (ext1->y() - int1->y()); - ddC = (extValue << 9) / (ext1->y() - int1->y()); - } - if (ext1->y() != ext2->y()) - dxE = ((ext1->x() - ext2->x()) << 8) / (ext1->y() - ext2->y()); - - const qint32 div = (ext1->x() - int1->x()) * (ext2->y() - int1->y()) - - (ext1->y() - int1->y()) * (ext2->x() - int1->x()); - const qint32 dd = div ? qint32((qint64(extValue * (ext2->y() - ext1->y())) << 9) / div) : 0; - - int xe1, xe2, xc1, xc2; - qint32 d; - - qint32 intValue = -extValue; - - if (center2->x() < center1->x()) { - // Leaning to the right. '/' - if (int1->y() < ext2->y()) { - // Mostly vertical. - Q_ASSERT(ext1->y() != ext2->y()); - xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); - xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); - if (ye1 != yi1) { - xc2 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); - xc2 += (ye1 - yc1) * dxC; - fillLines(bits, width, height, ye1, yi1, xe1, dxE, - xc2, dxC, extValue, 0, dd); - } - if (yi1 != ye2) - fillLines(bits, width, height, yi1, ye2, xe1, dxE, - xe2, dxE, extValue, 0, dd); - if (ye2 != yi2) { - xc1 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); - xc1 += (ye2 - yc2) * dxC; - fillLines(bits, width, height, ye2, yi2, xc1, dxC, - xe2, dxE, intValue, 0, dd); - } - } else { - // Mostly horizontal. - Q_ASSERT(ext1->y() != int1->y()); - xc1 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); - xc2 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); - xc1 += (ye2 - yc2) * dxC; - xc2 += (ye1 - yc1) * dxC; - if (ye1 != ye2) { - xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); - fillLines(bits, width, height, ye1, ye2, xe1, dxE, - xc2, dxC, extValue, 0, dd); - } - if (ye2 != yi1) { - d = (clip == Clip ? (ye2 << 8) + 0xff - center2->y() - : (ext2->y() | 0xff) - center2->y()) - * 2 * extValue / (ext1->y() - int1->y()); - fillLines(bits, width, height, ye2, yi1, xc1, dxC, - xc2, dxC, d, ddC, dd); - } - if (yi1 != yi2) { - xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); - fillLines(bits, width, height, yi1, yi2, xc1, dxC, - xe2, dxE, intValue, 0, dd); - } - } - } else { - // Leaning to the left. '\' - if (ext1->y() < int2->y()) { - // Mostly vertical. - Q_ASSERT(ext1->y() != ext2->y()); - xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); - xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); - if (yi1 != ye1) { - xc1 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); - xc1 += (yi1 - yc1) * dxC; - fillLines(bits, width, height, yi1, ye1, xc1, dxC, - xe2, dxE, intValue, 0, dd); - } - if (ye1 != yi2) - fillLines(bits, width, height, ye1, yi2, xe1, dxE, - xe2, dxE, intValue, 0, dd); - if (yi2 != ye2) { - xc2 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); - xc2 += (yi2 - yc2) * dxC; - fillLines(bits, width, height, yi2, ye2, xe1, dxE, - xc2, dxC, extValue, 0, dd); - } - } else { - // Mostly horizontal. - Q_ASSERT(ext1->y() != int1->y()); - xc1 = center1->x() + center1Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); - xc2 = center2->x() + center2Frac * (ext1->x() - int1->x()) / (ext1->y() - int1->y()); - xc1 += (yi1 - yc1) * dxC; - xc2 += (yi2 - yc2) * dxC; - if (yi1 != yi2) { - xe2 = int1->x() + int1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); - fillLines(bits, width, height, yi1, yi2, xc1, dxC, - xe2, dxE, intValue, 0, dd); - } - if (yi2 != ye1) { - d = (clip == Clip ? (yi2 << 8) + 0xff - center2->y() - : (int2->y() | 0xff) - center2->y()) - * 2 * extValue / (ext1->y() - int1->y()); - fillLines(bits, width, height, yi2, ye1, xc1, dxC, - xc2, dxC, d, ddC, dd); - } - if (ye1 != ye2) { - xe1 = ext1->x() + ext1Frac * (ext1->x() - ext2->x()) / (ext1->y() - ext2->y()); - fillLines(bits, width, height, ye1, ye2, xe1, dxE, - xc2, dxC, extValue, 0, dd); - } - } - } -} - -static void drawPolygons(qint32 *bits, int width, int height, const QPoint *vertices, - const quint32 *indices, int indexCount, qint32 value) -{ - Q_ASSERT(indexCount != 0); - Q_ASSERT(height <= 128); - QVarLengthArray scans[128]; - int first = 0; - for (int i = 1; i < indexCount; ++i) { - quint32 idx1 = indices[i - 1]; - quint32 idx2 = indices[i]; - Q_ASSERT(idx1 != quint32(-1)); - if (idx2 == quint32(-1)) { - idx2 = indices[first]; - Q_ASSERT(idx2 != quint32(-1)); - first = ++i; - } - const QPoint *v1 = &vertices[idx1]; - const QPoint *v2 = &vertices[idx2]; - if (v2->y() < v1->y()) - qSwap(v1, v2); - int fromY = qMax(0, v1->y() >> 8); - int toY = qMin(height, v2->y() >> 8); - if (fromY >= toY) - continue; - int dx = ((v2->x() - v1->x()) << 8) / (v2->y() - v1->y()); - int x = v1->x() + ((fromY << 8) + 0xff - v1->y()) * (v2->x() - v1->x()) / (v2->y() - v1->y()); - for (int y = fromY; y < toY; ++y) { - quint32 c = quint32(x >> 8); - if (c < quint32(width)) - scans[y].append(quint8(c)); - x += dx; - } - } - for (int i = 0; i < height; ++i) { - quint8 *scanline = scans[i].data(); - int size = scans[i].size(); - for (int j = 1; j < size; ++j) { - int k = j; - quint8 value = scanline[k]; - for (; k != 0 && value < scanline[k - 1]; --k) - scanline[k] = scanline[k - 1]; - scanline[k] = value; - } - qint32 *line = bits + i * width; - int j = 0; - for (; j + 1 < size; j += 2) { - for (quint8 x = scanline[j]; x < scanline[j + 1]; ++x) - line[x] = value; - } - if (j < size) { - for (int x = scanline[j]; x < width; ++x) - line[x] = value; - } - } -} - -static QImage makeDistanceField(int imgSize, const QPainterPath &path, int dfScale, int offs) -{ - QImage image(imgSize, imgSize, QImage::Format_Indexed8); - - if (path.isEmpty()) { - image.fill(0); - return image; - } - - QTransform transform; - transform.translate(offs, offs); - transform.scale(qreal(1) / dfScale, qreal(1) / dfScale); - - QDataBuffer pathIndices(0); - QDataBuffer pathVertices(0); - qSimplifyPath(path, pathVertices, pathIndices, transform); - - const qint32 interiorColor = -0x7f80; // 8:8 signed format, -127.5 - const qint32 exteriorColor = 0x7f80; // 8:8 signed format, 127.5 - - QScopedArrayPointer bits(new qint32[imgSize * imgSize]); - for (int i = 0; i < imgSize * imgSize; ++i) - bits[i] = exteriorColor; - - const qreal angleStep = qreal(15 * 3.141592653589793238 / 180); - const QPoint rotation(qRound(cos(angleStep) * 0x4000), - qRound(sin(angleStep) * 0x4000)); // 2:14 signed - - const quint32 *indices = pathIndices.data(); - QVarLengthArray normals; - QVarLengthArray vertices; - QVarLengthArray isConvex; - QVarLengthArray needsClipping; - - drawPolygons(bits.data(), imgSize, imgSize, pathVertices.data(), indices, pathIndices.size(), - interiorColor); - - int index = 0; - - while (index < pathIndices.size()) { - normals.clear(); - vertices.clear(); - needsClipping.clear(); - - // Find end of polygon. - int end = index; - while (indices[end] != quint32(-1)) - ++end; - - // Calculate vertex normals. - for (int next = index, prev = end - 1; next < end; prev = next++) { - quint32 fromVertexIndex = indices[prev]; - quint32 toVertexIndex = indices[next]; - - const QPoint &from = pathVertices.at(fromVertexIndex); - const QPoint &to = pathVertices.at(toVertexIndex); - - QPoint n(to.y() - from.y(), from.x() - to.x()); - if (n.x() == 0 && n.y() == 0) - continue; - int scale = qRound((offs << 16) / sqrt(qreal(n.x() * n.x() + n.y() * n.y()))); // 8:16 - n.rx() = n.x() * scale >> 8; - n.ry() = n.y() * scale >> 8; - normals.append(n); - QPoint v(to.x() + 0x7f, to.y() + 0x7f); - vertices.append(v); - needsClipping.append((to.x() < offs << 8) || (to.x() >= (imgSize - offs) << 8) - || (to.y() < offs << 8) || (to.y() >= (imgSize - offs) << 8)); - } - - isConvex.resize(normals.count()); - for (int next = 0, prev = normals.count() - 1; next < normals.count(); prev = next++) { - isConvex[prev] = normals.at(prev).x() * normals.at(next).y() - - normals.at(prev).y() * normals.at(next).x() < 0; - } - - // Draw quads. - for (int next = 0, prev = normals.count() - 1; next < normals.count(); prev = next++) { - QPoint n = normals.at(next); - QPoint intPrev = vertices.at(prev); - QPoint extPrev = vertices.at(prev); - QPoint intNext = vertices.at(next); - QPoint extNext = vertices.at(next); - - extPrev.rx() -= n.x(); - extPrev.ry() -= n.y(); - intPrev.rx() += n.x(); - intPrev.ry() += n.y(); - extNext.rx() -= n.x(); - extNext.ry() -= n.y(); - intNext.rx() += n.x(); - intNext.ry() += n.y(); - - if (needsClipping[prev] || needsClipping[next]) { - drawRectangle(bits.data(), imgSize, imgSize, - &intPrev, &vertices.at(prev), &extPrev, - &intNext, &vertices.at(next), &extNext, - exteriorColor); - } else { - drawRectangle(bits.data(), imgSize, imgSize, - &intPrev, &vertices.at(prev), &extPrev, - &intNext, &vertices.at(next), &extNext, - exteriorColor); - } - - if (isConvex.at(prev)) { - QPoint p = extPrev; - if (needsClipping[prev]) { - for (;;) { - QPoint rn((n.x() * rotation.x() - n.y() * rotation.y()) >> 14, - (n.y() * rotation.x() + n.x() * rotation.y()) >> 14); - n = rn; - if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() <= 0) { - p.rx() = vertices.at(prev).x() - normals.at(prev).x(); - p.ry() = vertices.at(prev).y() - normals.at(prev).y(); - drawTriangle(bits.data(), imgSize, imgSize, &vertices.at(prev), - &extPrev, &p, exteriorColor); - break; - } - - p.rx() = vertices.at(prev).x() - n.x(); - p.ry() = vertices.at(prev).y() - n.y(); - drawTriangle(bits.data(), imgSize, imgSize, &vertices.at(prev), - &extPrev, &p, exteriorColor); - extPrev = p; - } - } else { - for (;;) { - QPoint rn((n.x() * rotation.x() - n.y() * rotation.y()) >> 14, - (n.y() * rotation.x() + n.x() * rotation.y()) >> 14); - n = rn; - if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() <= 0) { - p.rx() = vertices.at(prev).x() - normals.at(prev).x(); - p.ry() = vertices.at(prev).y() - normals.at(prev).y(); - drawTriangle(bits.data(), imgSize, imgSize, &vertices.at(prev), - &extPrev, &p, exteriorColor); - break; - } - - p.rx() = vertices.at(prev).x() - n.x(); - p.ry() = vertices.at(prev).y() - n.y(); - drawTriangle(bits.data(), imgSize, imgSize, &vertices.at(prev), - &extPrev, &p, exteriorColor); - extPrev = p; - } - } - } else { - QPoint p = intPrev; - if (needsClipping[prev]) { - for (;;) { - QPoint rn((n.x() * rotation.x() + n.y() * rotation.y()) >> 14, - (n.y() * rotation.x() - n.x() * rotation.y()) >> 14); - n = rn; - if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() >= 0) { - p.rx() = vertices.at(prev).x() + normals.at(prev).x(); - p.ry() = vertices.at(prev).y() + normals.at(prev).y(); - drawTriangle(bits.data(), imgSize, imgSize, &vertices.at(prev), - &p, &intPrev, interiorColor); - break; - } - - p.rx() = vertices.at(prev).x() + n.x(); - p.ry() = vertices.at(prev).y() + n.y(); - drawTriangle(bits.data(), imgSize, imgSize, &vertices.at(prev), - &p, &intPrev, interiorColor); - intPrev = p; - } - } else { - for (;;) { - QPoint rn((n.x() * rotation.x() + n.y() * rotation.y()) >> 14, - (n.y() * rotation.x() - n.x() * rotation.y()) >> 14); - n = rn; - if (n.x() * normals.at(prev).y() - n.y() * normals.at(prev).x() >= 0) { - p.rx() = vertices.at(prev).x() + normals.at(prev).x(); - p.ry() = vertices.at(prev).y() + normals.at(prev).y(); - drawTriangle(bits.data(), imgSize, imgSize, &vertices.at(prev), - &p, &intPrev, interiorColor); - break; - } - - p.rx() = vertices.at(prev).x() + n.x(); - p.ry() = vertices.at(prev).y() + n.y(); - drawTriangle(bits.data(), imgSize, imgSize, &vertices.at(prev), - &p, &intPrev, interiorColor); - intPrev = p; - } - } - } - } - - index = end + 1; - } - - const qint32 *inLine = bits.data(); - uchar *outLine = image.bits(); - int padding = image.bytesPerLine() - image.width(); - for (int y = 0; y < imgSize; ++y) { - for (int x = 0; x < imgSize; ++x, ++inLine, ++outLine) - *outLine = uchar((0x7f80 - *inLine) >> 8); - outLine += padding; - } - - return image; -} - -bool qt_fontHasNarrowOutlines(const QRawFont &f) -{ - QRawFont font = f; - font.setPixelSize(QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE); - Q_ASSERT(font.isValid()); - - QVector glyphIndices = font.glyphIndexesForString(QLatin1String("O")); - if (glyphIndices.size() < 1) - return false; - - QImage im = font.alphaMapForGlyph(glyphIndices.at(0), QRawFont::PixelAntialiasing); - if (im.isNull()) - return false; - - int minHThick = 999; - int minVThick = 999; - - int thick = 0; - bool in = false; - int y = (im.height() + 1) / 2; - for (int x = 0; x < im.width(); ++x) { - int a = qAlpha(im.pixel(x, y)); - if (a > 127) { - in = true; - ++thick; - } else if (in) { - in = false; - minHThick = qMin(minHThick, thick); - thick = 0; - } - } - - thick = 0; - in = false; - int x = (im.width() + 1) / 2; - for (int y = 0; y < im.height(); ++y) { - int a = qAlpha(im.pixel(x, y)); - if (a > 127) { - in = true; - ++thick; - } else if (in) { - in = false; - minVThick = qMin(minVThick, thick); - thick = 0; - } - } - - return minHThick == 1 || minVThick == 1; -} - -QImage qt_renderDistanceFieldGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution) -{ - QRawFont renderFont = font; - renderFont.setPixelSize(QT_DISTANCEFIELD_BASEFONTSIZE(doubleResolution) * QT_DISTANCEFIELD_SCALE(doubleResolution)); - - QPainterPath path = renderFont.pathForGlyph(glyph); - path.translate(-path.boundingRect().topLeft()); - path.setFillRule(Qt::WindingFill); - - QImage im = makeDistanceField(QT_DISTANCEFIELD_TILESIZE(doubleResolution), - path, - QT_DISTANCEFIELD_SCALE(doubleResolution), - QT_DISTANCEFIELD_RADIUS(doubleResolution) / QT_DISTANCEFIELD_SCALE(doubleResolution)); - return im; -} - QSGDistanceFieldGlyphCacheManager::QSGDistanceFieldGlyphCacheManager(QSGContext *c) : sgCtx(c) , m_threshold_func(defaultThresholdFunc) diff --git a/src/quick/scenegraph/util/qsgdistancefieldutil_p.h b/src/quick/scenegraph/util/qsgdistancefieldutil_p.h index 23da1d121f..bc1dbc2c72 100644 --- a/src/quick/scenegraph/util/qsgdistancefieldutil_p.h +++ b/src/quick/scenegraph/util/qsgdistancefieldutil_p.h @@ -48,33 +48,9 @@ QT_BEGIN_NAMESPACE -#define QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE 54 -#define QT_DISTANCEFIELD_DEFAULT_TILESIZE 64 -#define QT_DISTANCEFIELD_DEFAULT_SCALE 16 -#define QT_DISTANCEFIELD_DEFAULT_RADIUS 80 -#define QT_DISTANCEFIELD_HIGHGLYPHCOUNT 2000 - -#define QT_DISTANCEFIELD_BASEFONTSIZE(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE * 2 : \ - QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE) -#define QT_DISTANCEFIELD_TILESIZE(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_TILESIZE * 2 : \ - QT_DISTANCEFIELD_DEFAULT_TILESIZE) -#define QT_DISTANCEFIELD_SCALE(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_SCALE / 2 : \ - QT_DISTANCEFIELD_DEFAULT_SCALE) -#define QT_DISTANCEFIELD_RADIUS(NarrowOutlineFont) \ - (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_RADIUS / 2 : \ - QT_DISTANCEFIELD_DEFAULT_RADIUS) - - typedef float (*ThresholdFunc)(float glyphScale); typedef float (*AntialiasingSpreadFunc)(float glyphScale); -bool qt_fontHasNarrowOutlines(const QRawFont &f); -QImage qt_renderDistanceFieldGlyph(const QRawFont &font, glyph_t glyph, bool doubleResolution); - - class QOpenGLShaderProgram; class QSGDistanceFieldGlyphCache; class QSGContext; -- cgit v1.2.3 From f7dae3960b2ab6f5db3a79e3ea701f2531b909d7 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 14 Feb 2012 09:33:42 +1000 Subject: Add AnimatedSprite A simpler sprite image element for the simple usecase. Because sometimes an engine with stochastic capabilities is overkill. Change-Id: I2b76c5d417719e92a548f6266bffd563dc016983 Reviewed-by: Alan Alpert --- examples/qtquick/imageelements/animatedsprite.qml | 74 +++ examples/qtquick/imageelements/simplesprite.qml | 59 -- src/quick/items/items.pri | 2 + src/quick/items/qquickanimatedsprite.cpp | 613 +++++++++++++++++++++ src/quick/items/qquickanimatedsprite_p.h | 373 +++++++++++++ src/quick/items/qquickitemsmodule.cpp | 2 + src/quick/items/qquicksprite_p.h | 1 + .../qtquick2/qquickanimatedsprite/data/basic.qml | 58 ++ .../qquickanimatedsprite/data/squarefacesprite.png | Bin 0 -> 496 bytes .../qquickanimatedsprite/qquickanimatedsprite.pro | 15 + .../tst_qquickanimatedsprite.cpp | 83 +++ tests/auto/qtquick2/qtquick2.pro | 1 + 12 files changed, 1222 insertions(+), 59 deletions(-) create mode 100644 examples/qtquick/imageelements/animatedsprite.qml delete mode 100644 examples/qtquick/imageelements/simplesprite.qml create mode 100644 src/quick/items/qquickanimatedsprite.cpp create mode 100644 src/quick/items/qquickanimatedsprite_p.h create mode 100644 tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml create mode 100644 tests/auto/qtquick2/qquickanimatedsprite/data/squarefacesprite.png create mode 100644 tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro create mode 100644 tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp diff --git a/examples/qtquick/imageelements/animatedsprite.qml b/examples/qtquick/imageelements/animatedsprite.qml new file mode 100644 index 0000000000..3a597bba71 --- /dev/null +++ b/examples/qtquick/imageelements/animatedsprite.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + width: 400 + height: 400 + Rectangle { + anchors.fill: parent + color: "white" + } + AnimatedSprite { + id: sprite + anchors.fill: parent + source: "content/speaker.png" + frameCount: 60 + frameSync: true + frameWidth: 170 + frameHeight: 170 + loops: 3 + } + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton + onClicked: { + if (!sprite.running) + sprite.start(); + if (!sprite.paused) + sprite.pause(); + if ( mouse.button == Qt.LeftButton ) { + sprite.advance(1); + } else { + sprite.advance(-1); + } + } + } +} diff --git a/examples/qtquick/imageelements/simplesprite.qml b/examples/qtquick/imageelements/simplesprite.qml deleted file mode 100644 index f619913bfc..0000000000 --- a/examples/qtquick/imageelements/simplesprite.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - width: 400 - height: 400 - Rectangle { - anchors.fill: parent - color: "white" - } - SpriteImage { - anchors.fill: parent - Sprite{ - source: "content/speaker.png" - frames: 60 - frameSync: true - frameWidth: 170 - frameHeight: 170 - } - } -} diff --git a/src/quick/items/items.pri b/src/quick/items/items.pri index f02c769c3a..bdd1692e85 100644 --- a/src/quick/items/items.pri +++ b/src/quick/items/items.pri @@ -66,6 +66,7 @@ HEADERS += \ $$PWD/qquickspriteengine_p.h \ $$PWD/qquicksprite_p.h \ $$PWD/qquickspriteimage_p.h \ + $$PWD/qquickanimatedsprite_p.h \ $$PWD/qquickdrag_p.h \ $$PWD/qquickdroparea_p.h \ $$PWD/qquickmultipointtoucharea_p.h \ @@ -117,6 +118,7 @@ SOURCES += \ $$PWD/qquickspriteengine.cpp \ $$PWD/qquicksprite.cpp \ $$PWD/qquickspriteimage.cpp \ + $$PWD/qquickanimatedsprite.cpp \ $$PWD/qquickaccessibleattached.cpp \ $$PWD/qquickdrag.cpp \ $$PWD/qquickdroparea.cpp \ diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp new file mode 100644 index 0000000000..ef79d052a8 --- /dev/null +++ b/src/quick/items/qquickanimatedsprite.cpp @@ -0,0 +1,613 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qquickanimatedsprite_p.h" +#include "qquicksprite_p.h" +#include "qquickspriteengine_p.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +static const char vertexShaderCode[] = + "attribute highp vec2 vTex;\n" + "uniform highp vec3 animData;// w,h(premultiplied of anim), interpolation progress\n" + "uniform highp vec4 animPos;//x,y, x,y (two frames for interpolation)\n" + "uniform highp vec2 size;//w,h of element\n" + "\n" + "uniform highp mat4 qt_Matrix;\n" + "\n" + "varying highp vec4 fTexS;\n" + "varying lowp float progress;\n" + "\n" + "\n" + "void main() {\n" + " progress = animData.z;\n" + " //Calculate frame location in texture\n" + " fTexS.xy = animPos.xy + vTex.xy * animData.xy;\n" + " //Next frame is also passed, for interpolation\n" + " fTexS.zw = animPos.zw + vTex.xy * animData.xy;\n" + "\n" + " gl_Position = qt_Matrix * vec4(size.x * vTex.x, size.y * vTex.y, 0, 1);\n" + "}\n"; + +static const char fragmentShaderCode[] = + "uniform sampler2D texture;\n" + "uniform lowp float qt_Opacity;\n" + "\n" + "varying highp vec4 fTexS;\n" + "varying lowp float progress;\n" + "\n" + "void main() {\n" + " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), progress) * qt_Opacity;\n" + "}\n"; + +class QQuickAnimatedSpriteMaterial : public QSGMaterial +{ +public: + QQuickAnimatedSpriteMaterial(); + ~QQuickAnimatedSpriteMaterial(); + virtual QSGMaterialType *type() const { static QSGMaterialType type; return &type; } + virtual QSGMaterialShader *createShader() const; + virtual int compare(const QSGMaterial *other) const + { + return this - static_cast(other); + } + + QSGTexture *texture; + + float animT; + float animX1; + float animY1; + float animX2; + float animY2; + float animW; + float animH; + float elementWidth; + float elementHeight; +}; + +QQuickAnimatedSpriteMaterial::QQuickAnimatedSpriteMaterial() + : texture(0) + , animT(0.0f) + , animX1(0.0f) + , animY1(0.0f) + , animX2(0.0f) + , animY2(0.0f) + , animW(1.0f) + , animH(1.0f) + , elementWidth(1.0f) + , elementHeight(1.0f) +{ + setFlag(Blending, true); +} + +QQuickAnimatedSpriteMaterial::~QQuickAnimatedSpriteMaterial() +{ + delete texture; +} + +class AnimatedSpriteMaterialData : public QSGMaterialShader +{ +public: + AnimatedSpriteMaterialData(const char * /* vertexFile */ = 0, const char * /* fragmentFile */ = 0) + { + } + + void deactivate() { + QSGMaterialShader::deactivate(); + + for (int i=0; i<8; ++i) { + program()->setAttributeArray(i, GL_FLOAT, chunkOfBytes, 1, 0); + } + } + + virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) + { + QQuickAnimatedSpriteMaterial *m = static_cast(newEffect); + m->texture->bind(); + + program()->setUniformValue(m_opacity_id, state.opacity()); + program()->setUniformValue(m_animData_id, m->animW, m->animH, m->animT); + program()->setUniformValue(m_animPos_id, m->animX1, m->animY1, m->animX2, m->animY2); + program()->setUniformValue(m_size_id, m->elementWidth, m->elementHeight); + + if (state.isMatrixDirty()) + program()->setUniformValue(m_matrix_id, state.combinedMatrix()); + } + + virtual void initialize() { + m_matrix_id = program()->uniformLocation("qt_Matrix"); + m_opacity_id = program()->uniformLocation("qt_Opacity"); + m_animData_id = program()->uniformLocation("animData"); + m_animPos_id = program()->uniformLocation("animPos"); + m_size_id = program()->uniformLocation("size"); + } + + virtual const char *vertexShader() const { return vertexShaderCode; } + virtual const char *fragmentShader() const { return fragmentShaderCode; } + + virtual char const *const *attributeNames() const { + static const char *attr[] = { + "vTex", + 0 + }; + return attr; + } + + int m_matrix_id; + int m_opacity_id; + int m_animData_id; + int m_animPos_id; + int m_size_id; + + static float chunkOfBytes[1024]; +}; + +float AnimatedSpriteMaterialData::chunkOfBytes[1024]; + +QSGMaterialShader *QQuickAnimatedSpriteMaterial::createShader() const +{ + return new AnimatedSpriteMaterialData; +} + +struct AnimatedSpriteVertex { + float tx; + float ty; +}; + +struct AnimatedSpriteVertices { + AnimatedSpriteVertex v1; + AnimatedSpriteVertex v2; + AnimatedSpriteVertex v3; + AnimatedSpriteVertex v4; +}; + +/*! + \qmlclass AnimatedSprite QQuickAnimatedSprite + \inqmlmodule QtQuick 2 + \inherits Item + \brief The AnimatedSprite element draws a sprite animation +*/ + +/*! + \qmlproperty bool QtQuick2::AnimatedSprite::running + + Whether the sprite is animating or not. + + Default is true +*/ + +/*! + \qmlproperty bool QtQuick2::AnimatedSprite::interpolate + + If true, interpolation will occur between sprite frames to make the + animation appear smoother. + + Default is true. +*/ + +/*! + \qmlproperty qreal QtQuick2::AnimatedSprite::frameRate + + Frames per second to show in the animation. Values below 0 are invalid. + + If frameRate is valid then it will be used to calculate the duration of the frames. + If not, and frameDuration is valid , then frameDuration will be used. +*/ + +/*! + \qmlproperty int QtQuick2::AnimatedSprite::frameDuration + + Duration of each frame of the animation. Values below 0 are invalid. + + If frameRate is valid then it will be used to calculate the duration of the frames. + If not, and frameDuration is valid, then frameDuration will be used. +*/ + +/*! + \qmlproperty int QtQuick2::AnimatedSprite::frameCount + + Number of frames in this AnimatedSprite. +*/ +/*! + \qmlproperty int QtQuick2::AnimatedSprite::frameHeight + + Height of a single frame in this AnimatedSprite. + + May be omitted if it is the only sprite in the file. +*/ +/*! + \qmlproperty int QtQuick2::AnimatedSprite::frameWidth + + Width of a single frame in this AnimatedSprite. + + May be omitted if it is the only sprite in the file. +*/ +/*! + \qmlproperty int QtQuick2::AnimatedSprite::frameX + + The X coordinate in the image file of the first frame of the AnimatedSprite. + + May be omitted if the first frame starts in the upper left corner of the file. +*/ +/*! + \qmlproperty int QtQuick2::AnimatedSprite::frameY + + The Y coordinate in the image file of the first frame of the AnimatedSprite. + + May be omitted if the first frame starts in the upper left corner of the file. +*/ +/*! + \qmlproperty url QtQuick2::AnimatedSprite::source + + The image source for the animation. + + If frameHeight and frameWidth are not specified, it is assumed to be a single long row of square frames. + Otherwise, it can be multiple contiguous rows or rectangluar frames, when one row runs out the next will be used. + + If frameX and frameY are specified, the row of frames will be taken with that x/y coordinate as the upper left corner. +*/ + +/*! + \qmlproperty bool QtQuick2::AnimatedSprite::reverse + + If true, then the animation will be played in reverse. + + Default is false. +*/ + +/*! + \qmlproperty bool QtQuick2::AnimatedSprite::frameSync + + If true, then the animation will have no duration. Instead, the animation will advance + one frame each time a frame is rendered to the screen. This syncronizes it with the painting + rate as opposed to elapsed time. + + If frameSync is set to true, it overrides both frameRate and frameDuration. + + Default is false. +*/ + +/*! + \qmlproperty int QtQuick2::AnimatedSprite::loops + + After playing the animation this many times, the animation will automatically stop. Negative values are invalid. + + If this is set to AnimatedSprite.Infinite the animation will not stop playing on its own. + + Default is AnimatedSprite.Infinite +*/ + +/*! + \qmlproperty bool QtQuick2::AnimatedSprite::paused + + When paused, the current frame can be advanced manually. + + Default is false. +*/ + +/*! + \qmlproperty int QtQuick2::AnimatedSprite::currentFrame + + When paused, the current frame can be advanced manually by setting this property or calling advance(). + +*/ + +//TODO: Implicitly size element to size of sprite +QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) : + QQuickItem(parent) + , m_node(0) + , m_material(0) + , m_sprite(new QQuickSprite) + , m_spriteEngine(0) + , m_curFrame(0) + , m_pleaseReset(false) + , m_running(true) + , m_paused(false) + , m_interpolate(true) + , m_loops(-1) + , m_curLoop(0) + , m_pauseOffset(0) +{ + setFlag(ItemHasContents); + connect(this, SIGNAL(runningChanged(bool)), + this, SLOT(update())); +} + +void QQuickAnimatedSprite::reloadImage() +{ + if (!isComponentComplete()) + return; + createEngine();//### It's not as inefficient as it sounds, but it still sucks having to recreate the engine +} + +void QQuickAnimatedSprite::componentComplete() +{ + createEngine(); + QQuickItem::componentComplete(); + if (m_running) + start(); +} + +void QQuickAnimatedSprite::start() +{ + if (m_running) + return; + m_curLoop = 0; + m_timestamp.start(); + m_running = true; + emit runningChanged(true); + update(); +} + +void QQuickAnimatedSprite::stop() +{ + if (!m_running) + return; + m_running = false; + emit runningChanged(false); +} + +void QQuickAnimatedSprite::advance(int frames) +{ + if (!frames) + return; + //TODO-C: May not work when running - only when paused + m_curFrame += frames; + while (m_curFrame < 0) + m_curFrame += m_sprite->frames(); + m_curFrame = m_curFrame % m_sprite->frames(); + emit currentFrameChanged(m_curFrame); +} + +void QQuickAnimatedSprite::pause() +{ + if (m_paused) + return; + m_pauseOffset = m_timestamp.elapsed(); + m_paused = true; + emit pausedChanged(true); +} + +void QQuickAnimatedSprite::resume() +{ + if (!m_paused) + return; + m_pauseOffset = m_pauseOffset - m_timestamp.elapsed(); + m_paused = false; + emit pausedChanged(false); +} + +void QQuickAnimatedSprite::createEngine() +{ + if (m_spriteEngine) + delete m_spriteEngine; + QList spriteList; + spriteList << m_sprite; + m_spriteEngine = new QQuickSpriteEngine(QList(spriteList), this); + m_spriteEngine->startAssemblingImage(); + reset(); +} + +static QSGGeometry::Attribute AnimatedSprite_Attributes[] = { + QSGGeometry::Attribute::create(0, 2, GL_FLOAT), // tex +}; + +static QSGGeometry::AttributeSet AnimatedSprite_AttributeSet = +{ + 1, // Attribute Count + 2 * sizeof(float), + AnimatedSprite_Attributes +}; + +QSGGeometryNode* QQuickAnimatedSprite::buildNode() +{ + if (!m_spriteEngine) { + qmlInfo(this) << "No sprite engine..."; + return 0; + } else if (m_spriteEngine->status() == QDeclarativePixmap::Null) { + m_spriteEngine->startAssemblingImage(); + update();//Schedule another update, where we will check again + return 0; + } else if (m_spriteEngine->status() == QDeclarativePixmap::Loading) { + update();//Schedule another update, where we will check again + return 0; + } + + m_material = new QQuickAnimatedSpriteMaterial(); + + QImage image = m_spriteEngine->assembledImage(); + if (image.isNull()) + return 0; + m_sheetSize = QSizeF(image.size()); + m_material->texture = canvas()->createTextureFromImage(image); + m_material->texture->setFiltering(QSGTexture::Linear); + m_spriteEngine->start(0); + m_material->animT = 0; + m_material->animX1 = m_spriteEngine->spriteX() / m_sheetSize.width(); + m_material->animY1 = m_spriteEngine->spriteY() / m_sheetSize.height(); + m_material->animX2 = m_material->animX1; + m_material->animY2 = m_material->animY1; + m_material->animW = m_spriteEngine->spriteWidth() / m_sheetSize.width(); + m_material->animH = m_spriteEngine->spriteHeight() / m_sheetSize.height(); + m_material->elementWidth = width(); + m_material->elementHeight = height(); + + int vCount = 4; + int iCount = 6; + QSGGeometry *g = new QSGGeometry(AnimatedSprite_AttributeSet, vCount, iCount); + g->setDrawingMode(GL_TRIANGLES); + + AnimatedSpriteVertices *p = (AnimatedSpriteVertices *) g->vertexData(); + + p->v1.tx = 0; + p->v1.ty = 0; + + p->v2.tx = 1.0; + p->v2.ty = 0; + + p->v3.tx = 0; + p->v3.ty = 1.0; + + p->v4.tx = 1.0; + p->v4.ty = 1.0; + + quint16 *indices = g->indexDataAsUShort(); + indices[0] = 0; + indices[1] = 1; + indices[2] = 2; + indices[3] = 1; + indices[4] = 3; + indices[5] = 2; + + + m_timestamp.start(); + m_node = new QSGGeometryNode(); + m_node->setGeometry(g); + m_node->setMaterial(m_material); + m_node->setFlag(QSGGeometryNode::OwnsMaterial); + return m_node; +} + +void QQuickAnimatedSprite::reset() +{ + m_pleaseReset = true; +} + +QSGNode *QQuickAnimatedSprite::updatePaintNode(QSGNode *, UpdatePaintNodeData *) +{ + if (m_pleaseReset) { + delete m_node; + + m_node = 0; + m_material = 0; + m_pleaseReset = false; + } + + prepareNextFrame(); + + if (m_running) { + update(); + if (m_node) + m_node->markDirty(QSGNode::DirtyMaterial); + } + + return m_node; +} + +void QQuickAnimatedSprite::prepareNextFrame() +{ + if (m_node == 0) + m_node = buildNode(); + if (m_node == 0) //error creating node + return; + + uint timeInt = m_timestamp.elapsed() + m_pauseOffset; + qreal time = timeInt / 1000.; + m_material->elementHeight = height(); + m_material->elementWidth = width(); + + double frameAt; //double just for modf + qreal progress; + if (!m_paused) { + //Advance State (keeps time for psuedostates) + m_spriteEngine->updateSprites(timeInt); + + //Advance AnimatedSprite + qreal animT = m_spriteEngine->spriteStart()/1000.0; + qreal frameCount = m_spriteEngine->spriteFrames(); + qreal frameDuration = m_spriteEngine->spriteDuration()/frameCount; + if (frameDuration > 0) { + qreal frame = (time - animT)/(frameDuration / 1000.0); + frame = qBound(qreal(0.0), frame, frameCount - qreal(1.0));//Stop at count-1 frames until we have between anim interpolation + progress = modf(frame,&frameAt); + if (m_curFrame > frameAt) //went around + m_curLoop++; + m_curFrame = frameAt; + } else { + m_curFrame++; + if (m_curFrame >= frameCount){ + m_curFrame = 0; + m_curLoop++; + m_spriteEngine->advance(); + } + frameAt = m_curFrame; + progress = 0; + } + if (m_loops > 0 && m_curLoop >= m_loops) { + frameAt = 0; + m_running = false; + } + } else { + frameAt = m_curFrame; + } + if (m_spriteEngine->sprite()->reverse()) + frameAt = (m_spriteEngine->spriteFrames() - 1) - frameAt; + qreal y = m_spriteEngine->spriteY() / m_sheetSize.height(); + qreal w = m_spriteEngine->spriteWidth() / m_sheetSize.width(); + qreal h = m_spriteEngine->spriteHeight() / m_sheetSize.height(); + qreal x1 = m_spriteEngine->spriteX() / m_sheetSize.width(); + x1 += frameAt * w; + qreal x2 = x1; + if (frameAt < (m_spriteEngine->spriteFrames()-1)) + x2 += w; + + m_material->animX1 = x1; + m_material->animY1 = y; + m_material->animX2 = x2; + m_material->animY2 = y; + m_material->animW = w; + m_material->animH = h; + m_material->animT = m_interpolate ? progress : 0.0; +} + +QT_END_NAMESPACE diff --git a/src/quick/items/qquickanimatedsprite_p.h b/src/quick/items/qquickanimatedsprite_p.h new file mode 100644 index 0000000000..062b191621 --- /dev/null +++ b/src/quick/items/qquickanimatedsprite_p.h @@ -0,0 +1,373 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKANIMATEDSPRITE_P_H +#define QQUICKANIMATEDSPRITE_P_H + +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QSGContext; +class QQuickSprite; +class QQuickSpriteEngine; +class QSGGeometryNode; +class QQuickAnimatedSpriteMaterial; +class Q_AUTOTEST_EXPORT QQuickAnimatedSprite : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged) + Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged) + //###try to share similar spriteEngines for less overhead? + //These properties come out of QQuickSprite, since a SimpleSpriteImage is a renderer for a single sprite + Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(bool reverse READ reverse WRITE setReverse NOTIFY reverseChanged) + Q_PROPERTY(bool frameSync READ frameSync WRITE setFrameSync NOTIFY frameSyncChanged) + Q_PROPERTY(int frameCount READ frameCount WRITE setFrameCount NOTIFY frameCountChanged) + //If frame height or width is not specified, it is assumed to be a single long row of square frames. + //Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used. + Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged) + Q_PROPERTY(int frameWidth READ frameWidth WRITE setFrameWidth NOTIFY frameWidthChanged) + Q_PROPERTY(int frameX READ frameX WRITE setFrameX NOTIFY frameXChanged) + Q_PROPERTY(int frameY READ frameY WRITE setFrameY NOTIFY frameYChanged) + //Precedence order: frameRate, frameDuration + Q_PROPERTY(qreal frameRate READ frameRate WRITE setFrameRate NOTIFY frameRateChanged RESET resetFrameRate) + Q_PROPERTY(int frameDuration READ frameDuration WRITE setFrameDuration NOTIFY frameDurationChanged RESET resetFrameDuration) + //Extra Simple Sprite Stuff + Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopsChanged) + Q_PROPERTY(bool paused READ paused WRITE setPaused NOTIFY pausedChanged) + Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY currentFrameChanged) + + Q_ENUMS(LoopParameters) +public: + explicit QQuickAnimatedSprite(QQuickItem *parent = 0); + enum LoopParameters { + Infinite = -1 + }; + + bool running() const + { + return m_running; + } + + bool interpolate() const + { + return m_interpolate; + } + + QUrl source() const + { + return m_sprite->source(); + } + + bool reverse() const + { + return m_sprite->reverse(); + } + + bool frameSync() const + { + return m_sprite->frameSync(); + } + + int frameCount() const + { + return m_sprite->frames(); + } + + int frameHeight() const + { + return m_sprite->frameHeight(); + } + + int frameWidth() const + { + return m_sprite->frameWidth(); + } + + int frameX() const + { + return m_sprite->frameX(); + } + + int frameY() const + { + return m_sprite->frameY(); + } + + qreal frameRate() const + { + return m_sprite->frameRate(); + } + + int frameDuration() const + { + return m_sprite->frameDuration(); + } + + int loops() const + { + return m_loops; + } + + bool paused() const + { + return m_paused; + } + + int currentFrame() const + { + return m_curFrame; + } + +signals: + + void pausedChanged(bool arg); + void runningChanged(bool arg); + void interpolateChanged(bool arg); + + void sourceChanged(QUrl arg); + + void reverseChanged(bool arg); + + void frameSyncChanged(bool arg); + + void frameCountChanged(int arg); + + void frameHeightChanged(int arg); + + void frameWidthChanged(int arg); + + void frameXChanged(int arg); + + void frameYChanged(int arg); + + void frameRateChanged(qreal arg); + + void frameDurationChanged(int arg); + + void loopsChanged(int arg); + + void currentFrameChanged(int arg); + +public slots: + void start(); + void stop(); + void restart() {stop(); start();} + void advance(int frames=1); + void pause(); + void resume(); + + void setRunning(bool arg) + { + if (m_running != arg) { + if (m_running) + stop(); + else + start(); + } + } + + void setPaused(bool arg) + { + if (m_paused != arg) { + if (m_paused) + resume(); + else + pause(); + } + } + + void setInterpolate(bool arg) + { + if (m_interpolate != arg) { + m_interpolate = arg; + emit interpolateChanged(arg); + } + } + + void setSource(QUrl arg) + { + if (m_sprite->m_source != arg) { + m_sprite->setSource(arg); + emit sourceChanged(arg); + } + } + + void setReverse(bool arg) + { + if (m_sprite->m_reverse != arg) { + m_sprite->setReverse(arg); + emit reverseChanged(arg); + } + } + + void setFrameSync(bool arg) + { + if (m_sprite->m_frameSync != arg) { + m_sprite->setFrameSync(arg); + emit frameSyncChanged(arg); + } + } + + void setFrameCount(int arg) + { + if (m_sprite->m_frames != arg) { + m_sprite->setFrameCount(arg); + emit frameCountChanged(arg); + reloadImage(); + } + } + + void setFrameHeight(int arg) + { + if (m_sprite->m_frameHeight != arg) { + m_sprite->setFrameHeight(arg); + emit frameHeightChanged(arg); + reloadImage(); + } + } + + void setFrameWidth(int arg) + { + if (m_sprite->m_frameWidth != arg) { + m_sprite->setFrameWidth(arg); + emit frameWidthChanged(arg); + reloadImage(); + } + } + + void setFrameX(int arg) + { + if (m_sprite->m_frameX != arg) { + m_sprite->setFrameX(arg); + emit frameXChanged(arg); + reloadImage(); + } + } + + void setFrameY(int arg) + { + if (m_sprite->m_frameY != arg) { + m_sprite->setFrameY(arg); + emit frameYChanged(arg); + reloadImage(); + } + } + + void setFrameRate(qreal arg) + { + if (m_sprite->m_frameRate != arg) { + m_sprite->setFrameRate(arg); + emit frameRateChanged(arg); + } + } + + void setFrameDuration(int arg) + { + if (m_sprite->m_frameDuration != arg) { + m_sprite->setFrameDuration(arg); + emit frameDurationChanged(arg); + } + } + + void resetFrameRate() + { + setFrameRate(-1.0); + } + + void resetFrameDuration() + { + setFrameDuration(-1); + } + + void setLoops(int arg) + { + if (m_loops != arg) { + m_loops = arg; + emit loopsChanged(arg); + } + } + + void setCurrentFrame(int arg) //TODO-C: Probably only works when paused + { + if (m_curFrame != arg) { + m_curFrame = arg; + emit currentFrameChanged(arg); //TODO-C Only emitted on manual advance! + } + } + + +private slots: + void createEngine(); +protected: + void reset(); + void componentComplete(); + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); +private: + void prepareNextFrame(); + void reloadImage(); + QSGGeometryNode* buildNode(); + QSGGeometryNode *m_node; + QQuickAnimatedSpriteMaterial *m_material; + QQuickSprite* m_sprite; + QQuickSpriteEngine* m_spriteEngine; + QTime m_timestamp; + int m_curFrame; + bool m_pleaseReset; + bool m_running; + bool m_paused; + bool m_interpolate; + QSizeF m_sheetSize; + int m_loops; + int m_curLoop; + int m_pauseOffset; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QQUICKANIMATEDSPRITE_P_H diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index a4cfa26205..2c74e3c91c 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -78,6 +78,7 @@ #include #include "qquicksprite_p.h" #include "qquickspriteimage_p.h" +#include "qquickanimatedsprite_p.h" #include "qquickdrag_p.h" #include "qquickdroparea_p.h" #include "qquickmultipointtoucharea_p.h" @@ -200,6 +201,7 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) qmlRegisterType("QtQuick", 2, 0, "Canvas"); qmlRegisterType("QtQuick", 2, 0, "Sprite"); + qmlRegisterType("QtQuick", 2, 0, "AnimatedSprite"); qmlRegisterType("QtQuick", 2, 0, "SpriteImage"); qmlRegisterType(uri, major, minor,"ParentChange"); diff --git a/src/quick/items/qquicksprite_p.h b/src/quick/items/qquicksprite_p.h index 4c5e5ff58e..98cc90ad8c 100644 --- a/src/quick/items/qquicksprite_p.h +++ b/src/quick/items/qquicksprite_p.h @@ -279,6 +279,7 @@ private slots: private: friend class QQuickImageParticle; friend class QQuickSpriteImage; + friend class QQuickAnimatedSprite; friend class QQuickSpriteEngine; friend class QQuickStochasticEngine; int m_generatedCount; diff --git a/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml b/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml new file mode 100644 index 0000000000..f219e5fb81 --- /dev/null +++ b/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + AnimatedSprite { + objectName: "sprite" + loops: 3 + source: "squarefacesprite.png" + frames: 6 + frameDuration: 120 + width: 160 + height: 160 + } +} diff --git a/tests/auto/qtquick2/qquickanimatedsprite/data/squarefacesprite.png b/tests/auto/qtquick2/qquickanimatedsprite/data/squarefacesprite.png new file mode 100644 index 0000000000..f9a5d5fcce Binary files /dev/null and b/tests/auto/qtquick2/qquickanimatedsprite/data/squarefacesprite.png differ diff --git a/tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro b/tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro new file mode 100644 index 0000000000..aad73d538d --- /dev/null +++ b/tests/auto/qtquick2/qquickanimatedsprite/qquickanimatedsprite.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickanimatedsprite +SOURCES += tst_qquickanimatedsprite.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp new file mode 100644 index 0000000000..3cc8f129fd --- /dev/null +++ b/tests/auto/qtquick2/qquickanimatedsprite/tst_qquickanimatedsprite.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "../../shared/util.h" +#include +#include + +class tst_qquickanimatedsprite : public QDeclarativeDataTest +{ + Q_OBJECT +public: + tst_qquickanimatedsprite(){} + +private slots: + void test_properties(); +}; + +void tst_qquickanimatedsprite::test_properties() +{ + QQuickView *canvas = new QQuickView(0); + + canvas->setSource(testFileUrl("basic.qml")); + canvas->show(); + QTest::qWaitForWindowShown(canvas); + + QVERIFY(canvas->rootObject()); + QQuickAnimatedSprite* sprite = canvas->rootObject()->findChild("sprite"); + QVERIFY(sprite); + + QVERIFY(sprite->running()); + QVERIFY(!sprite->paused()); + QVERIFY(sprite->interpolate()); + QCOMPARE(sprite->loops(), 3); + + sprite->setRunning(false); + QVERIFY(!sprite->running()); + sprite->setInterpolate(false); + QVERIFY(!sprite->interpolate()); + + delete canvas; +} + +QTEST_MAIN(tst_qquickanimatedsprite) + +#include "tst_qquickanimatedsprite.moc" diff --git a/tests/auto/qtquick2/qtquick2.pro b/tests/auto/qtquick2/qtquick2.pro index 7acd75f69e..60e302759e 100644 --- a/tests/auto/qtquick2/qtquick2.pro +++ b/tests/auto/qtquick2/qtquick2.pro @@ -31,6 +31,7 @@ QUICKTESTS = \ qquickaccessible \ qquickanchors \ qquickanimatedimage \ + qquickanimatedsprite \ qquickborderimage \ qquickcanvas \ qquickdrag \ -- cgit v1.2.3 From 75a0d33d250a97d5ee0314f5b7aad876d9ee2fa8 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 14 Feb 2012 18:16:21 +1000 Subject: Rename SpriteImage to SpriteSequence Also rename Sprite::frames->Sprite::frameCount Change-Id: I2e7a71adc37044fd696ffda2a5da4835725ba3a8 Reviewed-by: Alan Alpert --- .../plasmapatrol/content/PlasmaPatrolParticles.qml | 6 +- examples/particles/affectors/age.qml | 2 +- examples/particles/affectors/attractor.qml | 2 +- examples/particles/affectors/customaffector.qml | 10 +- examples/particles/affectors/friction.qml | 10 +- examples/particles/affectors/spritegoal.qml | 6 +- examples/particles/affectors/wander.qml | 2 +- examples/particles/imageparticle/allatonce.qml | 2 +- examples/particles/imageparticle/sprites.qml | 12 +- examples/qtquick/imageelements/spriteimage.qml | 12 +- .../content/BearWhackParticleSystem.qml | 6 +- src/quick/items/items.pri | 4 +- src/quick/items/qquickitemsmodule.cpp | 5 +- src/quick/items/qquicksprite.cpp | 2 +- src/quick/items/qquicksprite_p.h | 21 +- src/quick/items/qquickspriteimage.cpp | 482 --------------------- src/quick/items/qquickspriteimage_p.h | 148 ------- src/quick/items/qquickspritesequence.cpp | 482 +++++++++++++++++++++ src/quick/items/qquickspritesequence_p.h | 148 +++++++ .../qtquick2/qquickanimatedsprite/data/basic.qml | 2 +- .../qtquick2/qquickspriteimage/data/advance.qml | 66 --- .../auto/qtquick2/qquickspriteimage/data/basic.qml | 60 --- .../qquickspriteimage/data/squarefacesprite.png | Bin 496 -> 0 bytes .../qquickspriteimage/qquickspriteimage.pro | 15 - .../qquickspriteimage/tst_qquickspriteimage.cpp | 98 ----- .../qtquick2/qquickspritesequence/data/advance.qml | 66 +++ .../qtquick2/qquickspritesequence/data/basic.qml | 60 +++ .../qquickspritesequence/data/squarefacesprite.png | Bin 0 -> 496 bytes .../qquickspritesequence/qquickspritesequence.pro | 15 + .../tst_qquickspritesequence.cpp | 98 +++++ tests/auto/qtquick2/qtquick2.pro | 2 +- 31 files changed, 929 insertions(+), 915 deletions(-) delete mode 100644 src/quick/items/qquickspriteimage.cpp delete mode 100644 src/quick/items/qquickspriteimage_p.h create mode 100644 src/quick/items/qquickspritesequence.cpp create mode 100644 src/quick/items/qquickspritesequence_p.h delete mode 100644 tests/auto/qtquick2/qquickspriteimage/data/advance.qml delete mode 100644 tests/auto/qtquick2/qquickspriteimage/data/basic.qml delete mode 100644 tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png delete mode 100644 tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro delete mode 100644 tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp create mode 100644 tests/auto/qtquick2/qquickspritesequence/data/advance.qml create mode 100644 tests/auto/qtquick2/qquickspritesequence/data/basic.qml create mode 100644 tests/auto/qtquick2/qquickspritesequence/data/squarefacesprite.png create mode 100644 tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro create mode 100644 tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp diff --git a/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml b/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml index 95d4bcd2b9..1d856b5805 100644 --- a/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml +++ b/examples/demos/plasmapatrol/content/PlasmaPatrolParticles.qml @@ -127,19 +127,19 @@ Item { id: spinState name: "spinning" source: "pics/meteor.png" - frames: 35 + frameCount: 35 frameDuration: 40 to: {"death":0, "spinning":1} },Sprite { name: "death" source: "pics/meteor_explo.png" - frames: 22 + frameCount: 22 frameDuration: 40 to: {"null":1} }, Sprite { name: "null" source: "pics/nullRock.png" - frames: 1 + frameCount: 1 frameDuration: 1000 } ] diff --git a/examples/particles/affectors/age.qml b/examples/particles/affectors/age.qml index 1e7774b63b..ea1b30275e 100644 --- a/examples/particles/affectors/age.qml +++ b/examples/particles/affectors/age.qml @@ -54,7 +54,7 @@ Rectangle { sprites: Sprite { name: "snow" source: "../images/snowflake.png" - frames: 51 + frameCount: 51 frameDuration: 40 frameDurationVariation: 8 } diff --git a/examples/particles/affectors/attractor.qml b/examples/particles/affectors/attractor.qml index 460a497a92..0d50937fe7 100644 --- a/examples/particles/affectors/attractor.qml +++ b/examples/particles/affectors/attractor.qml @@ -108,7 +108,7 @@ Rectangle { id: spinState name: "spinning" source: "../images/meteor.png" - frames: 35 + frameCount: 35 frameDuration: 60 } } diff --git a/examples/particles/affectors/customaffector.qml b/examples/particles/affectors/customaffector.qml index 3f98cd5b43..9ccf45d3e6 100644 --- a/examples/particles/affectors/customaffector.qml +++ b/examples/particles/affectors/customaffector.qml @@ -135,31 +135,31 @@ Item { system: sys sprites: [Sprite { source: "../images/realLeaf1.png" - frames: 1 + frameCount: 1 frameDuration: 1 to: {"a":1, "b":1, "c":1, "d":1} }, Sprite { name: "a" source: "../images/realLeaf1.png" - frames: 1 + frameCount: 1 frameDuration: 10000 }, Sprite { name: "b" source: "../images/realLeaf2.png" - frames: 1 + frameCount: 1 frameDuration: 10000 }, Sprite { name: "c" source: "../images/realLeaf3.png" - frames: 1 + frameCount: 1 frameDuration: 10000 }, Sprite { name: "d" source: "../images/realLeaf4.png" - frames: 1 + frameCount: 1 frameDuration: 10000 } ] diff --git a/examples/particles/affectors/friction.qml b/examples/particles/affectors/friction.qml index 4161fd9f02..b93ead1967 100644 --- a/examples/particles/affectors/friction.qml +++ b/examples/particles/affectors/friction.qml @@ -65,31 +65,31 @@ Item { system: sys sprites: [Sprite { source: "../images/realLeaf1.png" - frames: 1 + frameCount: 1 frameDuration: 1 to: {"a":1, "b":1, "c":1, "d":1} }, Sprite { name: "a" source: "../images/realLeaf1.png" - frames: 1 + frameCount: 1 frameDuration: 10000 }, Sprite { name: "b" source: "../images/realLeaf2.png" - frames: 1 + frameCount: 1 frameDuration: 10000 }, Sprite { name: "c" source: "../images/realLeaf3.png" - frames: 1 + frameCount: 1 frameDuration: 10000 }, Sprite { name: "d" source: "../images/realLeaf4.png" - frames: 1 + frameCount: 1 frameDuration: 10000 } ] diff --git a/examples/particles/affectors/spritegoal.qml b/examples/particles/affectors/spritegoal.qml index 1ea61442aa..7102d09bc2 100644 --- a/examples/particles/affectors/spritegoal.qml +++ b/examples/particles/affectors/spritegoal.qml @@ -105,20 +105,20 @@ Item { id: spinState name: "spinning" source: "../images/meteor.png" - frames: 35 + frameCount: 35 frameDuration: 40 randomStart: true to: {"explode":0, "spinning":1} },Sprite { name: "explode" source: "../images/_explo.png" - frames: 22 + frameCount: 22 frameDuration: 40 to: {"nullFrame":1} },Sprite {//Not sure if this is needed, but seemed easiest name: "nullFrame" source: "../images/nullRock.png" - frames: 1 + frameCount: 1 frameDuration: 1000 } ] diff --git a/examples/particles/affectors/wander.qml b/examples/particles/affectors/wander.qml index 31a0b4a796..ea008795c2 100644 --- a/examples/particles/affectors/wander.qml +++ b/examples/particles/affectors/wander.qml @@ -51,7 +51,7 @@ Rectangle { sprites: Sprite { name: "snow" source: "../images/snowflake.png" - frames: 51 + frameCount: 51 frameDuration: 40 frameDurationVariation: 8 } diff --git a/examples/particles/imageparticle/allatonce.qml b/examples/particles/imageparticle/allatonce.qml index fbc634ec9a..b62735d7f9 100644 --- a/examples/particles/imageparticle/allatonce.qml +++ b/examples/particles/imageparticle/allatonce.qml @@ -54,7 +54,7 @@ Rectangle { Sprite { name: "bear" source: "../images/bear_tiles.png" - frames: 13 + frameCount: 13 frameDuration: 120 } ] diff --git a/examples/particles/imageparticle/sprites.qml b/examples/particles/imageparticle/sprites.qml index 0fe4f31ea3..45ff2ebbaf 100644 --- a/examples/particles/imageparticle/sprites.qml +++ b/examples/particles/imageparticle/sprites.qml @@ -47,11 +47,11 @@ Rectangle { height: 800 id: root - SpriteImage { + SpriteSequence { sprites: Sprite { name: "bear" source: "../images/bear_tiles.png" - frames: 13 + frameCount: 13 frameDuration: 120 } width: 250 @@ -71,25 +71,25 @@ Rectangle { sprites: [Sprite { name: "happy" source: "../images/starfish_1.png" - frames: 1 + frameCount: 1 frameDuration: 260 to: {"happy": 1, "silly": 1, "angry": 1} }, Sprite { name: "angry" source: "../images/starfish_0.png" - frames: 1 + frameCount: 1 frameDuration: 260 to: {"happy": 1, "silly": 1, "angry": 1} }, Sprite { name: "silly" source: "../images/starfish_2.png" - frames: 1 + frameCount: 1 frameDuration: 260 to: {"happy": 1, "silly": 1, "noticedbear": 0} }, Sprite { name: "noticedbear" source: "../images/starfish_3.png" - frames: 1 + frameCount: 1 frameDuration: 2600 }] } diff --git a/examples/qtquick/imageelements/spriteimage.qml b/examples/qtquick/imageelements/spriteimage.qml index 559bb10a50..372970d1d6 100644 --- a/examples/qtquick/imageelements/spriteimage.qml +++ b/examples/qtquick/imageelements/spriteimage.qml @@ -53,7 +53,7 @@ Item { ScriptAction { script: {image.goalSprite = ""; image.jumpTo("still");} } PropertyAction { target: image; property: "y"; value: 0 } } - SpriteImage { + SpriteSequence { id: image width: 256 height: 256 @@ -63,7 +63,7 @@ Item { Sprite{ name: "still" source: "content/BearSheet.png" - frames: 1 + frameCount: 1 frameWidth: 256 frameHeight: 256 frameDuration: 100 @@ -72,7 +72,7 @@ Item { Sprite{ name: "blink" source: "content/BearSheet.png" - frames: 3 + frameCount: 3 frameX: 256 frameY: 1536 frameWidth: 256 @@ -83,7 +83,7 @@ Item { Sprite{ name: "floating" source: "content/BearSheet.png" - frames: 9 + frameCount: 9 frameX: 0 frameY: 0 frameWidth: 256 @@ -94,7 +94,7 @@ Item { Sprite{ name: "flailing" source: "content/BearSheet.png" - frames: 8 + frameCount: 8 frameX: 0 frameY: 768 frameWidth: 256 @@ -105,7 +105,7 @@ Item { Sprite{ name: "falling" source: "content/BearSheet.png" - frames: 5 + frameCount: 5 frameY: 1280 frameWidth: 256 frameHeight: 256 diff --git a/examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml b/examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml index 05d74ab0ea..bed03e99aa 100644 --- a/examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml +++ b/examples/qtquick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml @@ -151,7 +151,7 @@ ParticleSystem { Sprite{ name: "floating" source: "Bear1.png" - frames: 9 + frameCount: 9 frameWidth: 256 frameHeight: 256 frameDuration: 80 @@ -160,7 +160,7 @@ ParticleSystem { Sprite{ name: "flailing" source: "Bear2.png" - frames: 8 + frameCount: 8 frameWidth: 256 frameHeight: 256 frameDuration: 80 @@ -169,7 +169,7 @@ ParticleSystem { Sprite{ name: "falling" source: "Bear3.png" - frames: 5 + frameCount: 5 frameWidth: 256 frameHeight: 256 frameDuration: 80 diff --git a/src/quick/items/items.pri b/src/quick/items/items.pri index bdd1692e85..21bf7cc8c1 100644 --- a/src/quick/items/items.pri +++ b/src/quick/items/items.pri @@ -65,7 +65,7 @@ HEADERS += \ $$PWD/qquickimplicitsizeitem_p_p.h \ $$PWD/qquickspriteengine_p.h \ $$PWD/qquicksprite_p.h \ - $$PWD/qquickspriteimage_p.h \ + $$PWD/qquickspritesequence_p.h \ $$PWD/qquickanimatedsprite_p.h \ $$PWD/qquickdrag_p.h \ $$PWD/qquickdroparea_p.h \ @@ -117,7 +117,7 @@ SOURCES += \ $$PWD/qquickimplicitsizeitem.cpp \ $$PWD/qquickspriteengine.cpp \ $$PWD/qquicksprite.cpp \ - $$PWD/qquickspriteimage.cpp \ + $$PWD/qquickspritesequence.cpp \ $$PWD/qquickanimatedsprite.cpp \ $$PWD/qquickaccessibleattached.cpp \ $$PWD/qquickdrag.cpp \ diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index 2c74e3c91c..b9e401a231 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -77,7 +77,7 @@ #include #include #include "qquicksprite_p.h" -#include "qquickspriteimage_p.h" +#include "qquickspritesequence_p.h" #include "qquickanimatedsprite_p.h" #include "qquickdrag_p.h" #include "qquickdroparea_p.h" @@ -202,7 +202,8 @@ static void qt_quickitems_defineModule(const char *uri, int major, int minor) qmlRegisterType("QtQuick", 2, 0, "Sprite"); qmlRegisterType("QtQuick", 2, 0, "AnimatedSprite"); - qmlRegisterType("QtQuick", 2, 0, "SpriteImage"); + qmlRegisterType("QtQuick", 2, 0, "SpriteSequence"); + qmlRegisterType("QtQuick", 2, 0, "SpriteImage");//Deprecation in progress qmlRegisterType(uri, major, minor,"ParentChange"); qmlRegisterType(uri, major, minor,"AnchorChanges"); diff --git a/src/quick/items/qquicksprite.cpp b/src/quick/items/qquicksprite.cpp index 4de7880916..2a1bd08d59 100644 --- a/src/quick/items/qquicksprite.cpp +++ b/src/quick/items/qquicksprite.cpp @@ -145,7 +145,7 @@ QT_BEGIN_NAMESPACE will repeat itself after completing. */ /*! - \qmlproperty int QtQuick2::Sprite::frames + \qmlproperty int QtQuick2::Sprite::frameCount Number of frames in this sprite. */ diff --git a/src/quick/items/qquicksprite_p.h b/src/quick/items/qquicksprite_p.h index 98cc90ad8c..dd6560f5ab 100644 --- a/src/quick/items/qquicksprite_p.h +++ b/src/quick/items/qquicksprite_p.h @@ -48,6 +48,7 @@ #include #include #include "qquickspriteengine_p.h" +#include QT_BEGIN_HEADER @@ -60,7 +61,8 @@ class QQuickSprite : public QQuickStochasticState //Renderers have to query this hint when advancing frames Q_PROPERTY(bool reverse READ reverse WRITE setReverse NOTIFY reverseChanged) Q_PROPERTY(bool frameSync READ frameSync WRITE setFrameSync NOTIFY frameSyncChanged) - Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY framesChanged) + Q_PROPERTY(int frames READ frames WRITE setFrames NOTIFY frameCountChanged) + Q_PROPERTY(int frameCount READ frameCount WRITE setFrameCount NOTIFY frameCountChanged) //If frame height or width is not specified, it is assumed to be a single long row of square frames. //Otherwise, it can be multiple contiguous rows, when one row runs out the next will be used. Q_PROPERTY(int frameHeight READ frameHeight WRITE setFrameHeight NOTIFY frameHeightChanged) @@ -101,6 +103,11 @@ public: return m_frames; } + int frameCount() const + { + return m_frames; + } + int frameX() const { return m_frameX; @@ -158,7 +165,7 @@ signals: void reverseChanged(bool arg); - void framesChanged(int arg); + void frameCountChanged(int arg); void frameXChanged(int arg); @@ -210,10 +217,16 @@ public slots: } void setFrames(int arg) + { + qWarning() << "Sprite::frames has been renamed Sprite::frameCount"; + setFrameCount(arg); + } + + void setFrameCount(int arg) { if (m_frames != arg) { m_frames = arg; - emit framesChanged(arg); + emit frameCountChanged(arg); } } @@ -278,7 +291,7 @@ private slots: private: friend class QQuickImageParticle; - friend class QQuickSpriteImage; + friend class QQuickSpriteSequence; friend class QQuickAnimatedSprite; friend class QQuickSpriteEngine; friend class QQuickStochasticEngine; diff --git a/src/quick/items/qquickspriteimage.cpp b/src/quick/items/qquickspriteimage.cpp deleted file mode 100644 index 1b3b57710a..0000000000 --- a/src/quick/items/qquickspriteimage.cpp +++ /dev/null @@ -1,482 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickspriteimage_p.h" -#include "qquicksprite_p.h" -#include "qquickspriteengine_p.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -static const char vertexShaderCode[] = - "attribute highp vec2 vTex;\n" - "uniform highp vec3 animData;// w,h(premultiplied of anim), interpolation progress\n" - "uniform highp vec4 animPos;//x,y, x,y (two frames for interpolation)\n" - "uniform highp vec2 size;//w,h of element\n" - "\n" - "uniform highp mat4 qt_Matrix;\n" - "\n" - "varying highp vec4 fTexS;\n" - "varying lowp float progress;\n" - "\n" - "\n" - "void main() {\n" - " progress = animData.z;\n" - " //Calculate frame location in texture\n" - " fTexS.xy = animPos.xy + vTex.xy * animData.xy;\n" - " //Next frame is also passed, for interpolation\n" - " fTexS.zw = animPos.zw + vTex.xy * animData.xy;\n" - "\n" - " gl_Position = qt_Matrix * vec4(size.x * vTex.x, size.y * vTex.y, 0, 1);\n" - "}\n"; - -static const char fragmentShaderCode[] = - "uniform sampler2D texture;\n" - "uniform lowp float qt_Opacity;\n" - "\n" - "varying highp vec4 fTexS;\n" - "varying lowp float progress;\n" - "\n" - "void main() {\n" - " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), progress) * qt_Opacity;\n" - "}\n"; - -class QQuickSpriteImageMaterial : public QSGMaterial -{ -public: - QQuickSpriteImageMaterial(); - ~QQuickSpriteImageMaterial(); - virtual QSGMaterialType *type() const { static QSGMaterialType type; return &type; } - virtual QSGMaterialShader *createShader() const; - virtual int compare(const QSGMaterial *other) const - { - return this - static_cast(other); - } - - QSGTexture *texture; - - float animT; - float animX1; - float animY1; - float animX2; - float animY2; - float animW; - float animH; - float elementWidth; - float elementHeight; -}; - -QQuickSpriteImageMaterial::QQuickSpriteImageMaterial() - : animT(0.0f) - , animX1(0.0f) - , animY1(0.0f) - , animX2(0.0f) - , animY2(0.0f) - , animW(1.0f) - , animH(1.0f) - , elementWidth(1.0f) - , elementHeight(1.0f) -{ - setFlag(Blending, true); -} - -QQuickSpriteImageMaterial::~QQuickSpriteImageMaterial() -{ - delete texture; -} - -class SpriteImageMaterialData : public QSGMaterialShader -{ -public: - SpriteImageMaterialData(const char * /* vertexFile */ = 0, const char * /* fragmentFile */ = 0) - { - } - - void deactivate() { - QSGMaterialShader::deactivate(); - - for (int i=0; i<8; ++i) { - program()->setAttributeArray(i, GL_FLOAT, chunkOfBytes, 1, 0); - } - } - - virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) - { - QQuickSpriteImageMaterial *m = static_cast(newEffect); - m->texture->bind(); - - program()->setUniformValue(m_opacity_id, state.opacity()); - program()->setUniformValue(m_animData_id, m->animW, m->animH, m->animT); - program()->setUniformValue(m_animPos_id, m->animX1, m->animY1, m->animX2, m->animY2); - program()->setUniformValue(m_size_id, m->elementWidth, m->elementHeight); - - if (state.isMatrixDirty()) - program()->setUniformValue(m_matrix_id, state.combinedMatrix()); - } - - virtual void initialize() { - m_matrix_id = program()->uniformLocation("qt_Matrix"); - m_opacity_id = program()->uniformLocation("qt_Opacity"); - m_animData_id = program()->uniformLocation("animData"); - m_animPos_id = program()->uniformLocation("animPos"); - m_size_id = program()->uniformLocation("size"); - } - - virtual const char *vertexShader() const { return vertexShaderCode; } - virtual const char *fragmentShader() const { return fragmentShaderCode; } - - virtual char const *const *attributeNames() const { - static const char *attr[] = { - "vTex", - 0 - }; - return attr; - } - - int m_matrix_id; - int m_opacity_id; - int m_animData_id; - int m_animPos_id; - int m_size_id; - - static float chunkOfBytes[1024]; -}; - -float SpriteImageMaterialData::chunkOfBytes[1024]; - -QSGMaterialShader *QQuickSpriteImageMaterial::createShader() const -{ - return new SpriteImageMaterialData; -} - -struct SpriteVertex { - float tx; - float ty; -}; - -struct SpriteVertices { - SpriteVertex v1; - SpriteVertex v2; - SpriteVertex v3; - SpriteVertex v4; -}; - -/*! - \qmlclass SpriteImage QQuickSpriteImage - \inqmlmodule QtQuick 2 - \inherits Item - \brief The SpriteImage element draws a sprite animation - -*/ -/*! - \qmlproperty bool QtQuick2::SpriteImage::running - - Whether the sprite is animating or not. - - Default is true -*/ -/*! - \qmlproperty bool QtQuick2::SpriteImage::interpolate - - If true, interpolation will occur between sprite frames to make the - animation appear smoother. - - Default is true. -*/ -/*! - \qmlproperty string QtQuick2::SpriteImage::goalSprite - - The name of the Sprite which is currently animating. -*/ -/*! - \qmlproperty string QtQuick2::SpriteImage::goalSprite - - The name of the Sprite which the animation should move to. - - Sprite states have defined durations and transitions between them, setting goalState - will cause it to disregard any path weightings (including 0) and head down the path - which will reach the goalState quickest (fewest animations). It will pass through - intermediate states on that path, and animate them for their duration. - - If it is possible to return to the goalState from the starting point of the goalState - it will continue to do so until goalState is set to "" or an unreachable state. -*/ -/*! \qmlmethod void QtQuick2::SpriteImage::jumpTo(string sprite) - - This function causes the sprite to jump to the specified state immediately, intermediate - states are not played. -*/ -/*! - \qmlproperty list QtQuick2::SpriteImage::sprites - - The sprite or sprites to draw. Sprites will be scaled to the size of this element. -*/ - -//TODO: Implicitly size element to size of first sprite? -QQuickSpriteImage::QQuickSpriteImage(QQuickItem *parent) : - QQuickItem(parent) - , m_node(0) - , m_material(0) - , m_spriteEngine(0) - , m_curFrame(0) - , m_pleaseReset(false) - , m_running(true) - , m_interpolate(true) - , m_curStateIdx(0) -{ - setFlag(ItemHasContents); - connect(this, SIGNAL(runningChanged(bool)), - this, SLOT(update())); -} - -void QQuickSpriteImage::jumpTo(const QString &sprite) -{ - if (!m_spriteEngine) - return; - m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite), 0, true); -} - -void QQuickSpriteImage::setGoalSprite(const QString &sprite) -{ - if (m_goalState != sprite){ - m_goalState = sprite; - emit goalSpriteChanged(sprite); - m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite)); - } -} - -QDeclarativeListProperty QQuickSpriteImage::sprites() -{ - return QDeclarativeListProperty(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear); -} - -void QQuickSpriteImage::createEngine() -{ - //TODO: delay until component complete - if (m_spriteEngine) - delete m_spriteEngine; - if (m_sprites.count()) - m_spriteEngine = new QQuickSpriteEngine(m_sprites, this); - else - m_spriteEngine = 0; - reset(); -} - -static QSGGeometry::Attribute SpriteImage_Attributes[] = { - QSGGeometry::Attribute::create(0, 2, GL_FLOAT), // tex -}; - -static QSGGeometry::AttributeSet SpriteImage_AttributeSet = -{ - 1, // Attribute Count - 2 * sizeof(float), - SpriteImage_Attributes -}; - -QSGGeometryNode* QQuickSpriteImage::buildNode() -{ - if (!m_spriteEngine) { - qmlInfo(this) << "No sprite engine..."; - return 0; - } else if (m_spriteEngine->status() == QDeclarativePixmap::Null) { - m_spriteEngine->startAssemblingImage(); - update();//Schedule another update, where we will check again - return 0; - } else if (m_spriteEngine->status() == QDeclarativePixmap::Loading) { - update();//Schedule another update, where we will check again - return 0; - } - - m_material = new QQuickSpriteImageMaterial(); - - QImage image = m_spriteEngine->assembledImage(); - if (image.isNull()) - return 0; - m_sheetSize = QSizeF(image.size()); - m_material->texture = canvas()->createTextureFromImage(image); - m_material->texture->setFiltering(QSGTexture::Linear); - m_spriteEngine->start(0); - m_material->animT = 0; - m_material->animX1 = m_spriteEngine->spriteX() / m_sheetSize.width(); - m_material->animY1 = m_spriteEngine->spriteY() / m_sheetSize.height(); - m_material->animX2 = m_material->animX1; - m_material->animY2 = m_material->animY1; - m_material->animW = m_spriteEngine->spriteWidth() / m_sheetSize.width(); - m_material->animH = m_spriteEngine->spriteHeight() / m_sheetSize.height(); - m_material->elementWidth = width(); - m_material->elementHeight = height(); - m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name(); - emit currentSpriteChanged(m_curState); - - int vCount = 4; - int iCount = 6; - QSGGeometry *g = new QSGGeometry(SpriteImage_AttributeSet, vCount, iCount); - g->setDrawingMode(GL_TRIANGLES); - - SpriteVertices *p = (SpriteVertices *) g->vertexData(); - - p->v1.tx = 0; - p->v1.ty = 0; - - p->v2.tx = 1.0; - p->v2.ty = 0; - - p->v3.tx = 0; - p->v3.ty = 1.0; - - p->v4.tx = 1.0; - p->v4.ty = 1.0; - - quint16 *indices = g->indexDataAsUShort(); - indices[0] = 0; - indices[1] = 1; - indices[2] = 2; - indices[3] = 1; - indices[4] = 3; - indices[5] = 2; - - - m_timestamp.start(); - m_node = new QSGGeometryNode(); - m_node->setGeometry(g); - m_node->setMaterial(m_material); - m_node->setFlag(QSGGeometryNode::OwnsMaterial); - return m_node; -} - -void QQuickSpriteImage::reset() -{ - m_pleaseReset = true; -} - -QSGNode *QQuickSpriteImage::updatePaintNode(QSGNode *, UpdatePaintNodeData *) -{ - if (m_pleaseReset) { - delete m_node; - - m_node = 0; - m_material = 0; - m_pleaseReset = false; - } - - prepareNextFrame(); - - if (m_running) { - update(); - if (m_node) - m_node->markDirty(QSGNode::DirtyMaterial); - } - - return m_node; -} - -void QQuickSpriteImage::prepareNextFrame() -{ - if (m_node == 0) - m_node = buildNode(); - if (m_node == 0) //error creating node - return; - - uint timeInt = m_timestamp.elapsed(); - qreal time = timeInt / 1000.; - m_material->elementHeight = height(); - m_material->elementWidth = width(); - - //Advance State - m_spriteEngine->updateSprites(timeInt); - if (m_curStateIdx != m_spriteEngine->curState()) { - m_curStateIdx = m_spriteEngine->curState(); - m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name(); - emit currentSpriteChanged(m_curState); - m_curFrame= -1; - } - - //Advance Sprite - qreal animT = m_spriteEngine->spriteStart()/1000.0; - qreal frameCount = m_spriteEngine->spriteFrames(); - qreal frameDuration = m_spriteEngine->spriteDuration()/frameCount; - double frameAt; - qreal progress; - if (frameDuration > 0) { - qreal frame = (time - animT)/(frameDuration / 1000.0); - frame = qBound(qreal(0.0), frame, frameCount - qreal(1.0));//Stop at count-1 frames until we have between anim interpolation - progress = modf(frame,&frameAt); - } else { - m_curFrame++; - if (m_curFrame >= frameCount){ - m_curFrame = 0; - m_spriteEngine->advance(); - } - frameAt = m_curFrame; - progress = 0; - } - if (m_spriteEngine->sprite()->reverse()) - frameAt = (m_spriteEngine->spriteFrames() - 1) - frameAt; - qreal y = m_spriteEngine->spriteY() / m_sheetSize.height(); - qreal w = m_spriteEngine->spriteWidth() / m_sheetSize.width(); - qreal h = m_spriteEngine->spriteHeight() / m_sheetSize.height(); - qreal x1 = m_spriteEngine->spriteX() / m_sheetSize.width(); - x1 += frameAt * w; - qreal x2 = x1; - if (frameAt < (frameCount-1)) - x2 += w; - - m_material->animX1 = x1; - m_material->animY1 = y; - m_material->animX2 = x2; - m_material->animY2 = y; - m_material->animW = w; - m_material->animH = h; - m_material->animT = m_interpolate ? progress : 0.0; -} - -QT_END_NAMESPACE diff --git a/src/quick/items/qquickspriteimage_p.h b/src/quick/items/qquickspriteimage_p.h deleted file mode 100644 index 8017263bb1..0000000000 --- a/src/quick/items/qquickspriteimage_p.h +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the Declarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKSPRITEIMAGE_P_H -#define QQUICKSPRITEIMAGE_P_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QSGContext; -class QQuickSprite; -class QQuickSpriteEngine; -class QSGGeometryNode; -class QQuickSpriteImageMaterial; -class Q_AUTOTEST_EXPORT QQuickSpriteImage : public QQuickItem -{ - Q_OBJECT - Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged) - Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged) - Q_PROPERTY(QString goalSprite READ goalSprite WRITE setGoalSprite NOTIFY goalSpriteChanged) - Q_PROPERTY(QString currentSprite READ currentSprite NOTIFY currentSpriteChanged) - //###try to share similar spriteEngines for less overhead? - Q_PROPERTY(QDeclarativeListProperty sprites READ sprites) - Q_CLASSINFO("DefaultProperty", "sprites") - -public: - explicit QQuickSpriteImage(QQuickItem *parent = 0); - - QDeclarativeListProperty sprites(); - - bool running() const - { - return m_running; - } - - bool interpolate() const - { - return m_interpolate; - } - - QString goalSprite() const - { - return m_goalState; - } - - QString currentSprite() const - { - return m_curState; - } - -signals: - - void runningChanged(bool arg); - void interpolateChanged(bool arg); - void goalSpriteChanged(QString arg); - void currentSpriteChanged(QString arg); - -public slots: - - void jumpTo(const QString &sprite); - void setGoalSprite(const QString &sprite); - - void setRunning(bool arg) - { - if (m_running != arg) { - m_running = arg; - emit runningChanged(arg); - } - } - - void setInterpolate(bool arg) - { - if (m_interpolate != arg) { - m_interpolate = arg; - emit interpolateChanged(arg); - } - } - -private slots: - void createEngine(); -protected: - void reset(); - QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); -private: - void prepareNextFrame(); - QSGGeometryNode* buildNode(); - QSGGeometryNode *m_node; - QQuickSpriteImageMaterial *m_material; - QList m_sprites; - QQuickSpriteEngine* m_spriteEngine; - QTime m_timestamp; - int m_curFrame; - bool m_pleaseReset; - bool m_running; - bool m_interpolate; - QString m_goalState; - QString m_curState; - int m_curStateIdx; - QSizeF m_sheetSize; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QQUICKSPRITEIMAGE_P_H diff --git a/src/quick/items/qquickspritesequence.cpp b/src/quick/items/qquickspritesequence.cpp new file mode 100644 index 0000000000..a3a8a6ee8c --- /dev/null +++ b/src/quick/items/qquickspritesequence.cpp @@ -0,0 +1,482 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qquickspritesequence_p.h" +#include "qquicksprite_p.h" +#include "qquickspriteengine_p.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +static const char vertexShaderCode[] = + "attribute highp vec2 vTex;\n" + "uniform highp vec3 animData;// w,h(premultiplied of anim), interpolation progress\n" + "uniform highp vec4 animPos;//x,y, x,y (two frames for interpolation)\n" + "uniform highp vec2 size;//w,h of element\n" + "\n" + "uniform highp mat4 qt_Matrix;\n" + "\n" + "varying highp vec4 fTexS;\n" + "varying lowp float progress;\n" + "\n" + "\n" + "void main() {\n" + " progress = animData.z;\n" + " //Calculate frame location in texture\n" + " fTexS.xy = animPos.xy + vTex.xy * animData.xy;\n" + " //Next frame is also passed, for interpolation\n" + " fTexS.zw = animPos.zw + vTex.xy * animData.xy;\n" + "\n" + " gl_Position = qt_Matrix * vec4(size.x * vTex.x, size.y * vTex.y, 0, 1);\n" + "}\n"; + +static const char fragmentShaderCode[] = + "uniform sampler2D texture;\n" + "uniform lowp float qt_Opacity;\n" + "\n" + "varying highp vec4 fTexS;\n" + "varying lowp float progress;\n" + "\n" + "void main() {\n" + " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), progress) * qt_Opacity;\n" + "}\n"; + +class QQuickSpriteSequenceMaterial : public QSGMaterial +{ +public: + QQuickSpriteSequenceMaterial(); + ~QQuickSpriteSequenceMaterial(); + virtual QSGMaterialType *type() const { static QSGMaterialType type; return &type; } + virtual QSGMaterialShader *createShader() const; + virtual int compare(const QSGMaterial *other) const + { + return this - static_cast(other); + } + + QSGTexture *texture; + + float animT; + float animX1; + float animY1; + float animX2; + float animY2; + float animW; + float animH; + float elementWidth; + float elementHeight; +}; + +QQuickSpriteSequenceMaterial::QQuickSpriteSequenceMaterial() + : animT(0.0f) + , animX1(0.0f) + , animY1(0.0f) + , animX2(0.0f) + , animY2(0.0f) + , animW(1.0f) + , animH(1.0f) + , elementWidth(1.0f) + , elementHeight(1.0f) +{ + setFlag(Blending, true); +} + +QQuickSpriteSequenceMaterial::~QQuickSpriteSequenceMaterial() +{ + delete texture; +} + +class SpriteSequenceMaterialData : public QSGMaterialShader +{ +public: + SpriteSequenceMaterialData(const char * /* vertexFile */ = 0, const char * /* fragmentFile */ = 0) + { + } + + void deactivate() { + QSGMaterialShader::deactivate(); + + for (int i=0; i<8; ++i) { + program()->setAttributeArray(i, GL_FLOAT, chunkOfBytes, 1, 0); + } + } + + virtual void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *) + { + QQuickSpriteSequenceMaterial *m = static_cast(newEffect); + m->texture->bind(); + + program()->setUniformValue(m_opacity_id, state.opacity()); + program()->setUniformValue(m_animData_id, m->animW, m->animH, m->animT); + program()->setUniformValue(m_animPos_id, m->animX1, m->animY1, m->animX2, m->animY2); + program()->setUniformValue(m_size_id, m->elementWidth, m->elementHeight); + + if (state.isMatrixDirty()) + program()->setUniformValue(m_matrix_id, state.combinedMatrix()); + } + + virtual void initialize() { + m_matrix_id = program()->uniformLocation("qt_Matrix"); + m_opacity_id = program()->uniformLocation("qt_Opacity"); + m_animData_id = program()->uniformLocation("animData"); + m_animPos_id = program()->uniformLocation("animPos"); + m_size_id = program()->uniformLocation("size"); + } + + virtual const char *vertexShader() const { return vertexShaderCode; } + virtual const char *fragmentShader() const { return fragmentShaderCode; } + + virtual char const *const *attributeNames() const { + static const char *attr[] = { + "vTex", + 0 + }; + return attr; + } + + int m_matrix_id; + int m_opacity_id; + int m_animData_id; + int m_animPos_id; + int m_size_id; + + static float chunkOfBytes[1024]; +}; + +float SpriteSequenceMaterialData::chunkOfBytes[1024]; + +QSGMaterialShader *QQuickSpriteSequenceMaterial::createShader() const +{ + return new SpriteSequenceMaterialData; +} + +struct SpriteVertex { + float tx; + float ty; +}; + +struct SpriteVertices { + SpriteVertex v1; + SpriteVertex v2; + SpriteVertex v3; + SpriteVertex v4; +}; + +/*! + \qmlclass SpriteSequence QQuickSpriteSequence + \inqmlmodule QtQuick 2 + \inherits Item + \brief The SpriteSequence element draws a sprite animation + +*/ +/*! + \qmlproperty bool QtQuick2::SpriteSequence::running + + Whether the sprite is animating or not. + + Default is true +*/ +/*! + \qmlproperty bool QtQuick2::SpriteSequence::interpolate + + If true, interpolation will occur between sprite frames to make the + animation appear smoother. + + Default is true. +*/ +/*! + \qmlproperty string QtQuick2::SpriteSequence::goalSprite + + The name of the Sprite which is currently animating. +*/ +/*! + \qmlproperty string QtQuick2::SpriteSequence::goalSprite + + The name of the Sprite which the animation should move to. + + Sprite states have defined durations and transitions between them, setting goalState + will cause it to disregard any path weightings (including 0) and head down the path + which will reach the goalState quickest (fewest animations). It will pass through + intermediate states on that path, and animate them for their duration. + + If it is possible to return to the goalState from the starting point of the goalState + it will continue to do so until goalState is set to "" or an unreachable state. +*/ +/*! \qmlmethod void QtQuick2::SpriteSequence::jumpTo(string sprite) + + This function causes the sprite to jump to the specified state immediately, intermediate + states are not played. +*/ +/*! + \qmlproperty list QtQuick2::SpriteSequence::sprites + + The sprite or sprites to draw. Sprites will be scaled to the size of this element. +*/ + +//TODO: Implicitly size element to size of first sprite? +QQuickSpriteSequence::QQuickSpriteSequence(QQuickItem *parent) : + QQuickItem(parent) + , m_node(0) + , m_material(0) + , m_spriteEngine(0) + , m_curFrame(0) + , m_pleaseReset(false) + , m_running(true) + , m_interpolate(true) + , m_curStateIdx(0) +{ + setFlag(ItemHasContents); + connect(this, SIGNAL(runningChanged(bool)), + this, SLOT(update())); +} + +void QQuickSpriteSequence::jumpTo(const QString &sprite) +{ + if (!m_spriteEngine) + return; + m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite), 0, true); +} + +void QQuickSpriteSequence::setGoalSprite(const QString &sprite) +{ + if (m_goalState != sprite){ + m_goalState = sprite; + emit goalSpriteChanged(sprite); + m_spriteEngine->setGoal(m_spriteEngine->stateIndex(sprite)); + } +} + +QDeclarativeListProperty QQuickSpriteSequence::sprites() +{ + return QDeclarativeListProperty(this, &m_sprites, spriteAppend, spriteCount, spriteAt, spriteClear); +} + +void QQuickSpriteSequence::createEngine() +{ + //TODO: delay until component complete + if (m_spriteEngine) + delete m_spriteEngine; + if (m_sprites.count()) + m_spriteEngine = new QQuickSpriteEngine(m_sprites, this); + else + m_spriteEngine = 0; + reset(); +} + +static QSGGeometry::Attribute SpriteSequence_Attributes[] = { + QSGGeometry::Attribute::create(0, 2, GL_FLOAT), // tex +}; + +static QSGGeometry::AttributeSet SpriteSequence_AttributeSet = +{ + 1, // Attribute Count + 2 * sizeof(float), + SpriteSequence_Attributes +}; + +QSGGeometryNode* QQuickSpriteSequence::buildNode() +{ + if (!m_spriteEngine) { + qmlInfo(this) << "No sprite engine..."; + return 0; + } else if (m_spriteEngine->status() == QDeclarativePixmap::Null) { + m_spriteEngine->startAssemblingImage(); + update();//Schedule another update, where we will check again + return 0; + } else if (m_spriteEngine->status() == QDeclarativePixmap::Loading) { + update();//Schedule another update, where we will check again + return 0; + } + + m_material = new QQuickSpriteSequenceMaterial(); + + QImage image = m_spriteEngine->assembledImage(); + if (image.isNull()) + return 0; + m_sheetSize = QSizeF(image.size()); + m_material->texture = canvas()->createTextureFromImage(image); + m_material->texture->setFiltering(QSGTexture::Linear); + m_spriteEngine->start(0); + m_material->animT = 0; + m_material->animX1 = m_spriteEngine->spriteX() / m_sheetSize.width(); + m_material->animY1 = m_spriteEngine->spriteY() / m_sheetSize.height(); + m_material->animX2 = m_material->animX1; + m_material->animY2 = m_material->animY1; + m_material->animW = m_spriteEngine->spriteWidth() / m_sheetSize.width(); + m_material->animH = m_spriteEngine->spriteHeight() / m_sheetSize.height(); + m_material->elementWidth = width(); + m_material->elementHeight = height(); + m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name(); + emit currentSpriteChanged(m_curState); + + int vCount = 4; + int iCount = 6; + QSGGeometry *g = new QSGGeometry(SpriteSequence_AttributeSet, vCount, iCount); + g->setDrawingMode(GL_TRIANGLES); + + SpriteVertices *p = (SpriteVertices *) g->vertexData(); + + p->v1.tx = 0; + p->v1.ty = 0; + + p->v2.tx = 1.0; + p->v2.ty = 0; + + p->v3.tx = 0; + p->v3.ty = 1.0; + + p->v4.tx = 1.0; + p->v4.ty = 1.0; + + quint16 *indices = g->indexDataAsUShort(); + indices[0] = 0; + indices[1] = 1; + indices[2] = 2; + indices[3] = 1; + indices[4] = 3; + indices[5] = 2; + + + m_timestamp.start(); + m_node = new QSGGeometryNode(); + m_node->setGeometry(g); + m_node->setMaterial(m_material); + m_node->setFlag(QSGGeometryNode::OwnsMaterial); + return m_node; +} + +void QQuickSpriteSequence::reset() +{ + m_pleaseReset = true; +} + +QSGNode *QQuickSpriteSequence::updatePaintNode(QSGNode *, UpdatePaintNodeData *) +{ + if (m_pleaseReset) { + delete m_node; + + m_node = 0; + m_material = 0; + m_pleaseReset = false; + } + + prepareNextFrame(); + + if (m_running) { + update(); + if (m_node) + m_node->markDirty(QSGNode::DirtyMaterial); + } + + return m_node; +} + +void QQuickSpriteSequence::prepareNextFrame() +{ + if (m_node == 0) + m_node = buildNode(); + if (m_node == 0) //error creating node + return; + + uint timeInt = m_timestamp.elapsed(); + qreal time = timeInt / 1000.; + m_material->elementHeight = height(); + m_material->elementWidth = width(); + + //Advance State + m_spriteEngine->updateSprites(timeInt); + if (m_curStateIdx != m_spriteEngine->curState()) { + m_curStateIdx = m_spriteEngine->curState(); + m_curState = m_spriteEngine->state(m_spriteEngine->curState())->name(); + emit currentSpriteChanged(m_curState); + m_curFrame= -1; + } + + //Advance Sprite + qreal animT = m_spriteEngine->spriteStart()/1000.0; + qreal frameCount = m_spriteEngine->spriteFrames(); + qreal frameDuration = m_spriteEngine->spriteDuration()/frameCount; + double frameAt; + qreal progress; + if (frameDuration > 0) { + qreal frame = (time - animT)/(frameDuration / 1000.0); + frame = qBound(qreal(0.0), frame, frameCount - qreal(1.0));//Stop at count-1 frames until we have between anim interpolation + progress = modf(frame,&frameAt); + } else { + m_curFrame++; + if (m_curFrame >= frameCount){ + m_curFrame = 0; + m_spriteEngine->advance(); + } + frameAt = m_curFrame; + progress = 0; + } + if (m_spriteEngine->sprite()->reverse()) + frameAt = (m_spriteEngine->spriteFrames() - 1) - frameAt; + qreal y = m_spriteEngine->spriteY() / m_sheetSize.height(); + qreal w = m_spriteEngine->spriteWidth() / m_sheetSize.width(); + qreal h = m_spriteEngine->spriteHeight() / m_sheetSize.height(); + qreal x1 = m_spriteEngine->spriteX() / m_sheetSize.width(); + x1 += frameAt * w; + qreal x2 = x1; + if (frameAt < (frameCount-1)) + x2 += w; + + m_material->animX1 = x1; + m_material->animY1 = y; + m_material->animX2 = x2; + m_material->animY2 = y; + m_material->animW = w; + m_material->animH = h; + m_material->animT = m_interpolate ? progress : 0.0; +} + +QT_END_NAMESPACE diff --git a/src/quick/items/qquickspritesequence_p.h b/src/quick/items/qquickspritesequence_p.h new file mode 100644 index 0000000000..8a95594f61 --- /dev/null +++ b/src/quick/items/qquickspritesequence_p.h @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Declarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKSPRITESEQUENCE_P_H +#define QQUICKSPRITESEQUENCE_P_H + +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QSGContext; +class QQuickSprite; +class QQuickSpriteEngine; +class QSGGeometryNode; +class QQuickSpriteSequenceMaterial; +class Q_AUTOTEST_EXPORT QQuickSpriteSequence : public QQuickItem +{ + Q_OBJECT + Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged) + Q_PROPERTY(bool interpolate READ interpolate WRITE setInterpolate NOTIFY interpolateChanged) + Q_PROPERTY(QString goalSprite READ goalSprite WRITE setGoalSprite NOTIFY goalSpriteChanged) + Q_PROPERTY(QString currentSprite READ currentSprite NOTIFY currentSpriteChanged) + //###try to share similar spriteEngines for less overhead? + Q_PROPERTY(QDeclarativeListProperty sprites READ sprites) + Q_CLASSINFO("DefaultProperty", "sprites") + +public: + explicit QQuickSpriteSequence(QQuickItem *parent = 0); + + QDeclarativeListProperty sprites(); + + bool running() const + { + return m_running; + } + + bool interpolate() const + { + return m_interpolate; + } + + QString goalSprite() const + { + return m_goalState; + } + + QString currentSprite() const + { + return m_curState; + } + +signals: + + void runningChanged(bool arg); + void interpolateChanged(bool arg); + void goalSpriteChanged(QString arg); + void currentSpriteChanged(QString arg); + +public slots: + + void jumpTo(const QString &sprite); + void setGoalSprite(const QString &sprite); + + void setRunning(bool arg) + { + if (m_running != arg) { + m_running = arg; + emit runningChanged(arg); + } + } + + void setInterpolate(bool arg) + { + if (m_interpolate != arg) { + m_interpolate = arg; + emit interpolateChanged(arg); + } + } + +private slots: + void createEngine(); +protected: + void reset(); + QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *); +private: + void prepareNextFrame(); + QSGGeometryNode* buildNode(); + QSGGeometryNode *m_node; + QQuickSpriteSequenceMaterial *m_material; + QList m_sprites; + QQuickSpriteEngine* m_spriteEngine; + QTime m_timestamp; + int m_curFrame; + bool m_pleaseReset; + bool m_running; + bool m_interpolate; + QString m_goalState; + QString m_curState; + int m_curStateIdx; + QSizeF m_sheetSize; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QQUICKSPRITESEQUENCE_P_H diff --git a/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml b/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml index f219e5fb81..2dd20630d9 100644 --- a/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml +++ b/tests/auto/qtquick2/qquickanimatedsprite/data/basic.qml @@ -50,7 +50,7 @@ Rectangle { objectName: "sprite" loops: 3 source: "squarefacesprite.png" - frames: 6 + frameCount: 6 frameDuration: 120 width: 160 height: 160 diff --git a/tests/auto/qtquick2/qquickspriteimage/data/advance.qml b/tests/auto/qtquick2/qquickspriteimage/data/advance.qml deleted file mode 100644 index 46a49ca673..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/data/advance.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - color: "black" - width: 320 - height: 320 - - SpriteImage { - objectName: "sprite" - sprites: [Sprite { - name: "firstState" - source: "squarefacesprite.png" - frames: 3 - frameSync: true - to: {"secondState":1} - }, Sprite { - name: "secondState" - source: "squarefacesprite.png" - frames: 6 - frameSync: true - } ] - width: 160 - height: 160 - } -} diff --git a/tests/auto/qtquick2/qquickspriteimage/data/basic.qml b/tests/auto/qtquick2/qquickspriteimage/data/basic.qml deleted file mode 100644 index 2f2b1c96fa..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/data/basic.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - color: "black" - width: 320 - height: 320 - - SpriteImage { - objectName: "sprite" - sprites: Sprite { - name: "happy" - source: "squarefacesprite.png" - frames: 6 - frameDuration: 120 - } - width: 160 - height: 160 - } -} diff --git a/tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png b/tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png deleted file mode 100644 index f9a5d5fcce..0000000000 Binary files a/tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png and /dev/null differ diff --git a/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro b/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro deleted file mode 100644 index 0d63007c65..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickspriteimage -SOURCES += tst_qquickspriteimage.cpp - -include (../../shared/util.pri) - -macx:CONFIG -= app_bundle - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp b/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp deleted file mode 100644 index 37453521fa..0000000000 --- a/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include "../../shared/util.h" -#include -#include - -class tst_qquickspriteimage : public QDeclarativeDataTest -{ - Q_OBJECT -public: - tst_qquickspriteimage(){} - -private slots: - void test_properties(); - void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine -}; - -void tst_qquickspriteimage::test_properties() -{ - QQuickView *canvas = new QQuickView(0); - - canvas->setSource(testFileUrl("basic.qml")); - canvas->show(); - QTest::qWaitForWindowShown(canvas); - - QVERIFY(canvas->rootObject()); - QQuickSpriteImage* sprite = canvas->rootObject()->findChild("sprite"); - QVERIFY(sprite); - - QVERIFY(sprite->running()); - QVERIFY(sprite->interpolate()); - - sprite->setRunning(false); - QVERIFY(!sprite->running()); - sprite->setInterpolate(false); - QVERIFY(!sprite->interpolate()); - - delete canvas; -} - -void tst_qquickspriteimage::test_framerateAdvance() -{ - QQuickView *canvas = new QQuickView(0); - - canvas->setSource(testFileUrl("advance.qml")); - canvas->show(); - QTest::qWaitForWindowShown(canvas); - - QVERIFY(canvas->rootObject()); - QQuickSpriteImage* sprite = canvas->rootObject()->findChild("sprite"); - QVERIFY(sprite); - - QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState")); - delete canvas; -} - -QTEST_MAIN(tst_qquickspriteimage) - -#include "tst_qquickspriteimage.moc" diff --git a/tests/auto/qtquick2/qquickspritesequence/data/advance.qml b/tests/auto/qtquick2/qquickspritesequence/data/advance.qml new file mode 100644 index 0000000000..5866dcbfac --- /dev/null +++ b/tests/auto/qtquick2/qquickspritesequence/data/advance.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + SpriteSequence { + objectName: "sprite" + sprites: [Sprite { + name: "firstState" + source: "squarefacesprite.png" + frameCount: 3 + frameSync: true + to: {"secondState":1} + }, Sprite { + name: "secondState" + source: "squarefacesprite.png" + frameCount: 6 + frameSync: true + } ] + width: 160 + height: 160 + } +} diff --git a/tests/auto/qtquick2/qquickspritesequence/data/basic.qml b/tests/auto/qtquick2/qquickspritesequence/data/basic.qml new file mode 100644 index 0000000000..5eb7475f11 --- /dev/null +++ b/tests/auto/qtquick2/qquickspritesequence/data/basic.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + color: "black" + width: 320 + height: 320 + + SpriteSequence { + objectName: "sprite" + sprites: Sprite { + name: "happy" + source: "squarefacesprite.png" + frameCount: 6 + frameDuration: 120 + } + width: 160 + height: 160 + } +} diff --git a/tests/auto/qtquick2/qquickspritesequence/data/squarefacesprite.png b/tests/auto/qtquick2/qquickspritesequence/data/squarefacesprite.png new file mode 100644 index 0000000000..f9a5d5fcce Binary files /dev/null and b/tests/auto/qtquick2/qquickspritesequence/data/squarefacesprite.png differ diff --git a/tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro b/tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro new file mode 100644 index 0000000000..16c20ef75b --- /dev/null +++ b/tests/auto/qtquick2/qquickspritesequence/qquickspritesequence.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickspritesequence +SOURCES += tst_qquickspritesequence.cpp + +include (../../shared/util.pri) + +macx:CONFIG -= app_bundle + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test + +QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp b/tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp new file mode 100644 index 0000000000..848d6a343c --- /dev/null +++ b/tests/auto/qtquick2/qquickspritesequence/tst_qquickspritesequence.cpp @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include "../../shared/util.h" +#include +#include + +class tst_qquickspritesequence : public QDeclarativeDataTest +{ + Q_OBJECT +public: + tst_qquickspritesequence(){} + +private slots: + void test_properties(); + void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine +}; + +void tst_qquickspritesequence::test_properties() +{ + QQuickView *canvas = new QQuickView(0); + + canvas->setSource(testFileUrl("basic.qml")); + canvas->show(); + QTest::qWaitForWindowShown(canvas); + + QVERIFY(canvas->rootObject()); + QQuickSpriteSequence* sprite = canvas->rootObject()->findChild("sprite"); + QVERIFY(sprite); + + QVERIFY(sprite->running()); + QVERIFY(sprite->interpolate()); + + sprite->setRunning(false); + QVERIFY(!sprite->running()); + sprite->setInterpolate(false); + QVERIFY(!sprite->interpolate()); + + delete canvas; +} + +void tst_qquickspritesequence::test_framerateAdvance() +{ + QQuickView *canvas = new QQuickView(0); + + canvas->setSource(testFileUrl("advance.qml")); + canvas->show(); + QTest::qWaitForWindowShown(canvas); + + QVERIFY(canvas->rootObject()); + QQuickSpriteSequence* sprite = canvas->rootObject()->findChild("sprite"); + QVERIFY(sprite); + + QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState")); + delete canvas; +} + +QTEST_MAIN(tst_qquickspritesequence) + +#include "tst_qquickspritesequence.moc" diff --git a/tests/auto/qtquick2/qtquick2.pro b/tests/auto/qtquick2/qtquick2.pro index 60e302759e..9034cb445a 100644 --- a/tests/auto/qtquick2/qtquick2.pro +++ b/tests/auto/qtquick2/qtquick2.pro @@ -53,7 +53,7 @@ QUICKTESTS = \ qquickpositioners \ qquickrepeater \ qquickshadereffect \ - qquickspriteimage \ + qquickspritesequence \ qquicktext \ qquicktextedit \ qquicktextinput \ -- cgit v1.2.3 From 7d32bacfc574dabb469ad8c0a83c70bb0fc6d770 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 28 Feb 2012 11:33:51 +1000 Subject: Update drag and drop examples to new guidelines Change-Id: Ib09a50015eaf7e79f21ade5df3cbd3b58b89c83d Reviewed-by: Andrew den Exter --- examples/qtquick/draganddrop/draganddrop.pro | 10 ++++ examples/qtquick/draganddrop/draganddrop.qml | 68 ++++++++++++++++++++++ .../qtquick/draganddrop/draganddrop.qmlproject | 16 +++++ examples/qtquick/draganddrop/dragtarget.qmlproject | 14 ----- examples/qtquick/draganddrop/main.cpp | 41 +++++++++++++ examples/qtquick/draganddrop/tiles/DragTile.qml | 15 ++--- examples/qtquick/draganddrop/tiles/DropTile.qml | 2 +- examples/qtquick/draganddrop/tiles/tiles.qml | 20 +++---- examples/qtquick/draganddrop/views/gridview.qml | 22 ++++--- examples/qtquick/qtquick.pro | 4 +- 10 files changed, 171 insertions(+), 41 deletions(-) create mode 100644 examples/qtquick/draganddrop/draganddrop.pro create mode 100644 examples/qtquick/draganddrop/draganddrop.qml create mode 100644 examples/qtquick/draganddrop/draganddrop.qmlproject delete mode 100644 examples/qtquick/draganddrop/dragtarget.qmlproject create mode 100644 examples/qtquick/draganddrop/main.cpp diff --git a/examples/qtquick/draganddrop/draganddrop.pro b/examples/qtquick/draganddrop/draganddrop.pro new file mode 100644 index 0000000000..f937039ca2 --- /dev/null +++ b/examples/qtquick/draganddrop/draganddrop.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +QT += quick declarative +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/draganddrop +qml.files = draganddrop.qml tiles views +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/draganddrop +INSTALLS += target qml + diff --git a/examples/qtquick/draganddrop/draganddrop.qml b/examples/qtquick/draganddrop/draganddrop.qml new file mode 100644 index 0000000000..88e6d5e021 --- /dev/null +++ b/examples/qtquick/draganddrop/draganddrop.qml @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "../../shared" as Examples + +/*! + \title QtQuick Examples - Drag and Drop + \example qtquick/draganddrop + \brief This is a collection of QML drag and drop examples + \image qml-draganddrop-example.png + + This is a collection of small QML examples relating to drag and drop functionality. + + Tiles adds drag and drog to simple rectangles, which you can drag into a specific grid. + + GridView adds drag and drog to a GridView, allowing you to reorder the list. +*/ + +Item { + height: 480 + width: 320 + Examples.LauncherList { + id: ll + anchors.fill: parent + Component.onCompleted: { + addExample("Tiles", "", Qt.resolvedUrl("tiles/tiles.qml")); + addExample("GridView", "", Qt.resolvedUrl("views/gridview.qml")); + } + } +} diff --git a/examples/qtquick/draganddrop/draganddrop.qmlproject b/examples/qtquick/draganddrop/draganddrop.qmlproject new file mode 100644 index 0000000000..b8b15c3444 --- /dev/null +++ b/examples/qtquick/draganddrop/draganddrop.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + mainFile: "draganddrop.qml" + /* Include .qml, .js, and image files from current directory and subdirectories */ + + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} diff --git a/examples/qtquick/draganddrop/dragtarget.qmlproject b/examples/qtquick/draganddrop/dragtarget.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/qtquick/draganddrop/dragtarget.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/qtquick/draganddrop/main.cpp b/examples/qtquick/draganddrop/main.cpp new file mode 100644 index 0000000000..0d74fbfe2e --- /dev/null +++ b/examples/qtquick/draganddrop/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(draganddrop) diff --git a/examples/qtquick/draganddrop/tiles/DragTile.qml b/examples/qtquick/draganddrop/tiles/DragTile.qml index 2813fa8caf..1f4a8c2bea 100644 --- a/examples/qtquick/draganddrop/tiles/DragTile.qml +++ b/examples/qtquick/draganddrop/tiles/DragTile.qml @@ -44,12 +44,12 @@ Item { id: root property string colorKey - width: 100; height: 100 + width: 64; height: 64 MouseArea { id: mouseArea - width: 100; height: 100 + width: 64; height: 64 anchors.centerIn: parent drag.target: tile @@ -59,20 +59,21 @@ Item { Rectangle { id: tile - width: 100; height: 100 + width: 64; height: 64 + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter - anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter color: colorKey Drag.keys: [ colorKey ] Drag.active: mouseArea.drag.active - Drag.hotSpot.x: 50 - Drag.hotSpot.y: 50 + Drag.hotSpot.x: 32 + Drag.hotSpot.y: 32 Text { anchors.fill: parent color: "white" - font.pixelSize: 90 + font.pixelSize: 48 text: modelData + 1 horizontalAlignment:Text.AlignHCenter verticalAlignment: Text.AlignVCenter diff --git a/examples/qtquick/draganddrop/tiles/DropTile.qml b/examples/qtquick/draganddrop/tiles/DropTile.qml index e8566f04cc..98fedeb775 100644 --- a/examples/qtquick/draganddrop/tiles/DropTile.qml +++ b/examples/qtquick/draganddrop/tiles/DropTile.qml @@ -46,7 +46,7 @@ DropArea { property string colorKey property alias dropProxy: dragTarget - width: 100; height: 100 + width: 64; height: 64 keys: [ colorKey ] Rectangle { diff --git a/examples/qtquick/draganddrop/tiles/tiles.qml b/examples/qtquick/draganddrop/tiles/tiles.qml index 31c87f8244..0b5647bc2b 100644 --- a/examples/qtquick/draganddrop/tiles/tiles.qml +++ b/examples/qtquick/draganddrop/tiles/tiles.qml @@ -43,8 +43,8 @@ import QtQuick 2.0 Rectangle { id: root - width: 620 - height: 410 + width: 320 + height: 480 color: "black" @@ -53,8 +53,8 @@ Rectangle { anchors.left: redSource.right; anchors.top: parent.top; anchors.margins: 5 - width: 300 - height: 300 + width: 64*3 + height: 64*3 opacity: 0.5 columns: 3 @@ -67,8 +67,8 @@ Rectangle { Grid { anchors.right: blueSource.left; anchors.bottom: parent.bottom; anchors.margins: 5 - width: 300 - height: 300 + width: 64*3 + height: 64*3 opacity: 0.5 @@ -85,8 +85,8 @@ Rectangle { anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom anchors.margins: 5 - width: 100 - spacing: -60 + width: 64 + spacing: -16 Repeater { model: 9 @@ -98,8 +98,8 @@ Rectangle { anchors.right: parent.right; anchors.top: parent.top; anchors.bottom: parent.bottom anchors.margins: 5 - width: 100 - spacing: -60 + width: 64 + spacing: -16 Repeater { model: 9 diff --git a/examples/qtquick/draganddrop/views/gridview.qml b/examples/qtquick/draganddrop/views/gridview.qml index 375f3d2824..04d8dee463 100644 --- a/examples/qtquick/draganddrop/views/gridview.qml +++ b/examples/qtquick/draganddrop/views/gridview.qml @@ -42,8 +42,8 @@ import QtQuick 2.0 GridView { id: root - width: 360; height: 360 - cellWidth: 90; cellHeight: 90 + width: 320; height: 480 + cellWidth: 80; cellHeight: 80 model: VisualDataModel { id: visualModel @@ -61,10 +61,18 @@ GridView { ListElement { color: "aquamarine" } ListElement { color: "indigo" } ListElement { color: "black" } - ListElement { color: "chartreuse" } + ListElement { color: "lightsteelblue" } ListElement { color: "violet" } ListElement { color: "grey" } ListElement { color: "springgreen" } + ListElement { color: "salmon" } + ListElement { color: "blanchedalmond" } + ListElement { color: "forestgreen" } + ListElement { color: "pink" } + ListElement { color: "navy" } + ListElement { color: "goldenrod" } + ListElement { color: "crimson" } + ListElement { color: "teal" } } delegate: MouseArea { @@ -72,12 +80,12 @@ GridView { property int visualIndex: VisualDataModel.itemsIndex - width: 90; height: 90 + width: 80; height: 80 drag.target: icon Rectangle { id: icon - width: 80; height: 80 + width: 72; height: 72 anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter @@ -87,8 +95,8 @@ GridView { Drag.active: delegateRoot.pressed Drag.source: delegateRoot - Drag.hotSpot.x: 40 - Drag.hotSpot.y: 40 + Drag.hotSpot.x: 36 + Drag.hotSpot.y: 36 states: [ State { diff --git a/examples/qtquick/qtquick.pro b/examples/qtquick/qtquick.pro index 2ffc377f32..529f65ac25 100644 --- a/examples/qtquick/qtquick.pro +++ b/examples/qtquick/qtquick.pro @@ -1,8 +1,8 @@ TEMPLATE = subdirs SUBDIRS = accessibility \ - animation + animation \ + draganddrop #canvas \ - #draganddrop \ #imageelements \ #keyinteraction \ #modelviews \ -- cgit v1.2.3 From 01bfcfba0287fa7e9e051e2540ebbdb01fee5a9e Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 28 Feb 2012 11:30:16 +1000 Subject: Move some toys back to examples tvtennis, corkboards and dynamicscene are more examples than demos. clocks and tic-tac-toe are remaining demos for now. Change-Id: I3d9501a4742349a9eb7efdad0d06aa6e7cb02c14 Reviewed-by: Michael Brasser --- examples/demos/corkboards/content/Day.qml | 153 ------------ examples/demos/corkboards/content/cork.jpg | Bin 149337 -> 0 bytes examples/demos/corkboards/content/note-yellow.png | Bin 54559 -> 0 bytes examples/demos/corkboards/content/tack.png | Bin 7282 -> 0 bytes examples/demos/corkboards/corkboards.qml | 116 --------- examples/demos/dynamicscene/content/Button.qml | 80 ------ .../dynamicscene/content/GenericSceneItem.qml | 49 ---- .../demos/dynamicscene/content/PaletteItem.qml | 59 ----- .../demos/dynamicscene/content/PerspectiveItem.qml | 65 ----- examples/demos/dynamicscene/content/Sun.qml | 78 ------ examples/demos/dynamicscene/content/images/NOTE | 1 - .../dynamicscene/content/images/face-smile.png | Bin 15408 -> 0 bytes .../demos/dynamicscene/content/images/moon.png | Bin 1757 -> 0 bytes .../dynamicscene/content/images/rabbit_brown.png | Bin 1245 -> 0 bytes .../dynamicscene/content/images/rabbit_bw.png | Bin 1759 -> 0 bytes .../demos/dynamicscene/content/images/star.png | Bin 349 -> 0 bytes examples/demos/dynamicscene/content/images/sun.png | Bin 8153 -> 0 bytes .../demos/dynamicscene/content/images/tree_s.png | Bin 3406 -> 0 bytes .../demos/dynamicscene/content/itemCreation.js | 62 ----- examples/demos/dynamicscene/dynamicscene.qml | 275 --------------------- examples/demos/tvtennis/tvtennis.qml | 109 -------- examples/qml/dynamicscene/content/Button.qml | 80 ++++++ .../qml/dynamicscene/content/GenericSceneItem.qml | 49 ++++ examples/qml/dynamicscene/content/PaletteItem.qml | 59 +++++ .../qml/dynamicscene/content/PerspectiveItem.qml | 65 +++++ examples/qml/dynamicscene/content/Sun.qml | 78 ++++++ examples/qml/dynamicscene/content/images/NOTE | 1 + .../qml/dynamicscene/content/images/face-smile.png | Bin 0 -> 15408 bytes examples/qml/dynamicscene/content/images/moon.png | Bin 0 -> 1757 bytes .../dynamicscene/content/images/rabbit_brown.png | Bin 0 -> 1245 bytes .../qml/dynamicscene/content/images/rabbit_bw.png | Bin 0 -> 1759 bytes examples/qml/dynamicscene/content/images/star.png | Bin 0 -> 349 bytes examples/qml/dynamicscene/content/images/sun.png | Bin 0 -> 8153 bytes .../qml/dynamicscene/content/images/tree_s.png | Bin 0 -> 3406 bytes examples/qml/dynamicscene/content/itemCreation.js | 62 +++++ examples/qml/dynamicscene/dynamicscene.qml | 275 +++++++++++++++++++++ examples/qtquick/animation/animation.qml | 3 + examples/qtquick/animation/behaviors/tvtennis.qml | 109 ++++++++ .../touchinteraction/flickable/content/Day.qml | 153 ++++++++++++ .../touchinteraction/flickable/content/cork.jpg | Bin 0 -> 149337 bytes .../flickable/content/note-yellow.png | Bin 0 -> 54559 bytes .../touchinteraction/flickable/content/tack.png | Bin 0 -> 7282 bytes .../touchinteraction/flickable/corkboards.qml | 116 +++++++++ 43 files changed, 1050 insertions(+), 1047 deletions(-) delete mode 100644 examples/demos/corkboards/content/Day.qml delete mode 100644 examples/demos/corkboards/content/cork.jpg delete mode 100644 examples/demos/corkboards/content/note-yellow.png delete mode 100644 examples/demos/corkboards/content/tack.png delete mode 100644 examples/demos/corkboards/corkboards.qml delete mode 100644 examples/demos/dynamicscene/content/Button.qml delete mode 100644 examples/demos/dynamicscene/content/GenericSceneItem.qml delete mode 100644 examples/demos/dynamicscene/content/PaletteItem.qml delete mode 100644 examples/demos/dynamicscene/content/PerspectiveItem.qml delete mode 100644 examples/demos/dynamicscene/content/Sun.qml delete mode 100644 examples/demos/dynamicscene/content/images/NOTE delete mode 100644 examples/demos/dynamicscene/content/images/face-smile.png delete mode 100644 examples/demos/dynamicscene/content/images/moon.png delete mode 100644 examples/demos/dynamicscene/content/images/rabbit_brown.png delete mode 100644 examples/demos/dynamicscene/content/images/rabbit_bw.png delete mode 100644 examples/demos/dynamicscene/content/images/star.png delete mode 100644 examples/demos/dynamicscene/content/images/sun.png delete mode 100644 examples/demos/dynamicscene/content/images/tree_s.png delete mode 100644 examples/demos/dynamicscene/content/itemCreation.js delete mode 100644 examples/demos/dynamicscene/dynamicscene.qml delete mode 100644 examples/demos/tvtennis/tvtennis.qml create mode 100644 examples/qml/dynamicscene/content/Button.qml create mode 100644 examples/qml/dynamicscene/content/GenericSceneItem.qml create mode 100644 examples/qml/dynamicscene/content/PaletteItem.qml create mode 100644 examples/qml/dynamicscene/content/PerspectiveItem.qml create mode 100644 examples/qml/dynamicscene/content/Sun.qml create mode 100644 examples/qml/dynamicscene/content/images/NOTE create mode 100644 examples/qml/dynamicscene/content/images/face-smile.png create mode 100644 examples/qml/dynamicscene/content/images/moon.png create mode 100644 examples/qml/dynamicscene/content/images/rabbit_brown.png create mode 100644 examples/qml/dynamicscene/content/images/rabbit_bw.png create mode 100644 examples/qml/dynamicscene/content/images/star.png create mode 100644 examples/qml/dynamicscene/content/images/sun.png create mode 100644 examples/qml/dynamicscene/content/images/tree_s.png create mode 100644 examples/qml/dynamicscene/content/itemCreation.js create mode 100644 examples/qml/dynamicscene/dynamicscene.qml create mode 100644 examples/qtquick/animation/behaviors/tvtennis.qml create mode 100644 examples/qtquick/touchinteraction/flickable/content/Day.qml create mode 100644 examples/qtquick/touchinteraction/flickable/content/cork.jpg create mode 100644 examples/qtquick/touchinteraction/flickable/content/note-yellow.png create mode 100644 examples/qtquick/touchinteraction/flickable/content/tack.png create mode 100644 examples/qtquick/touchinteraction/flickable/corkboards.qml diff --git a/examples/demos/corkboards/content/Day.qml b/examples/demos/corkboards/content/Day.qml deleted file mode 100644 index 7fe625c305..0000000000 --- a/examples/demos/corkboards/content/Day.qml +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Component { - Item { - property variant stickies - - id: page - width: ListView.view.width+40; height: ListView.view.height - - - Image { - source: "cork.jpg" - width: page.ListView.view.width - height: page.ListView.view.height - fillMode: Image.PreserveAspectCrop - clip: true - } - - MouseArea { - anchors.fill: parent - onClicked: page.focus = false; - } - - Text { - text: name; x: 15; y: 8; height: 40; width: 370 - font.pixelSize: 18; font.bold: true; color: "white" - style: Text.Outline; styleColor: "black" - } - - Repeater { - model: notes - Item { - id: stickyPage - - property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100 - property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50 - - x: randomX; y: randomY - - rotation: -flickable.horizontalVelocity / 100; - Behavior on rotation { - SpringAnimation { spring: 2.0; damping: 0.15 } - } - - Item { - id: sticky - scale: 0.7 - - Image { - id: stickyImage - x: 8 + -width * 0.6 / 2; y: -20 - source: "note-yellow.png" - scale: 0.6; transformOrigin: Item.TopLeft - smooth: true - } - - TextEdit { - id: myText - x: -104; y: 36; width: 215; height: 200 - smooth: true - font.pixelSize: 24 - readOnly: false - rotation: -8 - text: noteText - } - - Item { - x: stickyImage.x; y: -20 - width: stickyImage.width * stickyImage.scale - height: stickyImage.height * stickyImage.scale - - MouseArea { - id: mouse - anchors.fill: parent - drag.target: stickyPage - drag.axis: Drag.XandYAxis - drag.minimumY: 0 - drag.maximumY: page.height - 80 - drag.minimumX: 100 - drag.maximumX: page.width - 140 - onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); } - } - } - } - - Image { - x: -width / 2; y: -height * 0.5 / 2 - source: "tack.png" - scale: 0.7; transformOrigin: Item.TopLeft - } - - states: State { - name: "pressed" - when: mouse.pressed - PropertyChanges { target: sticky; rotation: 8; scale: 1 } - PropertyChanges { target: page; z: 8 } - } - - transitions: Transition { - NumberAnimation { properties: "rotation,scale"; duration: 200 } - } - } - } - } -} - - - - - - - - diff --git a/examples/demos/corkboards/content/cork.jpg b/examples/demos/corkboards/content/cork.jpg deleted file mode 100644 index 160bc002bf..0000000000 Binary files a/examples/demos/corkboards/content/cork.jpg and /dev/null differ diff --git a/examples/demos/corkboards/content/note-yellow.png b/examples/demos/corkboards/content/note-yellow.png deleted file mode 100644 index 8ddecc8b03..0000000000 Binary files a/examples/demos/corkboards/content/note-yellow.png and /dev/null differ diff --git a/examples/demos/corkboards/content/tack.png b/examples/demos/corkboards/content/tack.png deleted file mode 100644 index cef2d1cd23..0000000000 Binary files a/examples/demos/corkboards/content/tack.png and /dev/null differ diff --git a/examples/demos/corkboards/corkboards.qml b/examples/demos/corkboards/corkboards.qml deleted file mode 100644 index dc3aa6b378..0000000000 --- a/examples/demos/corkboards/corkboards.qml +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "content" - -Rectangle { - width: 800; height: 480 - color: "#464646" - - ListModel { - id: list - - ListElement { - name: "Sunday" - notes: [ - ListElement { noteText: "Lunch" }, - ListElement { noteText: "Birthday Party" } - ] - } - - ListElement { - name: "Monday" - notes: [ - ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, - ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } - ] - } - - ListElement { - name: "Tuesday" - notes: [ - ListElement { noteText: "Walk dog" }, - ListElement { noteText: "Buy newspaper" } - ] - } - - ListElement { - name: "Wednesday" - notes: [ ListElement { noteText: "Cook dinner" } ] - } - - ListElement { - name: "Thursday" - notes: [ - ListElement { noteText: "Meeting\n5.30pm" }, - ListElement { noteText: "Weed garden" } - ] - } - - ListElement { - name: "Friday" - notes: [ - ListElement { noteText: "More work" }, - ListElement { noteText: "Grocery shopping" } - ] - } - - ListElement { - name: "Saturday" - notes: [ - ListElement { noteText: "Drink" }, - ListElement { noteText: "Download Qt\nPlay with QML" } - ] - } - } - - ListView { - id: flickable - - anchors.fill: parent - focus: true - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem - model: list - delegate: Day { } - } -} diff --git a/examples/demos/dynamicscene/content/Button.qml b/examples/demos/dynamicscene/content/Button.qml deleted file mode 100644 index 014692274a..0000000000 --- a/examples/demos/dynamicscene/content/Button.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: container - - property variant text - signal clicked - - height: text.height + 10; width: text.width + 20 - border.width: 1 - radius: 4 - smooth: true - - gradient: Gradient { - GradientStop { - position: 0.0 - color: !mouseArea.pressed ? activePalette.light : activePalette.button - } - GradientStop { - position: 1.0 - color: !mouseArea.pressed ? activePalette.button : activePalette.dark - } - } - - SystemPalette { id: activePalette } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked() - } - - Text { - id: text - anchors.centerIn:parent - font.pointSize: 10 - text: parent.text - color: activePalette.buttonText - } -} diff --git a/examples/demos/dynamicscene/content/GenericSceneItem.qml b/examples/demos/dynamicscene/content/GenericSceneItem.qml deleted file mode 100644 index 0408aa87fb..0000000000 --- a/examples/demos/dynamicscene/content/GenericSceneItem.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - property bool created: false - property string image - - source: image - -} diff --git a/examples/demos/dynamicscene/content/PaletteItem.qml b/examples/demos/dynamicscene/content/PaletteItem.qml deleted file mode 100644 index e993f89989..0000000000 --- a/examples/demos/dynamicscene/content/PaletteItem.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import "itemCreation.js" as Code - -Image { - id: paletteItem - - property string componentFile - property string image - - source: image - - MouseArea { - anchors.fill: parent - - onPressed: Code.startDrag(mouse); - onPositionChanged: Code.continueDrag(mouse); - onReleased: Code.endDrag(mouse); - } -} diff --git a/examples/demos/dynamicscene/content/PerspectiveItem.qml b/examples/demos/dynamicscene/content/PerspectiveItem.qml deleted file mode 100644 index f651369452..0000000000 --- a/examples/demos/dynamicscene/content/PerspectiveItem.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: rootItem - - property bool created: false - property string image - - property double scaledBottom: y + (height + height*scale) / 2 - property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset) - - source: image - opacity: onLand ? 1 : 0.25 - scale: Math.max((y + height - 250) * 0.01, 0.3) - smooth: true - - onCreatedChanged: { - if (created && !onLand) - rootItem.destroy(); - else - z = scaledBottom; - } - - onYChanged: z = scaledBottom; -} diff --git a/examples/demos/dynamicscene/content/Sun.qml b/examples/demos/dynamicscene/content/Sun.qml deleted file mode 100644 index b84516eecc..0000000000 --- a/examples/demos/dynamicscene/content/Sun.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: sun - - property bool created: false - property string image: "images/sun.png" - - source: image - - // once item is created, start moving offscreen - NumberAnimation on y { - to: (window.height / 2) + window.centerOffset - running: created - onRunningChanged: { - if (running) - duration = (window.height + window.centerOffset - sun.y) * 10; - else - state = "OffScreen" - } - } - - states: State { - name: "OffScreen" - StateChangeScript { - script: { sun.created = false; sun.destroy() } - } - } - - onCreatedChanged: { - if (created) { - sun.z = 1; // above the sky but below the ground layer - window.activeSuns++; - } else { - window.activeSuns--; - } - } -} diff --git a/examples/demos/dynamicscene/content/images/NOTE b/examples/demos/dynamicscene/content/images/NOTE deleted file mode 100644 index fcd87f9132..0000000000 --- a/examples/demos/dynamicscene/content/images/NOTE +++ /dev/null @@ -1 +0,0 @@ -Images (except star.png) are from the KDE project. diff --git a/examples/demos/dynamicscene/content/images/face-smile.png b/examples/demos/dynamicscene/content/images/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/demos/dynamicscene/content/images/face-smile.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/moon.png b/examples/demos/dynamicscene/content/images/moon.png deleted file mode 100644 index 1c0d6066a8..0000000000 Binary files a/examples/demos/dynamicscene/content/images/moon.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/rabbit_brown.png b/examples/demos/dynamicscene/content/images/rabbit_brown.png deleted file mode 100644 index ebfdeed332..0000000000 Binary files a/examples/demos/dynamicscene/content/images/rabbit_brown.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/rabbit_bw.png b/examples/demos/dynamicscene/content/images/rabbit_bw.png deleted file mode 100644 index 7bff9b92ca..0000000000 Binary files a/examples/demos/dynamicscene/content/images/rabbit_bw.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/star.png b/examples/demos/dynamicscene/content/images/star.png deleted file mode 100644 index 27ef924267..0000000000 Binary files a/examples/demos/dynamicscene/content/images/star.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/sun.png b/examples/demos/dynamicscene/content/images/sun.png deleted file mode 100644 index 7713ca5ce7..0000000000 Binary files a/examples/demos/dynamicscene/content/images/sun.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/images/tree_s.png b/examples/demos/dynamicscene/content/images/tree_s.png deleted file mode 100644 index 6eac35a729..0000000000 Binary files a/examples/demos/dynamicscene/content/images/tree_s.png and /dev/null differ diff --git a/examples/demos/dynamicscene/content/itemCreation.js b/examples/demos/dynamicscene/content/itemCreation.js deleted file mode 100644 index 40f5415f9f..0000000000 --- a/examples/demos/dynamicscene/content/itemCreation.js +++ /dev/null @@ -1,62 +0,0 @@ -var itemComponent = null; -var draggedItem = null; -var startingMouse; -var posnInWindow; - -function startDrag(mouse) -{ - posnInWindow = paletteItem.mapToItem(window, 0, 0); - startingMouse = { x: mouse.x, y: mouse.y } - loadComponent(); -} - -//Creation is split into two functions due to an asynchronous wait while -//possible external files are loaded. - -function loadComponent() { - if (itemComponent != null) { // component has been previously loaded - createItem(); - return; - } - - itemComponent = Qt.createComponent(paletteItem.componentFile); - if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately - component.statusChanged.connect(createItem); - else - createItem(); -} - -function createItem() { - if (itemComponent.status == Component.Ready && draggedItem == null) { - draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); - // make sure created item is above the ground layer - } else if (itemComponent.status == Component.Error) { - draggedItem = null; - console.log("error creating component"); - console.log(itemComponent.errorString()); - } -} - -function continueDrag(mouse) -{ - if (draggedItem == null) - return; - - draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; - draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; -} - -function endDrag(mouse) -{ - if (draggedItem == null) - return; - - if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox - draggedItem.destroy(); - draggedItem = null; - } else { - draggedItem.created = true; - draggedItem = null; - } -} - diff --git a/examples/demos/dynamicscene/dynamicscene.qml b/examples/demos/dynamicscene/dynamicscene.qml deleted file mode 100644 index c64df5cfc0..0000000000 --- a/examples/demos/dynamicscene/dynamicscene.qml +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.Particles 2.0 -import "content" - -Item { - id: window - - property int activeSuns: 0 - property int centerOffset: 72 - - height: 480; width: 320 - - - MouseArea { - anchors.fill: parent - onClicked: window.focus = false; - } - - //This is the message box that pops up when there's an error - Rectangle { - id: dialog - - opacity: 0 - anchors.centerIn: parent - width: dialogText.width + 6; height: dialogText.height + 6 - border.color: 'black' - color: 'lightsteelblue' - z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. - - function show(str){ - dialogText.text = str; - dialogAnim.start(); - } - - Text { - id: dialogText - x: 3; y: 3 - font.pixelSize: 14 - } - - SequentialAnimation { - id: dialogAnim - NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } - PauseAnimation { duration: 5000 } - NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } - } - } - - Item { - id: scene - anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right} - z: 10 - } - - // sky - Rectangle { - id: sky - anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } - GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } - } - } - - // stars (when there's no sun) - ParticleSystem { - id: particlesystem - anchors.fill: sky - - ImageParticle { - id: stars - source: "content/images/star.png" - groups: ["stars"] - opacity: .5 - } - - Emitter { - id: starsemitter - anchors.fill: parent - emitRate: parent.width / 50 - lifeSpan: 5000 - group: "stars" - } - } - - // ground - Rectangle { - id: ground - z: 2 // just above the sun so that the sun can set behind it - anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - SystemPalette { id: activePalette } - - // right-hand panel - Rectangle { - id: toolbox - - height: centerOffset * 2 - color: activePalette.window - anchors { right: parent.right; top: parent.top; left: parent.left} - - Column { - anchors.centerIn: parent - spacing: 8 - - Text { text: "Drag an item into the scene." } - - Rectangle { - width: palette.width + 10; height: palette.height + 10 - border.color: "black" - - Row { - id: palette - anchors.centerIn: parent - spacing: 8 - - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "Sun.qml" - source: "content/images/sun.png" - image: "images/sun.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "GenericSceneItem.qml" - source: "content/images/moon.png" - image: "images/moon.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/tree_s.png" - image: "images/tree_s.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/rabbit_brown.png" - image: "images/rabbit_brown.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - source: "content/images/rabbit_bw.png" - image: "images/rabbit_bw.png" - } - } - } - - Text { text: "Active Suns: " + activeSuns } - } - } - - //Popup toolbox down the bottom - Rectangle { - id: popupToolbox - z: 1000 - width: parent.width - height: popupColumn.height + 16 - color: activePalette.window - - property bool poppedUp: false - property int downY: window.height - (createButton.height + 16) - property int upY: window.height - (popupColumn.height + 16) - y: poppedUp ? upY : downY - Behavior on y { NumberAnimation {}} - - Column { - id: popupColumn - y: 8 - anchors.centerIn: parent - spacing: 8 - - Row { - height: createButton.height - spacing: 8 - Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } - Button { - id: popupButton - text: popupToolbox.poppedUp ? "Hide" : "Show" - onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp - } - Button { - id: createButton - text: "Create" - onClicked: { - try { - Qt.createQmlObject(qmlText.text, scene, 'CustomObject'); - } catch(err) { - dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); - } - } - } - - } - - Rectangle { - width: 360; height: 240 - - TextEdit { - id: qmlText - anchors.fill: parent; anchors.margins: 5 - readOnly: false - font.pixelSize: 14 - selectByMouse: true - wrapMode: TextEdit.WordWrap - - text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" - } - } - } - } - - //Day state, for when a sun is added to the scene - states: State { - name: "Day" - when: window.activeSuns > 0 - - PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } - PropertyChanges { target: gradientStopB; color: "SkyBlue" } - PropertyChanges { target: stars; opacity: 0 } - } - - //! [top-level transitions] - transitions: Transition { - PropertyAnimation { duration: 3000 } - ColorAnimation { duration: 3000 } - } - //! [top-level transitions] -} diff --git a/examples/demos/tvtennis/tvtennis.qml b/examples/demos/tvtennis/tvtennis.qml deleted file mode 100644 index 63866e3ce6..0000000000 --- a/examples/demos/tvtennis/tvtennis.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Rectangle { - id: page - width: 640; height: 480 - color: "Black" - - // Make a ball to bounce - Rectangle { - id: ball - - // Add a property for the target y coordinate - property variant direction : "right" - - x: 20; width: 20; height: 20; z: 1 - color: "Lime" - - // Move the ball to the right and back to the left repeatedly - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { to: page.width - 40; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "left" } - NumberAnimation { to: 20; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "right" } - } - - // Make y move with a velocity of 200 - Behavior on y { SpringAnimation{ velocity: 200; } - } - - Component.onCompleted: y = page.height-10; // start the ball motion - - // Detect the ball hitting the top or bottom of the view and bounce it - onYChanged: { - if (y <= 0) { - y = page.height - 20; - } else if (y >= page.height - 20) { - y = 0; - } - } - } - - // Place bats to the left and right of the view, following the y - // coordinates of the ball. - Rectangle { - id: leftBat - color: "Lime" - x: 2; width: 20; height: 90 - y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ velocity: 300 } } - } - Rectangle { - id: rightBat - color: "Lime" - x: page.width - 22; width: 20; height: 90 - y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ velocity: 300 } } - } - - // The rest, to make it look realistic, if neither ever scores... - Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } - Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } - Repeater { - model: page.height / 20 - Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } - } -} diff --git a/examples/qml/dynamicscene/content/Button.qml b/examples/qml/dynamicscene/content/Button.qml new file mode 100644 index 0000000000..014692274a --- /dev/null +++ b/examples/qml/dynamicscene/content/Button.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: container + + property variant text + signal clicked + + height: text.height + 10; width: text.width + 20 + border.width: 1 + radius: 4 + smooth: true + + gradient: Gradient { + GradientStop { + position: 0.0 + color: !mouseArea.pressed ? activePalette.light : activePalette.button + } + GradientStop { + position: 1.0 + color: !mouseArea.pressed ? activePalette.button : activePalette.dark + } + } + + SystemPalette { id: activePalette } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: container.clicked() + } + + Text { + id: text + anchors.centerIn:parent + font.pointSize: 10 + text: parent.text + color: activePalette.buttonText + } +} diff --git a/examples/qml/dynamicscene/content/GenericSceneItem.qml b/examples/qml/dynamicscene/content/GenericSceneItem.qml new file mode 100644 index 0000000000..0408aa87fb --- /dev/null +++ b/examples/qml/dynamicscene/content/GenericSceneItem.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + property bool created: false + property string image + + source: image + +} diff --git a/examples/qml/dynamicscene/content/PaletteItem.qml b/examples/qml/dynamicscene/content/PaletteItem.qml new file mode 100644 index 0000000000..e993f89989 --- /dev/null +++ b/examples/qml/dynamicscene/content/PaletteItem.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "itemCreation.js" as Code + +Image { + id: paletteItem + + property string componentFile + property string image + + source: image + + MouseArea { + anchors.fill: parent + + onPressed: Code.startDrag(mouse); + onPositionChanged: Code.continueDrag(mouse); + onReleased: Code.endDrag(mouse); + } +} diff --git a/examples/qml/dynamicscene/content/PerspectiveItem.qml b/examples/qml/dynamicscene/content/PerspectiveItem.qml new file mode 100644 index 0000000000..f651369452 --- /dev/null +++ b/examples/qml/dynamicscene/content/PerspectiveItem.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: rootItem + + property bool created: false + property string image + + property double scaledBottom: y + (height + height*scale) / 2 + property bool onLand: scaledBottom > (window.height / 2 + window.centerOffset) + + source: image + opacity: onLand ? 1 : 0.25 + scale: Math.max((y + height - 250) * 0.01, 0.3) + smooth: true + + onCreatedChanged: { + if (created && !onLand) + rootItem.destroy(); + else + z = scaledBottom; + } + + onYChanged: z = scaledBottom; +} diff --git a/examples/qml/dynamicscene/content/Sun.qml b/examples/qml/dynamicscene/content/Sun.qml new file mode 100644 index 0000000000..b84516eecc --- /dev/null +++ b/examples/qml/dynamicscene/content/Sun.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Image { + id: sun + + property bool created: false + property string image: "images/sun.png" + + source: image + + // once item is created, start moving offscreen + NumberAnimation on y { + to: (window.height / 2) + window.centerOffset + running: created + onRunningChanged: { + if (running) + duration = (window.height + window.centerOffset - sun.y) * 10; + else + state = "OffScreen" + } + } + + states: State { + name: "OffScreen" + StateChangeScript { + script: { sun.created = false; sun.destroy() } + } + } + + onCreatedChanged: { + if (created) { + sun.z = 1; // above the sky but below the ground layer + window.activeSuns++; + } else { + window.activeSuns--; + } + } +} diff --git a/examples/qml/dynamicscene/content/images/NOTE b/examples/qml/dynamicscene/content/images/NOTE new file mode 100644 index 0000000000..fcd87f9132 --- /dev/null +++ b/examples/qml/dynamicscene/content/images/NOTE @@ -0,0 +1 @@ +Images (except star.png) are from the KDE project. diff --git a/examples/qml/dynamicscene/content/images/face-smile.png b/examples/qml/dynamicscene/content/images/face-smile.png new file mode 100644 index 0000000000..3d66d72578 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/face-smile.png differ diff --git a/examples/qml/dynamicscene/content/images/moon.png b/examples/qml/dynamicscene/content/images/moon.png new file mode 100644 index 0000000000..1c0d6066a8 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/moon.png differ diff --git a/examples/qml/dynamicscene/content/images/rabbit_brown.png b/examples/qml/dynamicscene/content/images/rabbit_brown.png new file mode 100644 index 0000000000..ebfdeed332 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/rabbit_brown.png differ diff --git a/examples/qml/dynamicscene/content/images/rabbit_bw.png b/examples/qml/dynamicscene/content/images/rabbit_bw.png new file mode 100644 index 0000000000..7bff9b92ca Binary files /dev/null and b/examples/qml/dynamicscene/content/images/rabbit_bw.png differ diff --git a/examples/qml/dynamicscene/content/images/star.png b/examples/qml/dynamicscene/content/images/star.png new file mode 100644 index 0000000000..27ef924267 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/star.png differ diff --git a/examples/qml/dynamicscene/content/images/sun.png b/examples/qml/dynamicscene/content/images/sun.png new file mode 100644 index 0000000000..7713ca5ce7 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/sun.png differ diff --git a/examples/qml/dynamicscene/content/images/tree_s.png b/examples/qml/dynamicscene/content/images/tree_s.png new file mode 100644 index 0000000000..6eac35a729 Binary files /dev/null and b/examples/qml/dynamicscene/content/images/tree_s.png differ diff --git a/examples/qml/dynamicscene/content/itemCreation.js b/examples/qml/dynamicscene/content/itemCreation.js new file mode 100644 index 0000000000..40f5415f9f --- /dev/null +++ b/examples/qml/dynamicscene/content/itemCreation.js @@ -0,0 +1,62 @@ +var itemComponent = null; +var draggedItem = null; +var startingMouse; +var posnInWindow; + +function startDrag(mouse) +{ + posnInWindow = paletteItem.mapToItem(window, 0, 0); + startingMouse = { x: mouse.x, y: mouse.y } + loadComponent(); +} + +//Creation is split into two functions due to an asynchronous wait while +//possible external files are loaded. + +function loadComponent() { + if (itemComponent != null) { // component has been previously loaded + createItem(); + return; + } + + itemComponent = Qt.createComponent(paletteItem.componentFile); + if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately + component.statusChanged.connect(createItem); + else + createItem(); +} + +function createItem() { + if (itemComponent.status == Component.Ready && draggedItem == null) { + draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); + // make sure created item is above the ground layer + } else if (itemComponent.status == Component.Error) { + draggedItem = null; + console.log("error creating component"); + console.log(itemComponent.errorString()); + } +} + +function continueDrag(mouse) +{ + if (draggedItem == null) + return; + + draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; + draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; +} + +function endDrag(mouse) +{ + if (draggedItem == null) + return; + + if (draggedItem.y < toolbox.height) { //Don't drop it in the toolbox + draggedItem.destroy(); + draggedItem = null; + } else { + draggedItem.created = true; + draggedItem = null; + } +} + diff --git a/examples/qml/dynamicscene/dynamicscene.qml b/examples/qml/dynamicscene/dynamicscene.qml new file mode 100644 index 0000000000..c64df5cfc0 --- /dev/null +++ b/examples/qml/dynamicscene/dynamicscene.qml @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "content" + +Item { + id: window + + property int activeSuns: 0 + property int centerOffset: 72 + + height: 480; width: 320 + + + MouseArea { + anchors.fill: parent + onClicked: window.focus = false; + } + + //This is the message box that pops up when there's an error + Rectangle { + id: dialog + + opacity: 0 + anchors.centerIn: parent + width: dialogText.width + 6; height: dialogText.height + 6 + border.color: 'black' + color: 'lightsteelblue' + z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. + + function show(str){ + dialogText.text = str; + dialogAnim.start(); + } + + Text { + id: dialogText + x: 3; y: 3 + font.pixelSize: 14 + } + + SequentialAnimation { + id: dialogAnim + NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } + PauseAnimation { duration: 5000 } + NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } + } + } + + Item { + id: scene + anchors { top: sky.top; bottom: ground.bottom; left: parent.left; right: parent.right} + z: 10 + } + + // sky + Rectangle { + id: sky + anchors { left: parent.left; top: toolbox.bottom; right: parent.right; bottomMargin: -centerOffset; bottom: parent.verticalCenter } + gradient: Gradient { + GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } + GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } + } + } + + // stars (when there's no sun) + ParticleSystem { + id: particlesystem + anchors.fill: sky + + ImageParticle { + id: stars + source: "content/images/star.png" + groups: ["stars"] + opacity: .5 + } + + Emitter { + id: starsemitter + anchors.fill: parent + emitRate: parent.width / 50 + lifeSpan: 5000 + group: "stars" + } + } + + // ground + Rectangle { + id: ground + z: 2 // just above the sun so that the sun can set behind it + anchors { left: parent.left; top: parent.verticalCenter; topMargin: centerOffset; right: parent.right; bottom: parent.bottom } + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen" } + GradientStop { position: 1.0; color: "DarkGreen" } + } + } + + SystemPalette { id: activePalette } + + // right-hand panel + Rectangle { + id: toolbox + + height: centerOffset * 2 + color: activePalette.window + anchors { right: parent.right; top: parent.top; left: parent.left} + + Column { + anchors.centerIn: parent + spacing: 8 + + Text { text: "Drag an item into the scene." } + + Rectangle { + width: palette.width + 10; height: palette.height + 10 + border.color: "black" + + Row { + id: palette + anchors.centerIn: parent + spacing: 8 + + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "Sun.qml" + source: "content/images/sun.png" + image: "images/sun.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "GenericSceneItem.qml" + source: "content/images/moon.png" + image: "images/moon.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/tree_s.png" + image: "images/tree_s.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/rabbit_brown.png" + image: "images/rabbit_brown.png" + } + PaletteItem { + anchors.verticalCenter: parent.verticalCenter + componentFile: "PerspectiveItem.qml" + source: "content/images/rabbit_bw.png" + image: "images/rabbit_bw.png" + } + } + } + + Text { text: "Active Suns: " + activeSuns } + } + } + + //Popup toolbox down the bottom + Rectangle { + id: popupToolbox + z: 1000 + width: parent.width + height: popupColumn.height + 16 + color: activePalette.window + + property bool poppedUp: false + property int downY: window.height - (createButton.height + 16) + property int upY: window.height - (popupColumn.height + 16) + y: poppedUp ? upY : downY + Behavior on y { NumberAnimation {}} + + Column { + id: popupColumn + y: 8 + anchors.centerIn: parent + spacing: 8 + + Row { + height: createButton.height + spacing: 8 + Text { text: "Custom QML:"; anchors.verticalCenter: parent.verticalCenter } + Button { + id: popupButton + text: popupToolbox.poppedUp ? "Hide" : "Show" + onClicked: popupToolbox.poppedUp = !popupToolbox.poppedUp + } + Button { + id: createButton + text: "Create" + onClicked: { + try { + Qt.createQmlObject(qmlText.text, scene, 'CustomObject'); + } catch(err) { + dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); + } + } + } + + } + + Rectangle { + width: 360; height: 240 + + TextEdit { + id: qmlText + anchors.fill: parent; anchors.margins: 5 + readOnly: false + font.pixelSize: 14 + selectByMouse: true + wrapMode: TextEdit.WordWrap + + text: "import QtQuick 2.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'content/images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" + } + } + } + } + + //Day state, for when a sun is added to the scene + states: State { + name: "Day" + when: window.activeSuns > 0 + + PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } + PropertyChanges { target: gradientStopB; color: "SkyBlue" } + PropertyChanges { target: stars; opacity: 0 } + } + + //! [top-level transitions] + transitions: Transition { + PropertyAnimation { duration: 3000 } + ColorAnimation { duration: 3000 } + } + //! [top-level transitions] +} diff --git a/examples/qtquick/animation/animation.qml b/examples/qtquick/animation/animation.qml index 62a85a9cfa..bca68457d9 100644 --- a/examples/qtquick/animation/animation.qml +++ b/examples/qtquick/animation/animation.qml @@ -58,6 +58,8 @@ import "../../shared" as Examples Wiggly Text demonstrates using more complex behaviors to animate and wiggle some text around as you drag it. + Tv Tennis demonstrates using more complex behaviors to get paddles following a ball for an infinite game. + Easing Curves shows off all the easing curves available in Qt Quick animations. States demonstrates how the properties of an item can vary between states. @@ -80,6 +82,7 @@ Item { addExample("PropertyAnimation", "Interpolates between numbers", Qt.resolvedUrl("basics/property-animation.qml")); addExample("Behaviors", "Animates procedural movement", Qt.resolvedUrl("behaviors/behavior-example.qml")); addExample("Wiggly Text", "Text that wiggles as you drag it", Qt.resolvedUrl("behaviors/wigglytext.qml")); + addExample("Tv Tennis", "Paddles that follow a ball", Qt.resolvedUrl("behaviors/tvtennis.qml")); addExample("Easing Curves", "Compare available easing curves", Qt.resolvedUrl("easing/easing.qml")); addExample("States", "Simple states", Qt.resolvedUrl("states/states.qml")); addExample("Transitions", "Simple states with animated transitions", Qt.resolvedUrl("states/transitions.qml")); diff --git a/examples/qtquick/animation/behaviors/tvtennis.qml b/examples/qtquick/animation/behaviors/tvtennis.qml new file mode 100644 index 0000000000..108f19a11d --- /dev/null +++ b/examples/qtquick/animation/behaviors/tvtennis.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: page + width: 320; height: 480; + color: "Black" + + // Make a ball to bounce + Rectangle { + id: ball + + // Add a property for the target y coordinate + property variant direction : "right" + + x: 20; width: 20; height: 20; z: 1 + color: "Lime" + + // Move the ball to the right and back to the left repeatedly + SequentialAnimation on x { + loops: Animation.Infinite + NumberAnimation { to: page.width - 40; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "left" } + NumberAnimation { to: 20; duration: 2000 } + PropertyAction { target: ball; property: "direction"; value: "right" } + } + + // Make y move with a velocity of 200 + Behavior on y { SpringAnimation{ velocity: 200; } + } + + Component.onCompleted: y = page.height-10; // start the ball motion + + // Detect the ball hitting the top or bottom of the view and bounce it + onYChanged: { + if (y <= 0) { + y = page.height - 20; + } else if (y >= page.height - 20) { + y = 0; + } + } + } + + // Place bats to the left and right of the view, following the y + // coordinates of the ball. + Rectangle { + id: leftBat + color: "Lime" + x: 2; width: 20; height: 90 + y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45; + Behavior on y { SpringAnimation{ velocity: 300 } } + } + Rectangle { + id: rightBat + color: "Lime" + x: page.width - 22; width: 20; height: 90 + y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45; + Behavior on y { SpringAnimation{ velocity: 300 } } + } + + // The rest, to make it look realistic, if neither ever scores... + Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } + Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } + Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } + Repeater { + model: page.height / 20 + Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } + } +} diff --git a/examples/qtquick/touchinteraction/flickable/content/Day.qml b/examples/qtquick/touchinteraction/flickable/content/Day.qml new file mode 100644 index 0000000000..7fe625c305 --- /dev/null +++ b/examples/qtquick/touchinteraction/flickable/content/Day.qml @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Component { + Item { + property variant stickies + + id: page + width: ListView.view.width+40; height: ListView.view.height + + + Image { + source: "cork.jpg" + width: page.ListView.view.width + height: page.ListView.view.height + fillMode: Image.PreserveAspectCrop + clip: true + } + + MouseArea { + anchors.fill: parent + onClicked: page.focus = false; + } + + Text { + text: name; x: 15; y: 8; height: 40; width: 370 + font.pixelSize: 18; font.bold: true; color: "white" + style: Text.Outline; styleColor: "black" + } + + Repeater { + model: notes + Item { + id: stickyPage + + property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100 + property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50 + + x: randomX; y: randomY + + rotation: -flickable.horizontalVelocity / 100; + Behavior on rotation { + SpringAnimation { spring: 2.0; damping: 0.15 } + } + + Item { + id: sticky + scale: 0.7 + + Image { + id: stickyImage + x: 8 + -width * 0.6 / 2; y: -20 + source: "note-yellow.png" + scale: 0.6; transformOrigin: Item.TopLeft + smooth: true + } + + TextEdit { + id: myText + x: -104; y: 36; width: 215; height: 200 + smooth: true + font.pixelSize: 24 + readOnly: false + rotation: -8 + text: noteText + } + + Item { + x: stickyImage.x; y: -20 + width: stickyImage.width * stickyImage.scale + height: stickyImage.height * stickyImage.scale + + MouseArea { + id: mouse + anchors.fill: parent + drag.target: stickyPage + drag.axis: Drag.XandYAxis + drag.minimumY: 0 + drag.maximumY: page.height - 80 + drag.minimumX: 100 + drag.maximumX: page.width - 140 + onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); } + } + } + } + + Image { + x: -width / 2; y: -height * 0.5 / 2 + source: "tack.png" + scale: 0.7; transformOrigin: Item.TopLeft + } + + states: State { + name: "pressed" + when: mouse.pressed + PropertyChanges { target: sticky; rotation: 8; scale: 1 } + PropertyChanges { target: page; z: 8 } + } + + transitions: Transition { + NumberAnimation { properties: "rotation,scale"; duration: 200 } + } + } + } + } +} + + + + + + + + diff --git a/examples/qtquick/touchinteraction/flickable/content/cork.jpg b/examples/qtquick/touchinteraction/flickable/content/cork.jpg new file mode 100644 index 0000000000..160bc002bf Binary files /dev/null and b/examples/qtquick/touchinteraction/flickable/content/cork.jpg differ diff --git a/examples/qtquick/touchinteraction/flickable/content/note-yellow.png b/examples/qtquick/touchinteraction/flickable/content/note-yellow.png new file mode 100644 index 0000000000..8ddecc8b03 Binary files /dev/null and b/examples/qtquick/touchinteraction/flickable/content/note-yellow.png differ diff --git a/examples/qtquick/touchinteraction/flickable/content/tack.png b/examples/qtquick/touchinteraction/flickable/content/tack.png new file mode 100644 index 0000000000..cef2d1cd23 Binary files /dev/null and b/examples/qtquick/touchinteraction/flickable/content/tack.png differ diff --git a/examples/qtquick/touchinteraction/flickable/corkboards.qml b/examples/qtquick/touchinteraction/flickable/corkboards.qml new file mode 100644 index 0000000000..dc3aa6b378 --- /dev/null +++ b/examples/qtquick/touchinteraction/flickable/corkboards.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import "content" + +Rectangle { + width: 800; height: 480 + color: "#464646" + + ListModel { + id: list + + ListElement { + name: "Sunday" + notes: [ + ListElement { noteText: "Lunch" }, + ListElement { noteText: "Birthday Party" } + ] + } + + ListElement { + name: "Monday" + notes: [ + ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, + ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } + ] + } + + ListElement { + name: "Tuesday" + notes: [ + ListElement { noteText: "Walk dog" }, + ListElement { noteText: "Buy newspaper" } + ] + } + + ListElement { + name: "Wednesday" + notes: [ ListElement { noteText: "Cook dinner" } ] + } + + ListElement { + name: "Thursday" + notes: [ + ListElement { noteText: "Meeting\n5.30pm" }, + ListElement { noteText: "Weed garden" } + ] + } + + ListElement { + name: "Friday" + notes: [ + ListElement { noteText: "More work" }, + ListElement { noteText: "Grocery shopping" } + ] + } + + ListElement { + name: "Saturday" + notes: [ + ListElement { noteText: "Drink" }, + ListElement { noteText: "Download Qt\nPlay with QML" } + ] + } + } + + ListView { + id: flickable + + anchors.fill: parent + focus: true + highlightRangeMode: ListView.StrictlyEnforceRange + orientation: ListView.Horizontal + snapMode: ListView.SnapOneItem + model: list + delegate: Day { } + } +} -- cgit v1.2.3 From 60cae093d7e27e92198d626dc3df19dea9799faf Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 28 Feb 2012 11:41:50 +1000 Subject: Examples guidelines have changes slightly Update docs to current thinking. Change-Id: Ide00240f4d779549eebdc81592f3f2104dfd759a Reviewed-by: Michael Brasser --- examples/HACKING | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/HACKING b/examples/HACKING index a3aa3e9a77..7eea4975ac 100644 --- a/examples/HACKING +++ b/examples/HACKING @@ -7,13 +7,13 @@ Snippets are snatches of QML code that won't even run on their own. They don't b Examples --- -Examples are large blocks of QML code that demonstrate a feature. You should be able to launch an example and visually see the feature take effect. Examples should be written in a small form, and should automatically activate any features. Ideally, when you run an example, you see the feature demonstrate itself over and over until you get bored and close the application using your platform's close window mechanism. Examples shouldn't contain their own close buttons or start screen, explanatory text should be kept to a minimum (show, not tell), and reserve interaction for demonstrating interactive elements). The code should be held to a high level of quality, and should be understandable by people new to QML. +Examples are large blocks of QML code that demonstrate a feature. You should be able to launch an example and visually see the feature take effect. Examples should be written in a small form, and should automatically activate any features. Ideally, when you run an example, you see the feature demonstrate itself over and over until you get bored and close the application using your platform's close window mechanism. Examples shouldn't contain their own close buttons or start screen, explanatory text should be kept to a minimum (show, not tell), and reserve interaction for demonstrating interactive elements. The code should be held to a high level of quality, and should be understandable by people new to QML. Unless the demonstrated feature uses it, assume no interface devices other than a screen that can show a 320x480 rectangle and a generic pointing device (with the shared subset of mouse/touch functionality). -Groups of similar examples should be placed in one folder with a single launcher application, which uses the QtQuick.Examples module for common components. +Groups of similar examples should be placed in one folder with a single launcher application, which uses the shared folder of common components. -The example, or launcher application in case of groups, should contain a qdoc comment explaining the example. The example or launcher should be buildable as a full C++ application and runnable with the standard qml file launcher. +The example, or launcher application in case of groups, should contain a qdoc comment explaining the example. The example or launcher should be buildable as a full C++ application and runnable with the standard qml file launcher. Usually this will consist primarily of using the macro found in shared.h. Demos --- -- cgit v1.2.3 From 328c100ab3fc4d5ddccb0d19af9d7e87bd849f0b Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 21 Feb 2012 14:44:21 +1000 Subject: Separate view transition functionality into new file Move most of the view transition functionality from qquickitemview* into qquickitemviewtransition*. - Move QQuickViewTransitionAttached - Move QQuickItemViewTransitionManager, rename to QQuickItemViewTransitionJob - Move FxViewItem transition-specific features into new QQuickViewItem - Move transition-specific functions like transitionNextReposition() and canTransition() into QQuickItemViewTransitioner which holds all the transition objects now Also mention in docs that there's no defined order for choosing between multiple matching displaced transitions. Change-Id: I8701c0d40d2af152c5d432a4c8de646854c76ea2 Reviewed-by: Martin Jones --- src/quick/items/items.pri | 2 + src/quick/items/qquickgridview.cpp | 42 +- src/quick/items/qquickitemsmodule.cpp | 1 + src/quick/items/qquickitemview.cpp | 890 ++++----------------------- src/quick/items/qquickitemview_p.h | 44 -- src/quick/items/qquickitemview_p_p.h | 88 +-- src/quick/items/qquickitemviewtransition.cpp | 770 +++++++++++++++++++++++ src/quick/items/qquickitemviewtransition_p.h | 201 ++++++ src/quick/items/qquicklistview.cpp | 42 +- 9 files changed, 1159 insertions(+), 921 deletions(-) create mode 100644 src/quick/items/qquickitemviewtransition.cpp create mode 100644 src/quick/items/qquickitemviewtransition_p.h diff --git a/src/quick/items/items.pri b/src/quick/items/items.pri index 21bf7cc8c1..54220434b4 100644 --- a/src/quick/items/items.pri +++ b/src/quick/items/items.pri @@ -72,6 +72,7 @@ HEADERS += \ $$PWD/qquickmultipointtoucharea_p.h \ $$PWD/qquickitemview_p.h \ $$PWD/qquickitemview_p_p.h \ + $$PWD/qquickitemviewtransition_p.h \ $$PWD/qquickscreen_p.h \ $$PWD/qquickwindowmodule_p.h \ $$PWD/qquickwindowmanager_p.h @@ -124,6 +125,7 @@ SOURCES += \ $$PWD/qquickdroparea.cpp \ $$PWD/qquickmultipointtoucharea.cpp \ $$PWD/qquickitemview.cpp \ + $$PWD/qquickitemviewtransition.cpp \ $$PWD/qquickwindowmodule.cpp \ $$PWD/qquickscreen.cpp \ $$PWD/qquickwindowmanager.cpp diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp index a7e0af487f..fbce0af0c3 100644 --- a/src/quick/items/qquickgridview.cpp +++ b/src/quick/items/qquickgridview.cpp @@ -127,9 +127,6 @@ public: return (x >= itemX() && x < itemX() + view->cellWidth() && y >= itemY() && y < itemY() + view->cellHeight()); } - QQuickItemView *itemView() const { - return view; - } QQuickGridView *view; @@ -485,7 +482,7 @@ bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool d #endif if (!(item = static_cast(createItem(modelIndex, doBuffer)))) break; - if (!canTransition(FxViewItemTransitionManager::PopulateTransition, true)) // pos will be set by layoutVisibleItems() + if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems() item->setPosition(colPos, rowPos); item->item->setVisible(!doBuffer); visibleItems.append(item); @@ -523,7 +520,7 @@ bool QQuickGridViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool d if (!(item = static_cast(createItem(visibleIndex-1, doBuffer)))) break; --visibleIndex; - if (!canTransition(FxViewItemTransitionManager::PopulateTransition, true)) // pos will be set by layoutVisibleItems() + if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems() item->setPosition(colPos, rowPos); item->item->setVisible(!doBuffer); visibleItems.prepend(item); @@ -1674,6 +1671,10 @@ void QQuickGridView::setSnapMode(SnapMode mode) the new item that has been added to the view; to animate the added items, set the \l add property. + If an item is displaced by multiple types of operations at the same time, it is not + defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition + will be applied. + For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -1737,6 +1738,10 @@ void QQuickGridView::setSnapMode(SnapMode mode) the items that are the actual subjects of the move operation; to animate the moved items, set the \l move property. + If an item is displaced by multiple types of operations at the same time, it is not + defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition + will be applied. + For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -1804,6 +1809,10 @@ void QQuickGridView::setSnapMode(SnapMode mode) the item that has actually been removed from the view; to animate the removed items, set the \l remove property. + If an item is displaced by multiple types of operations at the same time, it is not + defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition + will be applied. + For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2112,10 +2121,12 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In FxViewItem *item = visibleItems.at(i); if (item->index != -1 && item->index >= modelIndex) { item->index += count; - if (change.isMove()) - transitionNextReposition(item, FxViewItemTransitionManager::MoveTransition, false); - else - transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, false); + if (transitioner) { + if (change.isMove()) + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::MoveTransition, false); + else + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, false); + } } } @@ -2146,7 +2157,8 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In insertResult->changedFirstItem = true; if (!change.isMove()) { addedItems->append(item); - transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, true); + if (transitioner) + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, true); } insertResult->sizeChangesBeforeVisiblePos += rowSize(); } @@ -2179,11 +2191,12 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In if (change.isMove()) { // we know this is a move target, since move displaced items that are // shuffled into view due to a move would be added in refill() - if (canTransition(FxViewItemTransitionManager::MoveTransition, true) && newItem) + if (newItem && transitioner && transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, true)) movingIntoView->append(MovedItem(item, change.moveKey(item->index))); } else { addedItems->append(item); - transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, true); + if (transitioner) + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, true); } insertResult->sizeChangesAfterVisiblePos += rowSize(); @@ -2204,6 +2217,9 @@ bool QQuickGridViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In void QQuickGridViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex, const ChangeResult &insertionResult, const ChangeResult &removalResult) { + if (!transitioner) + return; + int markerItemIndex = -1; for (int i=0; iindex == afterModelIndex) { @@ -2231,7 +2247,7 @@ void QQuickGridViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex qreal origColPos = gridItem->rowPos(); int indexDiff = gridItem->index - countItemsRemoved; gridItem->setPosition((indexDiff % columns) * colSize(), (indexDiff / columns) * rowSize()); - transitionNextReposition(gridItem, FxViewItemTransitionManager::RemoveTransition, false); + transitioner->transitionNextReposition(gridItem, QQuickItemViewTransitioner::RemoveTransition, false); gridItem->setPosition(origRowPos, origColPos); } } diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index b9e401a231..f50237427b 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -61,6 +61,7 @@ #include "qquickvisualdatamodel_p.h" #include "qquickgridview_p.h" #include "qquickpathview_p.h" +#include "qquickitemviewtransition_p.h" #include #include #include "qquickpositioners_p.h" diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index d5ce567590..481a0d4360 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -46,21 +46,12 @@ QT_BEGIN_NAMESPACE FxViewItem::FxViewItem(QQuickItem *i, bool own) - : item(i), ownItem(own), releaseAfterTransition(false) - , isTransitionTarget(false) - , nextTransitionToSet(false) - , index(-1) - , transition(0) - , nextTransitionType(FxViewItemTransitionManager::NoTransition) + : QQuickViewItem(i), ownItem(own), releaseAfterTransition(false) { } FxViewItem::~FxViewItem() { - if (transition) - transition->m_item = 0; - delete transition; - if (ownItem && item) { item->setParentItem(0); item->deleteLater(); @@ -68,273 +59,6 @@ FxViewItem::~FxViewItem() } } -qreal FxViewItem::itemX() const -{ - if (nextTransitionType != FxViewItemTransitionManager::NoTransition) - return nextTransitionToSet ? nextTransitionTo.x() : item->x(); - else if (transition && transition->isActive()) - return transition->m_toPos.x(); - else - return item->x(); -} - -qreal FxViewItem::itemY() const -{ - // If item is transitioning to some pos, return that dest pos. - // If item was redirected to some new pos before the current transition finished, - // return that new pos. - if (nextTransitionType != FxViewItemTransitionManager::NoTransition) - return nextTransitionToSet ? nextTransitionTo.y() : item->y(); - else if (transition && transition->isActive()) - return transition->m_toPos.y(); - else - return item->y(); -} - -void FxViewItem::setVisible(bool visible) -{ - if (!visible && transitionScheduledOrRunning()) - return; - item->setVisible(visible); -} - -void FxViewItem::setNextTransition(FxViewItemTransitionManager::TransitionType type, bool isTargetItem) -{ - // Don't reset nextTransitionToSet - once it is set, it cannot be changed - // until the animation finishes since the itemX() and itemY() may be used - // to calculate positions for transitions for other items in the view. - nextTransitionType = type; - isTransitionTarget = isTargetItem; -} - -bool FxViewItem::transitionScheduledOrRunning() const -{ - return (transition && transition->isActive()) - || nextTransitionType != FxViewItemTransitionManager::NoTransition; -} - -bool FxViewItem::prepareTransition(const QRectF &viewBounds) -{ - bool doTransition = false; - - switch (nextTransitionType) { - case FxViewItemTransitionManager::NoTransition: - { - return false; - } - case FxViewItemTransitionManager::PopulateTransition: - { - return true; - } - case FxViewItemTransitionManager::AddTransition: - case FxViewItemTransitionManager::RemoveTransition: - // For Add targets, do transition if item is moving into visible area - // For Remove targets, do transition if item is currently in visible area - if (isTransitionTarget) { - doTransition = (nextTransitionType == FxViewItemTransitionManager::AddTransition) - ? viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height())) - : viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())); - if (!doTransition) - item->setPos(nextTransitionTo); - } else { - if (viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())) - || viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height()))) { - doTransition = (nextTransitionTo != item->pos()); - } else { - item->setPos(nextTransitionTo); - } - } - break; - case FxViewItemTransitionManager::MoveTransition: - // do transition if moving from or into visible area - if (nextTransitionTo != item->pos()) { - doTransition = viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())) - || viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height())); - if (!doTransition) - item->setPos(nextTransitionTo); - } - break; - } - - if (!doTransition) - resetTransitionData(); - return doTransition; -} - -void FxViewItem::startTransition() -{ - if (nextTransitionType == FxViewItemTransitionManager::NoTransition) - return; - - if (!transition || transition->m_type != nextTransitionType || transition->m_isTarget != isTransitionTarget) { - delete transition; - transition = new FxViewItemTransitionManager; - } - - // if item is not already moving somewhere, set it to not move anywhere - // so that removed items do not move to the default (0,0) - if (!nextTransitionToSet) - moveTo(item->pos()); - - transition->startTransition(this, nextTransitionType, nextTransitionTo, isTransitionTarget); - nextTransitionType = FxViewItemTransitionManager::NoTransition; -} - -void FxViewItem::stopTransition() -{ - if (transition) { - transition->cancel(); - delete transition; - transition = 0; - } - resetTransitionData(); - finishedTransition(); -} - -void FxViewItem::finishedTransition() -{ - nextTransitionToSet = false; - nextTransitionTo = QPointF(); - - if (releaseAfterTransition) { - QQuickItemViewPrivate *vp = static_cast(QObjectPrivate::get(itemView())); - vp->releasePendingTransition.removeOne(this); - vp->releaseItem(this); - } -} - -void FxViewItem::resetTransitionData() -{ - nextTransitionType = FxViewItemTransitionManager::NoTransition; - isTransitionTarget = false; - nextTransitionTo = QPointF(); - nextTransitionToSet = false; -} - -bool FxViewItem::isPendingRemoval() const -{ - if (nextTransitionType == FxViewItemTransitionManager::RemoveTransition) - return isTransitionTarget; - if (transition && transition->isActive() && transition->m_type == FxViewItemTransitionManager::RemoveTransition) - return transition->m_isTarget; - return false; -} - -void FxViewItem::moveTo(const QPointF &pos) -{ - if (transitionScheduledOrRunning()) { - nextTransitionTo = pos; - nextTransitionToSet = true; - } else { - item->setPos(pos); - } -} - - -FxViewItemTransitionManager::FxViewItemTransitionManager() - : m_active(false), m_item(0), m_type(FxViewItemTransitionManager::NoTransition), m_isTarget(false) -{ -} - -FxViewItemTransitionManager::~FxViewItemTransitionManager() -{ -} - -bool FxViewItemTransitionManager::isActive() const -{ - return m_active; -} - -void FxViewItemTransitionManager::startTransition(FxViewItem *item, FxViewItemTransitionManager::TransitionType type, const QPointF &to, bool isTargetItem) -{ - if (!item) { - qWarning("startTransition(): invalid item"); - return; - } - - QQuickItemViewPrivate *vp = static_cast(QObjectPrivate::get(item->itemView())); - - QDeclarativeTransition *trans = 0; - switch (type) { - case NoTransition: - break; - case PopulateTransition: - trans = vp->populateTransition; - break; - case AddTransition: - trans = isTargetItem ? vp->addTransition : vp->addDisplacedTransition; - break; - case MoveTransition: - trans = isTargetItem ? vp->moveTransition : vp->moveDisplacedTransition; - break; - case RemoveTransition: - trans = isTargetItem ? vp->removeTransition : vp->removeDisplacedTransition; - break; - } - - if (!trans) { - qWarning("QQuickItemView: invalid view transition!"); - return; - } - - m_active = true; - m_item = item; - m_toPos = to; - m_type = type; - m_isTarget = isTargetItem; - - QQuickViewTransitionAttached *attached = - static_cast(qmlAttachedPropertiesObject(trans)); - if (attached) { - attached->m_index = item->index; - attached->m_item = item->item; - attached->m_destination = to; - switch (type) { - case NoTransition: - break; - case PopulateTransition: - case AddTransition: - attached->m_targetIndexes = vp->addTransitionIndexes; - attached->m_targetItems = vp->addTransitionTargets; - break; - case MoveTransition: - attached->m_targetIndexes = vp->moveTransitionIndexes; - attached->m_targetItems = vp->moveTransitionTargets; - break; - case RemoveTransition: - attached->m_targetIndexes = vp->removeTransitionIndexes; - attached->m_targetItems = vp->removeTransitionTargets; - break; - } - emit attached->indexChanged(); - emit attached->itemChanged(); - emit attached->destinationChanged(); - emit attached->targetIndexesChanged(); - emit attached->targetItemsChanged(); - } - - QDeclarativeStateOperation::ActionList actions; - actions << QDeclarativeAction(item->item, QLatin1String("x"), QVariant(to.x())); - actions << QDeclarativeAction(item->item, QLatin1String("y"), QVariant(to.y())); - - QDeclarativeTransitionManager::transition(actions, trans, item->item); -} - -void FxViewItemTransitionManager::finished() -{ - QDeclarativeTransitionManager::finished(); - - m_active = false; - - if (m_item) - m_item->finishedTransition(); - m_item = 0; - m_toPos.setX(0); - m_toPos.setY(0); - m_type = NoTransition; - m_isTarget = false; -} - QQuickItemViewChangeSet::QQuickItemViewChangeSet() : active(false) @@ -413,363 +137,6 @@ void QQuickItemViewChangeSet::reset() currentRemoved = false; } - -QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) - : QObject(parent), m_index(-1), m_item(0) -{ -} -/*! - \qmlclass ViewTransition QQuickViewTransitionAttached - \inqmlmodule QtQuick 2 - \ingroup qml-view-elements - \brief The ViewTransition attached property provides details on items under transition in a view. - - With ListView and GridView, it is possible to specify transitions that should be applied whenever - the items in the view change as a result of modifications to the view's model. They both have the - following properties that can be set to the appropriate transitions to be run for various - operations: - - \list - \o \c add and \c addDisplaced - the transitions to run when items are added to the view - \o \c remove and \c removeDisplaced - the transitions to run when items are removed from the view - \o \c move and \c moveDisplaced - the transitions to run when items are moved within the view - (i.e. as a result of a move operation in the model) - \o \c populate - the transition to run when a view is created, or when the model changes - \endlist - - Such view transitions additionally have access to a ViewTransition attached property that - provides details of the items that are under transition and the operation that triggered the - transition. Since view transitions are run once per item, these details can be used to customise - each transition for each individual item. - - The ViewTransition attached property provides the following properties specific to the item to - which the transition is applied: - - \list - \o ViewTransition.item - the item that is under transition - \o ViewTransition.index - the index of this item - \o ViewTransition.destination - the (x,y) point to which this item is moving for the relevant view operation - \endlist - - In addition, ViewTransition provides properties specific to the items which are the target - of the operation that triggered the transition: - - \list - \o ViewTransition.targetIndexes - the indexes of the target items - \o ViewTransition.targetItems - the target items themselves - \endlist - - View transitions can be written without referring to any of the attributes listed - above. These attributes merely provide extra details that are useful for customising view - transitions. - - Following is an introduction to view transitions and the ways in which the ViewTransition - attached property can be used to augment view transitions. - - - \section2 View transitions: a simple example - - Here is a basic example of the use of view transitions. The view below specifies transitions for - the \c add and \c addDisplaced properties, which will be run when items are added to the view: - - \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml 0 - - When the space key is pressed, adding an item to the model, the new item will fade in and - increase in scale over 400 milliseconds as it is added to the view. Also, any item that is - displaced by the addition of a new item will animate to its new position in the view over - 400 milliseconds, as specified by the \c addDisplaced transition. - - If five items were inserted in succession at index 0, the effect would be this: - - \image viewtransitions-basic.gif - - Notice that the NumberAnimation objects above do not need to specify a \c target to animate - the appropriate item. Also, the NumberAnimation in the \c addTransition does not need to specify - the \c to value to move the item to its correct position in the view. This is because the view - implicitly sets the \c target and \c to values with the correct item and final item position - values if these properties are not explicitly defined. - - At its simplest, a view transition may just animate an item to its new position following a - view operation, just as the \c addDisplaced transition does above, or animate some item properties, - as in the \c add transition above. Additionally, a view transition may make use of the - ViewTransition attached property to customise animation behavior for different items. Following - are some examples of how this can be achieved. - - - \section2 Using the ViewTransition attached property - - As stated, the various ViewTransition properties provide details specific to the individual item - being transitioned as well as the operation that triggered the transition. In the animation above, - five items are inserted in succession at index 0. When the fifth and final insertion takes place, - adding "Item 4" to the view, the \c add transition is run once (for the inserted item) and the - \c addDisplaced transition is run four times (once for each of the four existing items in the view). - - At this point, if we examined the \c addDisplaced transition that was run for the bottom displaced - item ("Item 0"), the ViewTransition property values provided to this transition would be as follows: - - \table - \header - \o Property - \o Value - \o Explanation - \row - \o ViewTransition.item - \o "Item 0" delegate instance - \o The "Item 0" \l Rectangle object itself - \row - \o ViewTransition.index - \o \c int value of 4 - \o The index of "Item 0" within the model following the add operation - \row - \o ViewTransition.destination - \o \l point value of (0, 120) - \o The position that "Item 0" is moving to - \row - \o ViewTransition.targetIndexes - \o \c int array, just contains the integer "0" (zero) - \o The index of "Item 4", the new item added to the view - \row - \o ViewTransition.targetItems - \o object array, just contains the "Item 4" delegate instance - \o The "Item 4" \l Rectangle object - the new item added to the view - \endtable - - The ViewTransition.targetIndexes and ViewTransition.targetItems lists provide the items and - indexes of all delegate instances that are the targets of the relevant operation. For an add - operation, these are all the items that are added into the view; for a remove, these are all - the items removed from the view, and so on. (Note these lists will only contain references to - items that have been created within the view or its cached items; targets that are not within - the visible area of the view or within the item cache will not be accessible.) - - So, while the ViewTransition.item, ViewTransition.index and ViewTransition.destination values - vary for each individual transition that is run, the ViewTransition.targetIndexes and - ViewTransition.targetItems values are the same for every \c add and \c addDisplaced transition - that is triggered by a particular add operation. - - - \section3 Delaying animations based on index - - Since each view transition is run once for each item affected by the transition, the ViewTransition - properties can be used within a transition to define custom behavior for each item's transition. - For example, the ListView in the previous example could use this information to create a ripple-type - effect on the movement of the displaced items. - - This can be achieved by modifying the \c addDisplaced transition so that it delays the animation of - each displaced item based on the difference between its index (provided by ViewTransition.index) - and the first removed index (provided by ViewTransition.targetIndexes): - - \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml 0 - - Each displaced item delays its animation by an additional 100 milliseconds, producing a subtle - ripple-type effect when items are displaced by the add, like this: - - \image viewtransitions-delayedbyindex.gif - - - \section3 Animating items to intermediate positions - - The ViewTransition.item property gives a reference to the item to which the transition is being - applied. This can be used to access any of the item's attributes, custom \c property values, - and so on. - - Below is a modification of the \c addDisplaced transition from the previous example. It adds a - ParallelAnimation with nested NumberAnimation objects that reference ViewTransition.item to access - each item's \c x and \c y values at the start of their transitions. This allows each item to - animate to an intermediate position relative to its starting point for the transition, before - animating to its final position in the view: - - \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml 0 - - Now, a displaced item will first move to a position of (20, 50) relative to its starting - position, and then to its final, correct position in the view: - - \image viewtransitions-intermediatemove.gif - - Since the final NumberAnimation does not specify a \c to value, the view implicitly sets this - value to the item's final position in the view, and so this last animation will move this item - to the correct place. If the transition requires the final position of the item for some calculation, - this is accessible through ViewTransition.destination. - - Instead of using multiple NumberAnimations, you could use a PathAnimation to animate an item over - a curved path. For example, the \c add transition in the previous example could be augmented with - a PathAnimation as follows: to animate newly added items along a path: - - \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml 0 - - This animates newly added items along a path. Notice that each path is specified relative to - each item's final destination point, so that items inserted at different indexes start their - paths from different positions: - - \image viewtransitions-pathanim.gif - - - \section2 Handling interrupted animations - - A view transition may be interrupted at any time if a different view transition needs to be - applied while the original transition is in progress. For example, say Item A is inserted at index 0 - and undergoes an "add" transition; then, Item B is inserted at index 0 in quick succession before - Item A's transition has finished. Since Item B is inserted before Item A, it will displace Item - A, causing the view to interrupt Item A's "add" transition mid-way and start an "addDisplaced" - transition on Item A instead. - - For simple animations that simply animate an item's movement to its final destination, this - interruption is unlikely to require additional consideration. However, if a transition changes other - properties, this interruption may cause unwanted side effects. Consider the first example on this - page, repeated below for convenience: - - \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml 0 - - If multiple items are added in rapid succession, without waiting for a previous transition - to finish, this is the result: - - \image viewtransitions-interruptedbad.gif - - Each newly added item undergoes an \c add transition, but before the transition can finish, - another item is added, displacing the previously added item. Because of this, the \c add - transition on the previously added item is interrupted and an \c addDisplaced transition is - started on the item instead. Due to the interruption, the \c opacity and \c scale animations - have not completed, thus producing items with opacity and scale that are below 1.0. - - To fix this, the \c addDisplaced transition should additionally ensure the item properties are - set to the end values specified in the \c add transition, effectively resetting these values - whenever an item is displaced. In this case, it means setting the item opacity and scale to 1.0: - - \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml 0 - - Now, when an item's \c add transition is interrupted, its opacity and scale are animated to 1.0 - upon displacement, avoiding the erroneous visual effects from before: - - \image viewtransitions-interruptedgood.gif - - The same principle applies to any combination of view transitions. An added item may be moved - before its add transition finishes, or a moved item may be removed before its moved transition - finishes, and so on; so, the rule of thumb is that every transition should handle the same set of - properties. - - - \section2 Restrictions regarding ScriptAction - - When a view transition is initialized, any property bindings that refer to the ViewTransition - attached property are evaluated in preparation for the transition. Due to the nature of the - internal construction of a view transition, the attributes of the ViewTransition attached - property are only valid for the relevant item when the transition is initialized, and may not be - valid when the transition is actually run. - - Therefore, a ScriptAction within a view transition should not refer to the ViewTransition - attached property, as it may not refer to the expected values at the time that the ScriptAction - is actually invoked. Consider the following example: - - \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml 0 - - When the space key is pressed, three items are moved from index 5 to index 1. For each moved - item, the \c moveTransition sequence presumably animates the item's color to "yellow", then - animates it to its final position, then changes the item color back to "lightsteelblue" using a - ScriptAction. However, when run, the transition does not produce the intended result: - - \image viewtransitions-scriptactionbad.gif - - Only the last moved item is returned to the "lightsteelblue" color; the others remain yellow. This - is because the ScriptAction is not run until after the transition has already been initialized, by - which time the ViewTransition.item value has changed to refer to a different item; the item that - the script had intended to refer to is not the one held by ViewTransition.item at the time the - ScriptAction is actually invoked. - - In this instance, to avoid this issue, the view could set the property using a PropertyAction - instead: - - \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml 0 - - When the transition is initialized, the PropertyAction \c target will be set to the respective - ViewTransition.item for the transition and will later run with the correct item target as - expected. - */ - -/*! - \qmlattachedproperty list QtQuick2::ViewTransition::index - - This attached property holds the index of the item that is being - transitioned. - - Note that if the item is being moved, this property holds the index that - the item is moving to, not from. -*/ - -/*! - \qmlattachedproperty list QtQuick2::ViewTransition::item - - This attached property holds the the item that is being transitioned. - - \warning This item should not be kept and referred to outside of the transition - as it may become invalid as the view changes. -*/ - -/*! - \qmlattachedproperty list QtQuick2::ViewTransition::destination - - This attached property holds the final destination position for the transitioned - item within the view. - - This property value is a \l point with \c x and \c y properties. -*/ - -/*! - \qmlattachedproperty list QtQuick2::ViewTransition::targetIndexes - - This attached property holds a list of the indexes of the items in view - that are the target of the relevant operation. - - The targets are the items that are the subject of the operation. For - an add operation, these are the items being added; for a remove, these - are the items being removed; for a move, these are the items being - moved. - - For example, if the transition was triggered by an insert operation - that added two items at index 1 and 2, this targetIndexes list would - have the value [1,2]. - - \note The targetIndexes list only contains the indexes of items that are actually - in view, or will be in the view once the relevant operation completes. - - \sa QtQuick2::ViewTransition::targetIndexes -*/ - -/*! - \qmlattachedproperty list QtQuick2::ViewTransition::targetItems - - This attached property holds the list of items in view that are the - target of the relevant operation. - - The targets are the items that are the subject of the operation. For - an add operation, these are the items being added; for a remove, these - are the items being removed; for a move, these are the items being - moved. - - For example, if the transition was triggered by an insert operation - that added two items at index 1 and 2, this targetItems list would - contain these two items. - - \note The targetItems list only contains items that are actually - in view, or will be in the view once the relevant operation completes. - - \warning The objects in this list should not be kept and referred to - outside of the transition as the items may become invalid. The targetItems - are only valid when the Transition is initially created; this also means - they should not be used by ScriptAction objects in the Transition, which are - not evaluated until the transition is run. - - \sa QtQuick2::ViewTransition::targetIndexes -*/ -QDeclarativeListProperty QQuickViewTransitionAttached::targetItems() -{ - return QDeclarativeListProperty(this, m_targetItems); -} - -QQuickViewTransitionAttached *QQuickViewTransitionAttached::qmlAttachedProperties(QObject *obj) -{ - return new QQuickViewTransitionAttached(obj); -} - - //----------------------------------- QQuickItemView::QQuickItemView(QQuickFlickablePrivate &dd, QQuickItem *parent) @@ -868,9 +235,9 @@ void QQuickItemView::setModel(const QVariant &model) } d->updateViewport(); - if (d->populateTransition) { + if (d->transitioner && d->transitioner->populateTransition) { d->forceLayout = true; - d->usePopulateTransition = true; + d->transitioner->setPopulateTransitionEnabled(true); polish(); } } @@ -1229,14 +596,15 @@ void QQuickItemView::setHighlightMoveDuration(int duration) QDeclarativeTransition *QQuickItemView::populateTransition() const { Q_D(const QQuickItemView); - return d->populateTransition; + return d->transitioner ? d->transitioner->populateTransition : 0; } void QQuickItemView::setPopulateTransition(QDeclarativeTransition *transition) { Q_D(QQuickItemView); - if (d->populateTransition != transition) { - d->populateTransition = transition; + d->createTransitioner(); + if (d->transitioner->populateTransition != transition) { + d->transitioner->populateTransition = transition; emit populateTransitionChanged(); } } @@ -1244,14 +612,15 @@ void QQuickItemView::setPopulateTransition(QDeclarativeTransition *transition) QDeclarativeTransition *QQuickItemView::addTransition() const { Q_D(const QQuickItemView); - return d->addTransition; + return d->transitioner ? d->transitioner->addTransition : 0; } void QQuickItemView::setAddTransition(QDeclarativeTransition *transition) { Q_D(QQuickItemView); - if (d->addTransition != transition) { - d->addTransition = transition; + d->createTransitioner(); + if (d->transitioner->addTransition != transition) { + d->transitioner->addTransition = transition; emit addTransitionChanged(); } } @@ -1259,14 +628,15 @@ void QQuickItemView::setAddTransition(QDeclarativeTransition *transition) QDeclarativeTransition *QQuickItemView::addDisplacedTransition() const { Q_D(const QQuickItemView); - return d->addDisplacedTransition; + return d->transitioner ? d->transitioner->addDisplacedTransition : 0; } void QQuickItemView::setAddDisplacedTransition(QDeclarativeTransition *transition) { Q_D(QQuickItemView); - if (d->addDisplacedTransition != transition) { - d->addDisplacedTransition = transition; + d->createTransitioner(); + if (d->transitioner->addDisplacedTransition != transition) { + d->transitioner->addDisplacedTransition = transition; emit addDisplacedTransitionChanged(); } } @@ -1274,14 +644,15 @@ void QQuickItemView::setAddDisplacedTransition(QDeclarativeTransition *transitio QDeclarativeTransition *QQuickItemView::moveTransition() const { Q_D(const QQuickItemView); - return d->moveTransition; + return d->transitioner ? d->transitioner->moveTransition : 0; } void QQuickItemView::setMoveTransition(QDeclarativeTransition *transition) { Q_D(QQuickItemView); - if (d->moveTransition != transition) { - d->moveTransition = transition; + d->createTransitioner(); + if (d->transitioner->moveTransition != transition) { + d->transitioner->moveTransition = transition; emit moveTransitionChanged(); } } @@ -1289,14 +660,15 @@ void QQuickItemView::setMoveTransition(QDeclarativeTransition *transition) QDeclarativeTransition *QQuickItemView::moveDisplacedTransition() const { Q_D(const QQuickItemView); - return d->moveDisplacedTransition; + return d->transitioner ? d->transitioner->moveDisplacedTransition : 0; } void QQuickItemView::setMoveDisplacedTransition(QDeclarativeTransition *transition) { Q_D(QQuickItemView); - if (d->moveDisplacedTransition != transition) { - d->moveDisplacedTransition = transition; + d->createTransitioner(); + if (d->transitioner->moveDisplacedTransition != transition) { + d->transitioner->moveDisplacedTransition = transition; emit moveDisplacedTransitionChanged(); } } @@ -1304,14 +676,15 @@ void QQuickItemView::setMoveDisplacedTransition(QDeclarativeTransition *transiti QDeclarativeTransition *QQuickItemView::removeTransition() const { Q_D(const QQuickItemView); - return d->removeTransition; + return d->transitioner ? d->transitioner->removeTransition : 0; } void QQuickItemView::setRemoveTransition(QDeclarativeTransition *transition) { Q_D(QQuickItemView); - if (d->removeTransition != transition) { - d->removeTransition = transition; + d->createTransitioner(); + if (d->transitioner->removeTransition != transition) { + d->transitioner->removeTransition = transition; emit removeTransitionChanged(); } } @@ -1319,14 +692,15 @@ void QQuickItemView::setRemoveTransition(QDeclarativeTransition *transition) QDeclarativeTransition *QQuickItemView::removeDisplacedTransition() const { Q_D(const QQuickItemView); - return d->removeDisplacedTransition; + return d->transitioner ? d->transitioner->removeDisplacedTransition : 0; } void QQuickItemView::setRemoveDisplacedTransition(QDeclarativeTransition *transition) { Q_D(QQuickItemView); - if (d->removeDisplacedTransition != transition) { - d->removeDisplacedTransition = transition; + d->createTransitioner(); + if (d->transitioner->removeDisplacedTransition != transition) { + d->transitioner->removeDisplacedTransition = transition; emit removeDisplacedTransitionChanged(); } } @@ -1465,64 +839,6 @@ void QQuickItemViewPrivate::applyPendingChanges() layout(); } -bool QQuickItemViewPrivate::canTransition(FxViewItemTransitionManager::TransitionType type, bool asTarget) const -{ - switch (type) { - case FxViewItemTransitionManager::NoTransition: - break; - case FxViewItemTransitionManager::PopulateTransition: - return usePopulateTransition - && populateTransition && populateTransition->enabled(); - case FxViewItemTransitionManager::AddTransition: - if (asTarget) - return addTransition && addTransition->enabled(); - else - return addDisplacedTransition && addDisplacedTransition->enabled(); - case FxViewItemTransitionManager::MoveTransition: - if (asTarget) - return moveTransition && moveTransition->enabled(); - else - return moveDisplacedTransition && moveDisplacedTransition->enabled(); - case FxViewItemTransitionManager::RemoveTransition: - if (asTarget) - return removeTransition && removeTransition->enabled(); - else - return removeDisplacedTransition && removeDisplacedTransition->enabled(); - } - return false; -} - -bool QQuickItemViewPrivate::hasItemTransitions() const -{ - return canTransition(FxViewItemTransitionManager::PopulateTransition, true) - || canTransition(FxViewItemTransitionManager::AddTransition, true) - || canTransition(FxViewItemTransitionManager::AddTransition, false) - || canTransition(FxViewItemTransitionManager::MoveTransition, true) - || canTransition(FxViewItemTransitionManager::MoveTransition, false) - || canTransition(FxViewItemTransitionManager::RemoveTransition, true) - || canTransition(FxViewItemTransitionManager::RemoveTransition, false); -} - -void QQuickItemViewPrivate::transitionNextReposition(FxViewItem *item, FxViewItemTransitionManager::TransitionType type, bool isTarget) -{ - bool matchedTransition = false; - if (type == FxViewItemTransitionManager::AddTransition) { - // don't run add transitions for added items while populating - matchedTransition = !usePopulateTransition && canTransition(type, isTarget); - } else { - matchedTransition = canTransition(type, isTarget); - } - - if (matchedTransition) { - item->setNextTransition(type, isTarget); - } else { - // the requested transition type is not valid, but the item is scheduled/in another - // transition, so cancel it to allow the item to move directly to the correct pos - if (item->transitionScheduledOrRunning()) - item->stopTransition(); - } -} - int QQuickItemViewPrivate::findMoveKeyIndex(QDeclarativeChangeSet::MoveKey key, const QVector &changes) const { for (int i=0; itransition && actualItem->transition->isRunning()) + FxViewItem *actualItem = transitioner ? visibleItem(currentIndex) : 0; + if (actualItem && actualItem->transitionRunning()) disableLayout = true; } updateHighlight(); @@ -1602,7 +918,7 @@ void QQuickItemView::destroyRemoved() it != d->visibleItems.end();) { FxViewItem *item = *it; if (item->index == -1 && item->attached->delayRemove() == false) { - if (d->canTransition(FxViewItemTransitionManager::RemoveTransition, true)) { + if (d->transitioner && d->transitioner->canTransition(QQuickItemViewTransitioner::RemoveTransition, true)) { // don't remove from visibleItems until next layout() d->runDelayedRemoveTransition = true; QObject::disconnect(item->attached, SIGNAL(delayRemoveChanged()), this, SLOT(destroyRemoved())); @@ -1626,7 +942,8 @@ void QQuickItemView::modelUpdated(const QDeclarativeChangeSet &changeSet, bool r { Q_D(QQuickItemView); if (reset) { - d->usePopulateTransition = true; + if (d->transitioner) + d->transitioner->setPopulateTransitionEnabled(true); d->moveReason = QQuickItemViewPrivate::SetIndex; d->regenerate(); if (d->highlight && d->currentItem) { @@ -1636,7 +953,7 @@ void QQuickItemView::modelUpdated(const QDeclarativeChangeSet &changeSet, bool r } d->moveReason = QQuickItemViewPrivate::Other; emit countChanged(); - if (d->populateTransition) { + if (d->transitioner && d->transitioner->populateTransition) { d->forceLayout = true; polish(); } @@ -1936,7 +1253,8 @@ void QQuickItemView::componentComplete() d->updateFooter(); d->updateViewport(); d->setPosition(d->contentStartOffset()); - d->usePopulateTransition = true; + if (d->transitioner) + d->transitioner->setPopulateTransitionEnabled(true); if (d->isValid()) { d->refill(); @@ -1972,19 +1290,21 @@ QQuickItemViewPrivate::QQuickItemViewPrivate() , highlightRangeStart(0), highlightRangeEnd(0) , highlightMoveDuration(150) , headerComponent(0), header(0), footerComponent(0), footer(0) - , populateTransition(0) - , addTransition(0), addDisplacedTransition(0) - , moveTransition(0), moveDisplacedTransition(0) - , removeTransition(0), removeDisplacedTransition(0) + , transitioner(0) , minExtent(0), maxExtent(0) , ownModel(false), wrap(false) , disableLayout(false), inViewportMoved(false), forceLayout(false), currentIndexCleared(false) , haveHighlightRange(false), autoHighlight(true), highlightRangeStartValid(false), highlightRangeEndValid(false) , fillCacheBuffer(false), inRequest(false), requestedAsync(false) - , usePopulateTransition(false), runDelayedRemoveTransition(false) + , runDelayedRemoveTransition(false) { } +QQuickItemViewPrivate::~QQuickItemViewPrivate() +{ + delete transitioner; +} + bool QQuickItemViewPrivate::isValid() const { return model && model->count() && model->isValid(); @@ -2267,15 +1587,17 @@ void QQuickItemViewPrivate::layout() if (!isValid() && !visibleItems.count()) { clear(); setPosition(contentStartOffset()); - usePopulateTransition = false; + if (transitioner) + transitioner->setPopulateTransitionEnabled(false); return; } - if (runDelayedRemoveTransition && canTransition(FxViewItemTransitionManager::RemoveTransition, false)) { + if (runDelayedRemoveTransition && transitioner + && transitioner->canTransition(QQuickItemViewTransitioner::RemoveTransition, false)) { // assume that any items moving now are moving due to the remove - if they schedule // a different transition, that will override this one anyway for (int i=0; itransitionNextReposition(visibleItems[i], QQuickItemViewTransitioner::RemoveTransition, false); } ChangeResult insertionPosChanges; @@ -2289,9 +1611,9 @@ void QQuickItemViewPrivate::layout() } forceLayout = false; - if (canTransition(FxViewItemTransitionManager::PopulateTransition, true)) { + if (transitioner && transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) { for (int i=0; itransitionNextReposition(visibleItems.at(i), QQuickItemViewTransitioner::PopulateTransition, true); } layoutVisibleItems(); @@ -2310,11 +1632,11 @@ void QQuickItemViewPrivate::layout() updateViewport(); updateUnrequestedPositions(); - if (hasItemTransitions()) { + if (transitioner) { // items added in the last refill() may need to be transitioned in - e.g. a remove // causes items to slide up into view - if (canTransition(FxViewItemTransitionManager::MoveTransition, false) - || canTransition(FxViewItemTransitionManager::RemoveTransition, false)) { + if (transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, false) + || transitioner->canTransition(QQuickItemViewTransitioner::RemoveTransition, false)) { translateAndTransitionItemsAfter(lastIndexInView, insertionPosChanges, removalPosChanges); } @@ -2324,8 +1646,7 @@ void QQuickItemViewPrivate::layout() for (QList::Iterator it = releasePendingTransition.begin(); it != releasePendingTransition.end(); ) { FxViewItem *item = *it; - if ( (item->transition && item->transition->isActive()) - || prepareNonVisibleItemTransition(item, viewBounds)) { + if (item->transitionRunning() || prepareNonVisibleItemTransition(item, viewBounds)) { ++it; } else { releaseItem(item); @@ -2334,11 +1655,12 @@ void QQuickItemViewPrivate::layout() } for (int i=0; istartTransition(); + visibleItems[i]->startTransition(transitioner); for (int i=0; istartTransition(); + releasePendingTransition[i]->startTransition(transitioner); + transitioner->setPopulateTransitionEnabled(false); } - usePopulateTransition = false; + runDelayedRemoveTransition = false; } @@ -2441,7 +1763,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult // for each item that was moved directly into the view as a result of a move(), // find the index it was moved from in order to set its initial position, so that we // can transition it from this "original" position to its new position in the view - if (canTransition(FxViewItemTransitionManager::MoveTransition, true)) { + if (transitioner && transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, true)) { for (int i=0; i= 0) { @@ -2449,7 +1771,7 @@ bool QQuickItemViewPrivate::applyModelChanges(ChangeResult *totalInsertionResult repositionItemAt(movingIntoView[i].item, fromIndex, -totalInsertionResult->sizeChangesAfterVisiblePos); else repositionItemAt(movingIntoView[i].item, fromIndex, totalInsertionResult->sizeChangesAfterVisiblePos); - transitionNextReposition(movingIntoView[i].item, FxViewItemTransitionManager::MoveTransition, true); + transitioner->transitionNextReposition(movingIntoView[i].item, QQuickItemViewTransitioner::MoveTransition, true); } } } @@ -2513,10 +1835,12 @@ bool QQuickItemViewPrivate::applyRemovalChange(const QDeclarativeChangeSet::Remo } else if (item->index >= removal.index + removal.count) { // after removed items item->index -= removal.count; - if (removal.isMove()) - transitionNextReposition(item, FxViewItemTransitionManager::MoveTransition, false); - else - transitionNextReposition(item, FxViewItemTransitionManager::RemoveTransition, false); + if (transitioner) { + if (removal.isMove()) + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::MoveTransition, false); + else + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::RemoveTransition, false); + } ++it; } else { // removed item @@ -2550,7 +1874,8 @@ void QQuickItemViewPrivate::removeItem(FxViewItem *item, const QDeclarativeChang } if (removal.isMove()) { currentChanges.removedItems.insert(removal.moveKey(item->index), item); - transitionNextReposition(item, FxViewItemTransitionManager::MoveTransition, true); + if (transitioner) + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::MoveTransition, true); } else { // track item so it is released later currentChanges.removedItems.insertMulti(QDeclarativeChangeSet::MoveKey(), item); @@ -2598,16 +1923,24 @@ void QQuickItemViewPrivate::repositionFirstItem(FxViewItem *prevVisibleItemsFirs } } +void QQuickItemViewPrivate::createTransitioner() +{ + if (!transitioner) { + transitioner = new QQuickItemViewTransitioner; + transitioner->setChangeListener(this); + } +} + void QQuickItemViewPrivate::prepareVisibleItemTransitions() { Q_Q(QQuickItemView); - if (!hasItemTransitions()) + if (!transitioner) return; - addTransitionIndexes.clear(); - addTransitionTargets.clear(); - moveTransitionIndexes.clear(); - moveTransitionTargets.clear(); + transitioner->addTransitionIndexes.clear(); + transitioner->addTransitionTargets.clear(); + transitioner->moveTransitionIndexes.clear(); + transitioner->moveTransitionTargets.clear(); QRectF viewBounds(0, position(), q->width(), q->height()); for (int i=0; iisTransitionTarget) { switch (visibleItems[i]->nextTransitionType) { - case FxViewItemTransitionManager::NoTransition: + case QQuickItemViewTransitioner::NoTransition: break; - case FxViewItemTransitionManager::PopulateTransition: - case FxViewItemTransitionManager::AddTransition: - addTransitionIndexes.append(visibleItems[i]->index); - addTransitionTargets.append(visibleItems[i]->item); + case QQuickItemViewTransitioner::PopulateTransition: + case QQuickItemViewTransitioner::AddTransition: + transitioner->addTransitionIndexes.append(visibleItems[i]->index); + transitioner->addTransitionTargets.append(visibleItems[i]->item); break; - case FxViewItemTransitionManager::MoveTransition: - moveTransitionIndexes.append(visibleItems[i]->index); - moveTransitionTargets.append(visibleItems[i]->item); + case QQuickItemViewTransitioner::MoveTransition: + transitioner->moveTransitionIndexes.append(visibleItems[i]->index); + transitioner->moveTransitionTargets.append(visibleItems[i]->item); break; - case FxViewItemTransitionManager::RemoveTransition: + case QQuickItemViewTransitioner::RemoveTransition: // removed targets won't be in visibleItems, handle these // in prepareNonVisibleItemTransition() break; @@ -2638,10 +1971,13 @@ void QQuickItemViewPrivate::prepareVisibleItemTransitions() void QQuickItemViewPrivate::prepareRemoveTransitions(QHash *removedItems) { - removeTransitionIndexes.clear(); - removeTransitionTargets.clear(); + if (!transitioner) + return; - if (canTransition(FxViewItemTransitionManager::RemoveTransition, true)) { + transitioner->removeTransitionIndexes.clear(); + transitioner->removeTransitionTargets.clear(); + + if (transitioner->canTransition(QQuickItemViewTransitioner::RemoveTransition, true)) { for (QHash::Iterator it = removedItems->begin(); it != removedItems->end(); ) { bool isRemove = it.key().moveId < 0; @@ -2649,7 +1985,7 @@ void QQuickItemViewPrivate::prepareRemoveTransitions(QHashreleaseAfterTransition = true; releasePendingTransition.append(item); - transitionNextReposition(item, FxViewItemTransitionManager::RemoveTransition, true); + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::RemoveTransition, true); it = removedItems->erase(it); } else { ++it; @@ -2665,18 +2001,21 @@ bool QQuickItemViewPrivate::prepareNonVisibleItemTransition(FxViewItem *item, co // removed, or moved to outside of the view, as well as those that are // displaced to a position outside of the view due to an insert or move. - if (item->nextTransitionType == FxViewItemTransitionManager::MoveTransition) + if (!transitioner) + return false; + + if (item->nextTransitionType == QQuickItemViewTransitioner::MoveTransition) repositionItemAt(item, item->index, 0); if (!item->prepareTransition(viewBounds)) return false; if (item->isTransitionTarget) { - if (item->nextTransitionType == FxViewItemTransitionManager::MoveTransition) { - moveTransitionIndexes.append(item->index); - moveTransitionTargets.append(item->item); - } else if (item->nextTransitionType == FxViewItemTransitionManager::RemoveTransition) { - removeTransitionIndexes.append(item->index); - removeTransitionTargets.append(item->item); + if (item->nextTransitionType == QQuickItemViewTransitioner::MoveTransition) { + transitioner->moveTransitionIndexes.append(item->index); + transitioner->moveTransitionTargets.append(item->item); + } else if (item->nextTransitionType == QQuickItemViewTransitioner::RemoveTransition) { + transitioner->removeTransitionIndexes.append(item->index); + transitioner->removeTransitionTargets.append(item->item); } } @@ -2684,6 +2023,15 @@ bool QQuickItemViewPrivate::prepareNonVisibleItemTransition(FxViewItem *item, co return true; } +void QQuickItemViewPrivate::viewItemTransitionFinished(QQuickViewItem *i) +{ + FxViewItem *item = static_cast(i); + if (item->releaseAfterTransition) { + releasePendingTransition.removeOne(item); + releaseItem(item); + } +} + /* This may return 0 if the item is being created asynchronously. When the item becomes available, refill() will be called and the item diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h index 0d3cd1c3ce..63262f32ab 100644 --- a/src/quick/items/qquickitemview_p.h +++ b/src/quick/items/qquickitemview_p.h @@ -324,53 +324,9 @@ public: QString m_nextSection; }; -class QQuickViewTransitionAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int index READ index NOTIFY indexChanged) - Q_PROPERTY(QQuickItem* item READ item NOTIFY itemChanged) - Q_PROPERTY(QPointF destination READ destination NOTIFY destinationChanged) - - Q_PROPERTY(QList targetIndexes READ targetIndexes NOTIFY targetIndexesChanged) - Q_PROPERTY(QDeclarativeListProperty targetItems READ targetItems NOTIFY targetItemsChanged) - -public: - QQuickViewTransitionAttached(QObject *parent); - - int index() const { return m_index; } - QQuickItem *item() const { return m_item; } - QPointF destination() const { return m_destination; } - - QList targetIndexes() const { return m_targetIndexes; } - QDeclarativeListProperty targetItems(); - - static QQuickViewTransitionAttached *qmlAttachedProperties(QObject *); - -signals: - void indexChanged(); - void itemChanged(); - void destinationChanged(); - - void targetIndexesChanged(); - void targetItemsChanged(); - -private: - friend class FxViewItemTransitionManager; - int m_index; - QQuickItem *m_item; - QPointF m_destination; - - QList m_targetIndexes; - QList m_targetItems; -}; - QT_END_NAMESPACE -QML_DECLARE_TYPE(QQuickViewTransitionAttached) -QML_DECLARE_TYPEINFO(QQuickViewTransitionAttached, QML_HAS_ATTACHED_PROPERTIES) - QT_END_HEADER #endif // QQUICKITEMVIEW_P_H diff --git a/src/quick/items/qquickitemview_p_p.h b/src/quick/items/qquickitemview_p_p.h index fce6e4eba5..57860a43c6 100644 --- a/src/quick/items/qquickitemview_p_p.h +++ b/src/quick/items/qquickitemview_p_p.h @@ -43,10 +43,10 @@ #define QQUICKITEMVIEW_P_P_H #include "qquickitemview_p.h" +#include "qquickitemviewtransition_p.h" #include "qquickflickable_p_p.h" #include "qquickvisualdatamodel_p.h" #include "qquickvisualitemmodel_p.h" -#include #include @@ -57,55 +57,12 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class FxViewItem; -class FxViewItemTransitionManager : public QDeclarativeTransitionManager -{ -public: - enum TransitionType { - NoTransition, - PopulateTransition, - AddTransition, - MoveTransition, - RemoveTransition - }; - - FxViewItemTransitionManager(); - ~FxViewItemTransitionManager(); - - bool isActive() const; - void startTransition(FxViewItem *item, FxViewItemTransitionManager::TransitionType type, const QPointF &to, bool isTargetItem); - - bool m_active; - FxViewItem *m_item; - QPointF m_toPos; - FxViewItemTransitionManager::TransitionType m_type; - bool m_isTarget; - -protected: - virtual void finished(); -}; - - -class FxViewItem +class FxViewItem : public QQuickViewItem { public: FxViewItem(QQuickItem *, bool own); virtual ~FxViewItem(); - qreal itemX() const; - qreal itemY() const; - - void setVisible(bool visible); - - void setNextTransition(FxViewItemTransitionManager::TransitionType, bool isTargetItem); - bool transitionScheduledOrRunning() const; - bool isPendingRemoval() const; - - bool prepareTransition(const QRectF &viewBounds); - void startTransition(); - void stopTransition(); - void finishedTransition(); - // these are positions and sizes along the current direction of scrolling/flicking virtual qreal position() const = 0; virtual qreal endPosition() const = 0; @@ -113,23 +70,10 @@ public: virtual qreal sectionSize() const = 0; virtual bool contains(qreal x, qreal y) const = 0; - virtual QQuickItemView *itemView() const = 0; - QQuickItem *item; + QQuickItemViewAttached *attached; bool ownItem; bool releaseAfterTransition; - bool isTransitionTarget; - bool nextTransitionToSet; - int index; - QQuickItemViewAttached *attached; - - FxViewItemTransitionManager *transition; - QPointF nextTransitionTo; - FxViewItemTransitionManager::TransitionType nextTransitionType; - -protected: - void moveTo(const QPointF &pos); - void resetTransitionData(); }; @@ -155,11 +99,12 @@ public: }; -class QQuickItemViewPrivate : public QQuickFlickablePrivate +class QQuickItemViewPrivate : public QQuickFlickablePrivate, public QQuickItemViewTransitionChangeListener { Q_DECLARE_PUBLIC(QQuickItemView) public: QQuickItemViewPrivate(); + ~QQuickItemViewPrivate(); struct ChangeResult { QDeclarativeNullableValue visiblePos; @@ -243,13 +188,12 @@ public: void repositionFirstItem(FxViewItem *prevVisibleItemsFirst, qreal prevVisibleItemsFirstPos, FxViewItem *prevFirstVisible, ChangeResult *insertionResult, ChangeResult *removalResult); + void createTransitioner(); void prepareVisibleItemTransitions(); void prepareRemoveTransitions(QHash *removedItems); bool prepareNonVisibleItemTransition(FxViewItem *item, const QRectF &viewBounds); + virtual void viewItemTransitionFinished(QQuickViewItem *item); - bool canTransition(FxViewItemTransitionManager::TransitionType type, bool asTarget) const; - bool hasItemTransitions() const; - void transitionNextReposition(FxViewItem *item, FxViewItemTransitionManager::TransitionType type, bool isTarget); int findMoveKeyIndex(QDeclarativeChangeSet::MoveKey key, const QVector &changes) const; void checkVisible() const; @@ -281,7 +225,6 @@ public: FxViewItem *requestedItem; QQuickItemViewChangeSet currentChanges; - // XXX split into struct QDeclarativeComponent *highlightComponent; FxViewItem *highlight; int highlightRange; // enum value @@ -294,27 +237,13 @@ public: QDeclarativeComponent *footerComponent; FxViewItem *footer; - QDeclarativeTransition *populateTransition; - QDeclarativeTransition *addTransition; - QDeclarativeTransition *addDisplacedTransition; - QDeclarativeTransition *moveTransition; - QDeclarativeTransition *moveDisplacedTransition; - QDeclarativeTransition *removeTransition; - QDeclarativeTransition *removeDisplacedTransition; - - QList addTransitionIndexes; - QList moveTransitionIndexes; - QList removeTransitionIndexes; - QList addTransitionTargets; - QList moveTransitionTargets; - QList removeTransitionTargets; - struct MovedItem { FxViewItem *item; QDeclarativeChangeSet::MoveKey moveKey; MovedItem(FxViewItem *i, QDeclarativeChangeSet::MoveKey k) : item(i), moveKey(k) {} }; + QQuickItemViewTransitioner *transitioner; QList releasePendingTransition; mutable qreal minExtent; @@ -333,7 +262,6 @@ public: bool fillCacheBuffer : 1; bool inRequest : 1; bool requestedAsync : 1; - bool usePopulateTransition : 1; bool runDelayedRemoveTransition : 1; protected: diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp new file mode 100644 index 0000000000..3e3a99f553 --- /dev/null +++ b/src/quick/items/qquickitemviewtransition.cpp @@ -0,0 +1,770 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qquickitemviewtransition_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + + +class QQuickItemViewTransitionJob : public QDeclarativeTransitionManager +{ +public: + QQuickItemViewTransitionJob(QQuickItemViewTransitioner *transitioner); + ~QQuickItemViewTransitionJob(); + + void startTransition(QQuickViewItem *item, QQuickItemViewTransitioner::TransitionType type, const QPointF &to, bool isTargetItem); + + QQuickItemViewTransitioner *m_transitioner; + QQuickViewItem *m_item; + QPointF m_toPos; + QQuickItemViewTransitioner::TransitionType m_type; + bool m_isTarget; + +protected: + virtual void finished(); +}; + + +QQuickItemViewTransitionJob::QQuickItemViewTransitionJob(QQuickItemViewTransitioner *transitioner) + : m_transitioner(transitioner) + , m_item(0), m_type(QQuickItemViewTransitioner::NoTransition), m_isTarget(false) +{ +} + +QQuickItemViewTransitionJob::~QQuickItemViewTransitionJob() +{ +} + +void QQuickItemViewTransitionJob::startTransition(QQuickViewItem *item, QQuickItemViewTransitioner::TransitionType type, const QPointF &to, bool isTargetItem) +{ + if (!item) { + qWarning("startTransition(): invalid item"); + return; + } + + QDeclarativeTransition *trans = 0; + switch (type) { + case QQuickItemViewTransitioner::NoTransition: + break; + case QQuickItemViewTransitioner::PopulateTransition: + trans = m_transitioner->populateTransition; + break; + case QQuickItemViewTransitioner::AddTransition: + trans = isTargetItem ? m_transitioner->addTransition : m_transitioner->addDisplacedTransition; + break; + case QQuickItemViewTransitioner::MoveTransition: + trans = isTargetItem ? m_transitioner->moveTransition : m_transitioner->moveDisplacedTransition; + break; + case QQuickItemViewTransitioner::RemoveTransition: + trans = isTargetItem ? m_transitioner->removeTransition : m_transitioner->removeDisplacedTransition; + break; + } + + if (!trans) { + qWarning("QQuickItemView: invalid view transition!"); + return; + } + + m_item = item; + m_toPos = to; + m_type = type; + m_isTarget = isTargetItem; + + QQuickViewTransitionAttached *attached = + static_cast(qmlAttachedPropertiesObject(trans)); + if (attached) { + attached->m_index = item->index; + attached->m_item = item->item; + attached->m_destination = to; + switch (type) { + case QQuickItemViewTransitioner::NoTransition: + break; + case QQuickItemViewTransitioner::PopulateTransition: + case QQuickItemViewTransitioner::AddTransition: + attached->m_targetIndexes = m_transitioner->addTransitionIndexes; + attached->m_targetItems = m_transitioner->addTransitionTargets; + break; + case QQuickItemViewTransitioner::MoveTransition: + attached->m_targetIndexes = m_transitioner->moveTransitionIndexes; + attached->m_targetItems = m_transitioner->moveTransitionTargets; + break; + case QQuickItemViewTransitioner::RemoveTransition: + attached->m_targetIndexes = m_transitioner->removeTransitionIndexes; + attached->m_targetItems = m_transitioner->removeTransitionTargets; + break; + } + emit attached->indexChanged(); + emit attached->itemChanged(); + emit attached->destinationChanged(); + emit attached->targetIndexesChanged(); + emit attached->targetItemsChanged(); + } + + QDeclarativeStateOperation::ActionList actions; + actions << QDeclarativeAction(item->item, QLatin1String("x"), QVariant(to.x())); + actions << QDeclarativeAction(item->item, QLatin1String("y"), QVariant(to.y())); + + QDeclarativeTransitionManager::transition(actions, trans, item->item); +} + +void QQuickItemViewTransitionJob::finished() +{ + QDeclarativeTransitionManager::finished(); + + if (m_item) + m_item->finishedTransition(); + if (m_transitioner) + m_transitioner->finishedTransition(m_item); + + m_item = 0; + m_toPos.setX(0); + m_toPos.setY(0); + m_type = QQuickItemViewTransitioner::NoTransition; + m_isTarget = false; +} + + +QQuickItemViewTransitioner::QQuickItemViewTransitioner() + : populateTransition(0) + , addTransition(0), addDisplacedTransition(0) + , moveTransition(0), moveDisplacedTransition(0) + , removeTransition(0), removeDisplacedTransition(0) + , changeListener(0) + , usePopulateTransition(false) +{ +} + +bool QQuickItemViewTransitioner::canTransition(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const +{ + switch (type) { + case QQuickItemViewTransitioner::NoTransition: + break; + case QQuickItemViewTransitioner::PopulateTransition: + return usePopulateTransition + && populateTransition && populateTransition->enabled(); + case QQuickItemViewTransitioner::AddTransition: + if (asTarget) + return addTransition && addTransition->enabled(); + else + return addDisplacedTransition && addDisplacedTransition->enabled(); + case QQuickItemViewTransitioner::MoveTransition: + if (asTarget) + return moveTransition && moveTransition->enabled(); + else + return moveDisplacedTransition && moveDisplacedTransition->enabled(); + case QQuickItemViewTransitioner::RemoveTransition: + if (asTarget) + return removeTransition && removeTransition->enabled(); + else + return removeDisplacedTransition && removeDisplacedTransition->enabled(); + } + return false; +} + +void QQuickItemViewTransitioner::transitionNextReposition(QQuickViewItem *item, QQuickItemViewTransitioner::TransitionType type, bool isTarget) +{ + bool matchedTransition = false; + if (type == QQuickItemViewTransitioner::AddTransition) { + // don't run add transitions for added items while populating + if (usePopulateTransition) + matchedTransition = false; + else + matchedTransition = canTransition(type, isTarget); + } else { + matchedTransition = canTransition(type, isTarget); + } + + if (matchedTransition) { + item->setNextTransition(type, isTarget); + } else { + // the requested transition type is not valid, but the item is scheduled/in another + // transition, so cancel it to allow the item to move directly to the correct pos + if (item->transitionScheduledOrRunning()) + item->stopTransition(); + } +} + +void QQuickItemViewTransitioner::finishedTransition(QQuickViewItem *item) +{ + if (changeListener) + changeListener->viewItemTransitionFinished(item); +} + + +QQuickViewItem::QQuickViewItem(QQuickItem *i) + : item(i) + , transition(0) + , nextTransitionType(QQuickItemViewTransitioner::NoTransition) + , index(-1) + , isTransitionTarget(false) + , nextTransitionToSet(false) +{ +} + +QQuickViewItem::~QQuickViewItem() +{ + if (transition) { + transition->m_item = 0; + transition->m_transitioner = 0; + } + delete transition; +} + +qreal QQuickViewItem::itemX() const +{ + if (nextTransitionType != QQuickItemViewTransitioner::NoTransition) + return nextTransitionToSet ? nextTransitionTo.x() : item->x(); + else if (transition && transition->isRunning()) + return transition->m_toPos.x(); + else + return item->x(); +} + +qreal QQuickViewItem::itemY() const +{ + // If item is transitioning to some pos, return that dest pos. + // If item was redirected to some new pos before the current transition finished, + // return that new pos. + if (nextTransitionType != QQuickItemViewTransitioner::NoTransition) + return nextTransitionToSet ? nextTransitionTo.y() : item->y(); + else if (transition && transition->isRunning()) + return transition->m_toPos.y(); + else + return item->y(); +} + +void QQuickViewItem::moveTo(const QPointF &pos) +{ + if (transitionScheduledOrRunning()) { + nextTransitionTo = pos; + nextTransitionToSet = true; + } else { + item->setPos(pos); + } +} + +void QQuickViewItem::setVisible(bool visible) +{ + if (!visible && transitionScheduledOrRunning()) + return; + item->setVisible(visible); +} + +bool QQuickViewItem::transitionScheduledOrRunning() const +{ + return (transition && transition->isRunning()) + || nextTransitionType != QQuickItemViewTransitioner::NoTransition; +} + +bool QQuickViewItem::transitionRunning() const +{ + return (transition && transition->isRunning()); +} + +bool QQuickViewItem::isPendingRemoval() const +{ + if (nextTransitionType == QQuickItemViewTransitioner::RemoveTransition) + return isTransitionTarget; + if (transition && transition->isRunning() && transition->m_type == QQuickItemViewTransitioner::RemoveTransition) + return transition->m_isTarget; + return false; +} + +bool QQuickViewItem::prepareTransition(const QRectF &viewBounds) +{ + bool doTransition = false; + + switch (nextTransitionType) { + case QQuickItemViewTransitioner::NoTransition: + { + return false; + } + case QQuickItemViewTransitioner::PopulateTransition: + { + return true; + } + case QQuickItemViewTransitioner::AddTransition: + case QQuickItemViewTransitioner::RemoveTransition: + // For Add targets, do transition if item is moving into visible area + // For Remove targets, do transition if item is currently in visible area + if (isTransitionTarget) { + doTransition = (nextTransitionType == QQuickItemViewTransitioner::AddTransition) + ? viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height())) + : viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())); + if (!doTransition) + item->setPos(nextTransitionTo); + } else { + if (viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())) + || viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height()))) { + doTransition = (nextTransitionTo != item->pos()); + } else { + item->setPos(nextTransitionTo); + } + } + break; + case QQuickItemViewTransitioner::MoveTransition: + // do transition if moving from or into visible area + if (nextTransitionTo != item->pos()) { + doTransition = viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())) + || viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height())); + if (!doTransition) + item->setPos(nextTransitionTo); + } + break; + } + + if (!doTransition) + resetTransitionData(); + return doTransition; +} + +void QQuickViewItem::startTransition(QQuickItemViewTransitioner *transitioner) +{ + if (nextTransitionType == QQuickItemViewTransitioner::NoTransition) + return; + + if (!transition || transition->m_type != nextTransitionType || transition->m_isTarget != isTransitionTarget) { + delete transition; + transition = new QQuickItemViewTransitionJob(transitioner); + } + + // if item is not already moving somewhere, set it to not move anywhere + // so that removed items do not move to the default (0,0) + if (!nextTransitionToSet) + moveTo(item->pos()); + + transition->startTransition(this, nextTransitionType, nextTransitionTo, isTransitionTarget); + nextTransitionType = QQuickItemViewTransitioner::NoTransition; +} + +void QQuickViewItem::stopTransition() +{ + if (transition) { + transition->cancel(); + delete transition; + transition = 0; + } + resetTransitionData(); + finishedTransition(); +} + +void QQuickViewItem::setNextTransition(QQuickItemViewTransitioner::TransitionType type, bool isTargetItem) +{ + // Don't reset nextTransitionToSet - once it is set, it cannot be changed + // until the animation finishes since the itemX() and itemY() may be used + // to calculate positions for transitions for other items in the view. + nextTransitionType = type; + isTransitionTarget = isTargetItem; +} + +void QQuickViewItem::finishedTransition() +{ + nextTransitionToSet = false; + nextTransitionTo = QPointF(); +} + +void QQuickViewItem::resetTransitionData() +{ + nextTransitionType = QQuickItemViewTransitioner::NoTransition; + isTransitionTarget = false; + nextTransitionTo = QPointF(); + nextTransitionToSet = false; +} + + +QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) + : QObject(parent), m_item(0), m_index(-1) +{ +} +/*! + \qmlclass ViewTransition QQuickViewTransitionAttached + \inqmlmodule QtQuick 2 + \ingroup qml-view-elements + \brief The ViewTransition attached property provides details on items under transition in a view. + + With ListView and GridView, it is possible to specify transitions that should be applied whenever + the items in the view change as a result of modifications to the view's model. They both have the + following properties that can be set to the appropriate transitions to be run for various + operations: + + \list + \o \c add and \c addDisplaced - the transitions to run when items are added to the view + \o \c remove and \c removeDisplaced - the transitions to run when items are removed from the view + \o \c move and \c moveDisplaced - the transitions to run when items are moved within the view + (i.e. as a result of a move operation in the model) + \o \c populate - the transition to run when a view is created, or when the model changes + \endlist + + Such view transitions additionally have access to a ViewTransition attached property that + provides details of the items that are under transition and the operation that triggered the + transition. Since view transitions are run once per item, these details can be used to customise + each transition for each individual item. + + The ViewTransition attached property provides the following properties specific to the item to + which the transition is applied: + + \list + \o ViewTransition.item - the item that is under transition + \o ViewTransition.index - the index of this item + \o ViewTransition.destination - the (x,y) point to which this item is moving for the relevant view operation + \endlist + + In addition, ViewTransition provides properties specific to the items which are the target + of the operation that triggered the transition: + + \list + \o ViewTransition.targetIndexes - the indexes of the target items + \o ViewTransition.targetItems - the target items themselves + \endlist + + View transitions can be written without referring to any of the attributes listed + above. These attributes merely provide extra details that are useful for customising view + transitions. + + Following is an introduction to view transitions and the ways in which the ViewTransition + attached property can be used to augment view transitions. + + + \section2 View transitions: a simple example + + Here is a basic example of the use of view transitions. The view below specifies transitions for + the \c add and \c addDisplaced properties, which will be run when items are added to the view: + + \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml 0 + + When the space key is pressed, adding an item to the model, the new item will fade in and + increase in scale over 400 milliseconds as it is added to the view. Also, any item that is + displaced by the addition of a new item will animate to its new position in the view over + 400 milliseconds, as specified by the \c addDisplaced transition. + + If five items were inserted in succession at index 0, the effect would be this: + + \image viewtransitions-basic.gif + + Notice that the NumberAnimation objects above do not need to specify a \c target to animate + the appropriate item. Also, the NumberAnimation in the \c addTransition does not need to specify + the \c to value to move the item to its correct position in the view. This is because the view + implicitly sets the \c target and \c to values with the correct item and final item position + values if these properties are not explicitly defined. + + At its simplest, a view transition may just animate an item to its new position following a + view operation, just as the \c addDisplaced transition does above, or animate some item properties, + as in the \c add transition above. Additionally, a view transition may make use of the + ViewTransition attached property to customise animation behavior for different items. Following + are some examples of how this can be achieved. + + + \section2 Using the ViewTransition attached property + + As stated, the various ViewTransition properties provide details specific to the individual item + being transitioned as well as the operation that triggered the transition. In the animation above, + five items are inserted in succession at index 0. When the fifth and final insertion takes place, + adding "Item 4" to the view, the \c add transition is run once (for the inserted item) and the + \c addDisplaced transition is run four times (once for each of the four existing items in the view). + + At this point, if we examined the \c addDisplaced transition that was run for the bottom displaced + item ("Item 0"), the ViewTransition property values provided to this transition would be as follows: + + \table + \header + \o Property + \o Value + \o Explanation + \row + \o ViewTransition.item + \o "Item 0" delegate instance + \o The "Item 0" \l Rectangle object itself + \row + \o ViewTransition.index + \o \c int value of 4 + \o The index of "Item 0" within the model following the add operation + \row + \o ViewTransition.destination + \o \l point value of (0, 120) + \o The position that "Item 0" is moving to + \row + \o ViewTransition.targetIndexes + \o \c int array, just contains the integer "0" (zero) + \o The index of "Item 4", the new item added to the view + \row + \o ViewTransition.targetItems + \o object array, just contains the "Item 4" delegate instance + \o The "Item 4" \l Rectangle object - the new item added to the view + \endtable + + The ViewTransition.targetIndexes and ViewTransition.targetItems lists provide the items and + indexes of all delegate instances that are the targets of the relevant operation. For an add + operation, these are all the items that are added into the view; for a remove, these are all + the items removed from the view, and so on. (Note these lists will only contain references to + items that have been created within the view or its cached items; targets that are not within + the visible area of the view or within the item cache will not be accessible.) + + So, while the ViewTransition.item, ViewTransition.index and ViewTransition.destination values + vary for each individual transition that is run, the ViewTransition.targetIndexes and + ViewTransition.targetItems values are the same for every \c add and \c addDisplaced transition + that is triggered by a particular add operation. + + + \section3 Delaying animations based on index + + Since each view transition is run once for each item affected by the transition, the ViewTransition + properties can be used within a transition to define custom behavior for each item's transition. + For example, the ListView in the previous example could use this information to create a ripple-type + effect on the movement of the displaced items. + + This can be achieved by modifying the \c addDisplaced transition so that it delays the animation of + each displaced item based on the difference between its index (provided by ViewTransition.index) + and the first removed index (provided by ViewTransition.targetIndexes): + + \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml 0 + + Each displaced item delays its animation by an additional 100 milliseconds, producing a subtle + ripple-type effect when items are displaced by the add, like this: + + \image viewtransitions-delayedbyindex.gif + + + \section3 Animating items to intermediate positions + + The ViewTransition.item property gives a reference to the item to which the transition is being + applied. This can be used to access any of the item's attributes, custom \c property values, + and so on. + + Below is a modification of the \c addDisplaced transition from the previous example. It adds a + ParallelAnimation with nested NumberAnimation objects that reference ViewTransition.item to access + each item's \c x and \c y values at the start of their transitions. This allows each item to + animate to an intermediate position relative to its starting point for the transition, before + animating to its final position in the view: + + \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml 0 + + Now, a displaced item will first move to a position of (20, 50) relative to its starting + position, and then to its final, correct position in the view: + + \image viewtransitions-intermediatemove.gif + + Since the final NumberAnimation does not specify a \c to value, the view implicitly sets this + value to the item's final position in the view, and so this last animation will move this item + to the correct place. If the transition requires the final position of the item for some calculation, + this is accessible through ViewTransition.destination. + + Instead of using multiple NumberAnimations, you could use a PathAnimation to animate an item over + a curved path. For example, the \c add transition in the previous example could be augmented with + a PathAnimation as follows: to animate newly added items along a path: + + \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml 0 + + This animates newly added items along a path. Notice that each path is specified relative to + each item's final destination point, so that items inserted at different indexes start their + paths from different positions: + + \image viewtransitions-pathanim.gif + + + \section2 Handling interrupted animations + + A view transition may be interrupted at any time if a different view transition needs to be + applied while the original transition is in progress. For example, say Item A is inserted at index 0 + and undergoes an "add" transition; then, Item B is inserted at index 0 in quick succession before + Item A's transition has finished. Since Item B is inserted before Item A, it will displace Item + A, causing the view to interrupt Item A's "add" transition mid-way and start an "addDisplaced" + transition on Item A instead. + + For simple animations that simply animate an item's movement to its final destination, this + interruption is unlikely to require additional consideration. However, if a transition changes other + properties, this interruption may cause unwanted side effects. Consider the first example on this + page, repeated below for convenience: + + \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml 0 + + If multiple items are added in rapid succession, without waiting for a previous transition + to finish, this is the result: + + \image viewtransitions-interruptedbad.gif + + Each newly added item undergoes an \c add transition, but before the transition can finish, + another item is added, displacing the previously added item. Because of this, the \c add + transition on the previously added item is interrupted and an \c addDisplaced transition is + started on the item instead. Due to the interruption, the \c opacity and \c scale animations + have not completed, thus producing items with opacity and scale that are below 1.0. + + To fix this, the \c addDisplaced transition should additionally ensure the item properties are + set to the end values specified in the \c add transition, effectively resetting these values + whenever an item is displaced. In this case, it means setting the item opacity and scale to 1.0: + + \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml 0 + + Now, when an item's \c add transition is interrupted, its opacity and scale are animated to 1.0 + upon displacement, avoiding the erroneous visual effects from before: + + \image viewtransitions-interruptedgood.gif + + The same principle applies to any combination of view transitions. An added item may be moved + before its add transition finishes, or a moved item may be removed before its moved transition + finishes, and so on; so, the rule of thumb is that every transition should handle the same set of + properties. + + + \section2 Restrictions regarding ScriptAction + + When a view transition is initialized, any property bindings that refer to the ViewTransition + attached property are evaluated in preparation for the transition. Due to the nature of the + internal construction of a view transition, the attributes of the ViewTransition attached + property are only valid for the relevant item when the transition is initialized, and may not be + valid when the transition is actually run. + + Therefore, a ScriptAction within a view transition should not refer to the ViewTransition + attached property, as it may not refer to the expected values at the time that the ScriptAction + is actually invoked. Consider the following example: + + \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml 0 + + When the space key is pressed, three items are moved from index 5 to index 1. For each moved + item, the \c moveTransition sequence presumably animates the item's color to "yellow", then + animates it to its final position, then changes the item color back to "lightsteelblue" using a + ScriptAction. However, when run, the transition does not produce the intended result: + + \image viewtransitions-scriptactionbad.gif + + Only the last moved item is returned to the "lightsteelblue" color; the others remain yellow. This + is because the ScriptAction is not run until after the transition has already been initialized, by + which time the ViewTransition.item value has changed to refer to a different item; the item that + the script had intended to refer to is not the one held by ViewTransition.item at the time the + ScriptAction is actually invoked. + + In this instance, to avoid this issue, the view could set the property using a PropertyAction + instead: + + \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml 0 + + When the transition is initialized, the PropertyAction \c target will be set to the respective + ViewTransition.item for the transition and will later run with the correct item target as + expected. + */ + +/*! + \qmlattachedproperty list QtQuick2::ViewTransition::index + + This attached property holds the index of the item that is being + transitioned. + + Note that if the item is being moved, this property holds the index that + the item is moving to, not from. +*/ + +/*! + \qmlattachedproperty list QtQuick2::ViewTransition::item + + This attached property holds the the item that is being transitioned. + + \warning This item should not be kept and referred to outside of the transition + as it may become invalid as the view changes. +*/ + +/*! + \qmlattachedproperty list QtQuick2::ViewTransition::destination + + This attached property holds the final destination position for the transitioned + item within the view. + + This property value is a \l point with \c x and \c y properties. +*/ + +/*! + \qmlattachedproperty list QtQuick2::ViewTransition::targetIndexes + + This attached property holds a list of the indexes of the items in view + that are the target of the relevant operation. + + The targets are the items that are the subject of the operation. For + an add operation, these are the items being added; for a remove, these + are the items being removed; for a move, these are the items being + moved. + + For example, if the transition was triggered by an insert operation + that added two items at index 1 and 2, this targetIndexes list would + have the value [1,2]. + + \note The targetIndexes list only contains the indexes of items that are actually + in view, or will be in the view once the relevant operation completes. + + \sa QtQuick2::ViewTransition::targetIndexes +*/ + +/*! + \qmlattachedproperty list QtQuick2::ViewTransition::targetItems + + This attached property holds the list of items in view that are the + target of the relevant operation. + + The targets are the items that are the subject of the operation. For + an add operation, these are the items being added; for a remove, these + are the items being removed; for a move, these are the items being + moved. + + For example, if the transition was triggered by an insert operation + that added two items at index 1 and 2, this targetItems list would + contain these two items. + + \note The targetItems list only contains items that are actually + in view, or will be in the view once the relevant operation completes. + + \warning The objects in this list should not be kept and referred to + outside of the transition as the items may become invalid. The targetItems + are only valid when the Transition is initially created; this also means + they should not be used by ScriptAction objects in the Transition, which are + not evaluated until the transition is run. + + \sa QtQuick2::ViewTransition::targetIndexes +*/ +QDeclarativeListProperty QQuickViewTransitionAttached::targetItems() +{ + return QDeclarativeListProperty(this, m_targetItems); +} + +QQuickViewTransitionAttached *QQuickViewTransitionAttached::qmlAttachedProperties(QObject *obj) +{ + return new QQuickViewTransitionAttached(obj); +} + +QT_END_NAMESPACE diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h new file mode 100644 index 0000000000..c388bed17e --- /dev/null +++ b/src/quick/items/qquickitemviewtransition_p.h @@ -0,0 +1,201 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKITEMVIEWTRANSITION_P_P_H +#define QQUICKITEMVIEWTRANSITION_P_P_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QQuickItem; +class QQuickViewItem; +class QQuickItemViewTransitionJob; + + +class QQuickItemViewTransitionChangeListener +{ +public: + QQuickItemViewTransitionChangeListener() {} + virtual ~QQuickItemViewTransitionChangeListener() {} + + virtual void viewItemTransitionFinished(QQuickViewItem *item) = 0; +}; + + +class QQuickItemViewTransitioner +{ +public: + enum TransitionType { + NoTransition, + PopulateTransition, + AddTransition, + MoveTransition, + RemoveTransition + }; + + QQuickItemViewTransitioner(); + virtual ~QQuickItemViewTransitioner() {} + + bool canTransition(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const; + void transitionNextReposition(QQuickViewItem *item, QQuickItemViewTransitioner::TransitionType type, bool isTarget); + + inline void setPopulateTransitionEnabled(bool b) { usePopulateTransition = b; } + inline void setChangeListener(QQuickItemViewTransitionChangeListener *obj) { changeListener = obj; } + + QList addTransitionIndexes; + QList moveTransitionIndexes; + QList removeTransitionIndexes; + QList addTransitionTargets; + QList moveTransitionTargets; + QList removeTransitionTargets; + + QDeclarativeTransition *populateTransition; + QDeclarativeTransition *addTransition; + QDeclarativeTransition *addDisplacedTransition; + QDeclarativeTransition *moveTransition; + QDeclarativeTransition *moveDisplacedTransition; + QDeclarativeTransition *removeTransition; + QDeclarativeTransition *removeDisplacedTransition; + +private: + friend class QQuickItemViewTransitionJob; + + QQuickItemViewTransitionChangeListener *changeListener; + bool usePopulateTransition; + + void finishedTransition(QQuickViewItem *item); +}; + + +/* + An item in a view, that can be transitioned using QQuickViewTransitionJob. + */ +class QQuickViewItem +{ +public: + QQuickViewItem(QQuickItem *i); + virtual ~QQuickViewItem(); + + qreal itemX() const; + qreal itemY() const; + + void moveTo(const QPointF &pos); + void setVisible(bool visible); + + bool transitionScheduledOrRunning() const; + bool transitionRunning() const; + bool isPendingRemoval() const; + + bool prepareTransition(const QRectF &viewBounds); + void startTransition(QQuickItemViewTransitioner *transitioner); + void stopTransition(); + + QPointF nextTransitionTo; + QQuickItem *item; + QQuickItemViewTransitionJob *transition; + QQuickItemViewTransitioner::TransitionType nextTransitionType; + int index; + bool isTransitionTarget; + bool nextTransitionToSet; + +private: + friend class QQuickItemViewTransitioner; + friend class QQuickItemViewTransitionJob; + void setNextTransition(QQuickItemViewTransitioner::TransitionType, bool isTargetItem); + void finishedTransition(); + void resetTransitionData(); +}; + + +class QQuickViewTransitionAttached : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int index READ index NOTIFY indexChanged) + Q_PROPERTY(QQuickItem* item READ item NOTIFY itemChanged) + Q_PROPERTY(QPointF destination READ destination NOTIFY destinationChanged) + + Q_PROPERTY(QList targetIndexes READ targetIndexes NOTIFY targetIndexesChanged) + Q_PROPERTY(QDeclarativeListProperty targetItems READ targetItems NOTIFY targetItemsChanged) + +public: + QQuickViewTransitionAttached(QObject *parent); + + int index() const { return m_index; } + QQuickItem *item() const { return m_item; } + QPointF destination() const { return m_destination; } + + QList targetIndexes() const { return m_targetIndexes; } + QDeclarativeListProperty targetItems(); + + static QQuickViewTransitionAttached *qmlAttachedProperties(QObject *); + +signals: + void indexChanged(); + void itemChanged(); + void destinationChanged(); + + void targetIndexesChanged(); + void targetItemsChanged(); + +private: + friend class QQuickItemViewTransitionJob; + QPointF m_destination; + QList m_targetIndexes; + QList m_targetItems; + + QQuickItem *m_item; + int m_index; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QQuickViewTransitionAttached) +QML_DECLARE_TYPEINFO(QQuickViewTransitionAttached, QML_HAS_ATTACHED_PROPERTIES) + +QT_END_HEADER + +#endif // QQUICKITEMVIEWTRANSITION_P_P_H diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 0e643a13e3..2190952c69 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -316,9 +316,6 @@ public: return (x >= itemX() && x < itemX() + item->width() && y >= itemY() && y < itemY() + item->height()); } - QQuickItemView *itemView() const { - return view; - } QQuickListView *view; @@ -643,7 +640,7 @@ bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool d #endif if (!(item = static_cast(createItem(modelIndex, doBuffer)))) break; - if (!canTransition(FxViewItemTransitionManager::PopulateTransition, true)) // pos will be set by layoutVisibleItems() + if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems() item->setPosition(pos); item->item->setVisible(!doBuffer); pos += item->size() + spacing; @@ -663,7 +660,7 @@ bool QQuickListViewPrivate::addVisibleItems(qreal fillFrom, qreal fillTo, bool d break; --visibleIndex; visiblePos -= item->size() + spacing; - if (!canTransition(FxViewItemTransitionManager::PopulateTransition, true)) // pos will be set by layoutVisibleItems() + if (!transitioner || !transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) // pos will be set by layoutVisibleItems() item->setPosition(visiblePos); item->item->setVisible(!doBuffer); visibleItems.prepend(item); @@ -2341,6 +2338,10 @@ void QQuickListView::setSnapMode(SnapMode mode) the new item that has been added to the view; to animate the added items, set the \l add property. + If an item is displaced by multiple types of operations at the same time, it is not + defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition + will be applied. + For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2405,6 +2406,10 @@ void QQuickListView::setSnapMode(SnapMode mode) the items that are the actual subjects of the move operation; to animate the moved items, set the \l move property. + If an item is displaced by multiple types of operations at the same time, it is not + defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition + will be applied. + For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2472,6 +2477,10 @@ void QQuickListView::setSnapMode(SnapMode mode) the item that has actually been removed from the view; to animate the removed items, set the \l remove property. + If an item is displaced by multiple types of operations at the same time, it is not + defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition + will be applied. + For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2740,7 +2749,8 @@ bool QQuickListViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In insertResult->changedFirstItem = true; if (!change.isMove()) { addedItems->append(item); - transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, true); + if (transitioner) + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, true); } insertResult->sizeChangesBeforeVisiblePos += item->size() + spacing; pos -= item->size() + spacing; @@ -2766,11 +2776,12 @@ bool QQuickListViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In if (change.isMove()) { // we know this is a move target, since move displaced items that are // shuffled into view due to a move would be added in refill() - if (canTransition(FxViewItemTransitionManager::MoveTransition, true) && newItem) + if (newItem && transitioner && transitioner->canTransition(QQuickItemViewTransitioner::MoveTransition, true)) movingIntoView->append(MovedItem(item, change.moveKey(item->index))); } else { addedItems->append(item); - transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, true); + if (transitioner) + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, true); } insertResult->sizeChangesAfterVisiblePos += item->size() + spacing; pos += item->size() + spacing; @@ -2782,10 +2793,12 @@ bool QQuickListViewPrivate::applyInsertionChange(const QDeclarativeChangeSet::In FxViewItem *item = visibleItems.at(index); if (item->index != -1) item->index += count; - if (change.isMove()) - transitionNextReposition(item, FxViewItemTransitionManager::MoveTransition, false); - else - transitionNextReposition(item, FxViewItemTransitionManager::AddTransition, false); + if (transitioner) { + if (change.isMove()) + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::MoveTransition, false); + else + transitioner->transitionNextReposition(item, QQuickItemViewTransitioner::AddTransition, false); + } } updateVisibleIndex(); @@ -2797,6 +2810,9 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex { Q_UNUSED(insertionResult); + if (!transitioner) + return; + int markerItemIndex = -1; for (int i=0; iindex == afterModelIndex) { @@ -2816,7 +2832,7 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex if (!listItem->transitionScheduledOrRunning()) { qreal pos = listItem->position(); listItem->setPosition(pos - sizeRemoved); - transitionNextReposition(listItem, FxViewItemTransitionManager::RemoveTransition, false); + transitioner->transitionNextReposition(listItem, QQuickItemViewTransitioner::RemoveTransition, false); listItem->setPosition(pos); } } -- cgit v1.2.3 From 0507afe3fc13640fbf7d1a79c6699337b31498fc Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 28 Feb 2012 12:03:46 +1000 Subject: Properly cleanup cancelled incubation. Not all allocations were being destroyed. Change-Id: I2134bb224c58b947cfb990b0af2f6eedfd36da4a Reviewed-by: Andrew den Exter --- src/quick/items/qquickvisualdatamodel.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/quick/items/qquickvisualdatamodel.cpp b/src/quick/items/qquickvisualdatamodel.cpp index 0bdf0cb5af..3aa6077d32 100644 --- a/src/quick/items/qquickvisualdatamodel.cpp +++ b/src/quick/items/qquickvisualdatamodel.cpp @@ -461,8 +461,28 @@ void QQuickVisualDataModel::cancel(int index) Compositor::iterator it = d->m_compositor.find(d->m_compositorGroup, index); QQuickVisualDataModelItem *cacheItem = it->inCache() ? d->m_cache.at(it.cacheIndex) : 0; - if (cacheItem && cacheItem->incubationTask) - d->releaseIncubator(cacheItem->incubationTask); + if (cacheItem) { + if (cacheItem->incubationTask) { + delete cacheItem->incubationTask->incubatingContext; + cacheItem->incubationTask->incubatingContext = 0; + d->releaseIncubator(cacheItem->incubationTask); + cacheItem->incubationTask = 0; + } + if (cacheItem->object && !cacheItem->isObjectReferenced()) { + d->destroy(cacheItem->object); + if (QDeclarativePackage *package = qobject_cast(cacheItem->object)) + d->emitDestroyingPackage(package); + else if (QQuickItem *item = qobject_cast(cacheItem->object)) + d->emitDestroyingItem(item); + cacheItem->object = 0; + } + if (!cacheItem->isReferenced()) { + d->m_compositor.clearFlags(Compositor::Cache, it.cacheIndex, 1, Compositor::CacheFlag); + d->m_cache.removeAt(it.cacheIndex); + delete cacheItem; + Q_ASSERT(d->m_cache.count() == d->m_compositor.count(Compositor::Cache)); + } + } } void QQuickVisualDataModelPrivate::group_append( -- cgit v1.2.3 From 76c695c9a257c3ac914c11c283f04209075bc290 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Feb 2012 11:15:03 +0100 Subject: Add missing include Change-Id: Ifb4b489bb87b7ee8fb2f758da0e00af1e95e410f Reviewed-by: Olivier Goffart --- src/declarative/debugger/qdebugmessageservice.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/debugger/qdebugmessageservice.cpp b/src/declarative/debugger/qdebugmessageservice.cpp index 3f18a0fe4b..ca75199f58 100644 --- a/src/declarative/debugger/qdebugmessageservice.cpp +++ b/src/declarative/debugger/qdebugmessageservice.cpp @@ -42,6 +42,8 @@ #include "qdebugmessageservice_p.h" #include "qdeclarativedebugservice_p_p.h" +#include + QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QDebugMessageService, declarativeDebugMessageService) -- cgit v1.2.3 From ba3ac328ca721712c56f28a1fc6ae8e64b6ad7f2 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 22 Feb 2012 17:23:47 +1000 Subject: Add generic "displaced" transition property This is the default displaced transition that will be applied if addDisplaced, removeDisplaced or moveDisplaced are not specified (or are disabled). Change-Id: I9356036dc93bd9cb26e64e0b1769228113b74273 Reviewed-by: Martin Jones --- .../viewtransitions/viewtransitions-basic.qml | 2 +- .../viewtransitions-delayedbyindex.qml | 8 +- .../viewtransitions-intermediatemove.qml | 12 +- .../viewtransitions-interruptedgood.qml | 2 +- .../viewtransitions/viewtransitions-pathanim.qml | 12 +- .../viewtransitions-scriptactionbad.qml | 2 +- .../viewtransitions-scriptactiongood.qml | 2 +- src/quick/items/qquickgridview.cpp | 74 +++++-- src/quick/items/qquickitemview.cpp | 16 ++ src/quick/items/qquickitemview_p.h | 5 + src/quick/items/qquickitemviewtransition.cpp | 60 ++++-- src/quick/items/qquickitemviewtransition_p.h | 1 + src/quick/items/qquicklistview.cpp | 72 +++++-- .../qquickgridview/data/displacedTransitions.qml | 138 +++++++++++++ .../qtquick2/qquickgridview/tst_qquickgridview.cpp | 211 ++++++++++++++++++++ .../qquicklistview/data/displacedTransitions.qml | 128 +++++++++++++ .../qtquick2/qquicklistview/tst_qquicklistview.cpp | 213 +++++++++++++++++++++ tests/auto/qtquick2/shared/viewtestutil.h | 1 + 18 files changed, 887 insertions(+), 72 deletions(-) create mode 100644 tests/auto/qtquick2/qquickgridview/data/displacedTransitions.qml create mode 100644 tests/auto/qtquick2/qquicklistview/data/displacedTransitions.qml diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml index 8a05491ee1..cb94acb2b1 100644 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml +++ b/doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml @@ -60,7 +60,7 @@ ListView { NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } } - addDisplaced: Transition { + displaced: Transition { NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } } diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml index 79d00d2d1c..84c4848a76 100644 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml +++ b/doc/src/snippets/declarative/viewtransitions/viewtransitions-delayedbyindex.qml @@ -60,12 +60,12 @@ ListView { } //! [0] - addDisplaced: Transition { - id: addDispTrans + displaced: Transition { + id: dispTrans SequentialAnimation { PauseAnimation { - duration: (addDispTrans.ViewTransition.index - - addDispTrans.ViewTransition.targetIndexes[0]) * 100 + duration: (dispTrans.ViewTransition.index - + dispTrans.ViewTransition.targetIndexes[0]) * 100 } NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } } diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml index a43d3a8b7f..89353b40e8 100644 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml +++ b/doc/src/snippets/declarative/viewtransitions/viewtransitions-intermediatemove.qml @@ -60,20 +60,20 @@ ListView { } //! [0] - addDisplaced: Transition { - id: addDispTrans + displaced: Transition { + id: dispTrans SequentialAnimation { PauseAnimation { - duration: (addDispTrans.ViewTransition.index - - addDispTrans.ViewTransition.targetIndexes[0]) * 100 + duration: (dispTrans.ViewTransition.index - + dispTrans.ViewTransition.targetIndexes[0]) * 100 } ParallelAnimation { NumberAnimation { - property: "x"; to: addDispTrans.ViewTransition.item.x + 20 + property: "x"; to: dispTrans.ViewTransition.item.x + 20 easing.type: Easing.OutQuad } NumberAnimation { - property: "y"; to: addDispTrans.ViewTransition.item.y + 50 + property: "y"; to: dispTrans.ViewTransition.item.y + 50 easing.type: Easing.OutQuad } } diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml index 1355268710..0644caaec7 100644 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml +++ b/doc/src/snippets/declarative/viewtransitions/viewtransitions-interruptedgood.qml @@ -60,7 +60,7 @@ ListView { } //! [0] - addDisplaced: Transition { + displaced: Transition { NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } // ensure opacity and scale values return to 1.0 diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml index 3d075c4367..4b1685719d 100644 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml +++ b/doc/src/snippets/declarative/viewtransitions/viewtransitions-pathanim.qml @@ -76,20 +76,20 @@ ListView { } //! [0] - addDisplaced: Transition { - id: addDispTrans + displaced: Transition { + id: dispTrans SequentialAnimation { PauseAnimation { - duration: (addDispTrans.ViewTransition.index - - addDispTrans.ViewTransition.targetIndexes[0]) * 100 + duration: (dispTrans.ViewTransition.index - + dispTrans.ViewTransition.targetIndexes[0]) * 100 } ParallelAnimation { NumberAnimation { - property: "x"; to: addDispTrans.ViewTransition.item.x + 20 + property: "x"; to: dispTrans.ViewTransition.item.x + 20 easing.type: Easing.OutQuad } NumberAnimation { - property: "y"; to: addDispTrans.ViewTransition.item.y + 50 + property: "y"; to: dispTrans.ViewTransition.item.y + 50 easing.type: Easing.OutQuad } } diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml index 03348356e1..0e7d1e8d82 100644 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml +++ b/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactionbad.qml @@ -70,7 +70,7 @@ ListView { } } - moveDisplaced: Transition { + displaced: Transition { NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } } diff --git a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml b/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml index eda5c35479..7fa7e48f82 100644 --- a/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml +++ b/doc/src/snippets/declarative/viewtransitions/viewtransitions-scriptactiongood.qml @@ -73,7 +73,7 @@ ListView { } //! [0] - moveDisplaced: Transition { + displaced: Transition { NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } } diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp index fbce0af0c3..8b9f8059fb 100644 --- a/src/quick/items/qquickgridview.cpp +++ b/src/quick/items/qquickgridview.cpp @@ -1634,8 +1634,8 @@ void QQuickGridView::setSnapMode(SnapMode mode) Whenever an item is added to the above view, the item will be animated from the position (100,100) to its final x,y position within the view, over one second. The transition only applies to the new items that are added to the view; it does not apply to the items below that are - displaced by the addition of the new items. To animate the displaced items, set the \l - addDisplaced property. + displaced by the addition of the new items. To animate the displaced items, set the \l displaced + or \l addDisplaced properties. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -1671,9 +1671,10 @@ void QQuickGridView::setSnapMode(SnapMode mode) the new item that has been added to the view; to animate the added items, set the \l add property. - If an item is displaced by multiple types of operations at the same time, it is not - defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition - will be applied. + If an item is displaced by multiple types of operations at the same time, it is not defined as to + whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, + if it is not necessary to specify different transitions depending on whether an item is displaced + by an add, move or remove operation, consider setting the \l displaced property instead. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -1682,7 +1683,7 @@ void QQuickGridView::setSnapMode(SnapMode mode) populated, or when the view's \l model changes. In those cases, the \l populate transition is applied instead. - \sa add, populate, ViewTransition + \sa displaced, add, populate, ViewTransition */ /*! \qmlproperty Transition QtQuick2::GridView::move @@ -1705,7 +1706,7 @@ void QQuickGridView::setSnapMode(SnapMode mode) respective items in the view will be animated to their new positions in the view over one second. The transition only applies to the items that are the subject of the move operation in the model; it does not apply to items below them that are displaced by the move operation. - To animate the displaced items, set the \l moveDisplaced property. + To animate the displaced items, set the \l displaced or \l moveDisplaced properties. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -1738,14 +1739,15 @@ void QQuickGridView::setSnapMode(SnapMode mode) the items that are the actual subjects of the move operation; to animate the moved items, set the \l move property. - If an item is displaced by multiple types of operations at the same time, it is not - defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition - will be applied. + If an item is displaced by multiple types of operations at the same time, it is not defined as to + whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, + if it is not necessary to specify different transitions depending on whether an item is displaced + by an add, move or remove operation, consider setting the \l displaced property instead. For more details and examples on how to use view transitions, see the ViewTransition documentation. - \sa move, ViewTransition + \sa displaced, move, ViewTransition */ /*! @@ -1770,8 +1772,8 @@ void QQuickGridView::setSnapMode(SnapMode mode) Whenever an item is removed from the above view, the item will be animated to the position (100,100) over one second, and in parallel will also change its opacity to 0. The transition only applies to the items that are removed from the view; it does not apply to the items below - them that are displaced by the removal of the items. To animate the displaced items, set the \l - removeDisplaced property. + them that are displaced by the removal of the items. To animate the displaced items, set the + \l displaced or \l removeDisplaced properties. Note that by the time the transition is applied, the item has already been removed from the model; any references to the model data for the removed index will not be valid. @@ -1809,15 +1811,53 @@ void QQuickGridView::setSnapMode(SnapMode mode) the item that has actually been removed from the view; to animate the removed items, set the \l remove property. - If an item is displaced by multiple types of operations at the same time, it is not - defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition - will be applied. + If an item is displaced by multiple types of operations at the same time, it is not defined as to + whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, + if it is not necessary to specify different transitions depending on whether an item is displaced + by an add, move or remove operation, consider setting the \l displaced property instead. For more details and examples on how to use view transitions, see the ViewTransition documentation. - \sa remove, ViewTransition + \sa displaced, remove, ViewTransition */ + +/*! + \qmlproperty Transition QtQuick2::GridView::displaced + This property holds the generic transition to apply to items that have been displaced by + any model operation that affects the view. + + This is a convenience for specifying a generic transition for items that are displaced + by add, move or remove operations, without having to specify the individual addDisplaced, + moveDisplaced and removeDisplaced properties. For example, here is a view that specifies + a displaced transition: + + \code + GridView { + ... + displaced: Transition { + NumberAnimation { properties: "x,y"; duration: 1000 } + } + } + \endcode + + When any item is added, moved or removed within the above view, the items below it are + displaced, causing them to move down (or sideways, if horizontally orientated) within the + view. As this displacement occurs, the items' movement to their new x,y positions within + the view will be animated by a NumberAnimation over one second, as specified. + + If a view specifies this generic displaced transition as well as a specific addDisplaced, + moveDisplaced or removeDisplaced transition, the more specific transition will be used + instead of the generic displaced transition when the relevant operation occurs, providing that + the more specific transition has not been disabled (by setting \l {Transition::enabled}{enabled} + to false). If it has indeed been disabled, the generic displaced transition is applied instead. + + For more details and examples on how to use view transitions, see the ViewTransition + documentation. + + \sa addDisplaced, moveDisplaced, removeDisplaced, ViewTransition +*/ + void QQuickGridView::viewportMoved() { Q_D(QQuickGridView); diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index 481a0d4360..600b72dfcb 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -705,6 +705,22 @@ void QQuickItemView::setRemoveDisplacedTransition(QDeclarativeTransition *transi } } +QDeclarativeTransition *QQuickItemView::displacedTransition() const +{ + Q_D(const QQuickItemView); + return d->transitioner ? d->transitioner->displacedTransition : 0; +} + +void QQuickItemView::setDisplacedTransition(QDeclarativeTransition *transition) +{ + Q_D(QQuickItemView); + d->createTransitioner(); + if (d->transitioner->displacedTransition != transition) { + d->transitioner->displacedTransition = transition; + emit displacedTransitionChanged(); + } +} + void QQuickItemViewPrivate::positionViewAtIndex(int index, int mode) { Q_Q(QQuickItemView); diff --git a/src/quick/items/qquickitemview_p.h b/src/quick/items/qquickitemview_p.h index 63262f32ab..69a3d4a0c8 100644 --- a/src/quick/items/qquickitemview_p.h +++ b/src/quick/items/qquickitemview_p.h @@ -83,6 +83,7 @@ class Q_AUTOTEST_EXPORT QQuickItemView : public QQuickFlickable Q_PROPERTY(QDeclarativeTransition *moveDisplaced READ moveDisplacedTransition WRITE setMoveDisplacedTransition NOTIFY moveDisplacedTransitionChanged) Q_PROPERTY(QDeclarativeTransition *remove READ removeTransition WRITE setRemoveTransition NOTIFY removeTransitionChanged) Q_PROPERTY(QDeclarativeTransition *removeDisplaced READ removeDisplacedTransition WRITE setRemoveDisplacedTransition NOTIFY removeDisplacedTransitionChanged) + Q_PROPERTY(QDeclarativeTransition *displaced READ displacedTransition WRITE setDisplacedTransition NOTIFY displacedTransitionChanged) Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged) Q_PROPERTY(QQuickItem *highlightItem READ highlightItem NOTIFY highlightItemChanged) @@ -151,6 +152,9 @@ public: QDeclarativeTransition *removeDisplacedTransition() const; void setRemoveDisplacedTransition(QDeclarativeTransition *transition); + QDeclarativeTransition *displacedTransition() const; + void setDisplacedTransition(QDeclarativeTransition *transition); + QDeclarativeComponent *highlight() const; void setHighlight(QDeclarativeComponent *); @@ -211,6 +215,7 @@ signals: void moveDisplacedTransitionChanged(); void removeTransitionChanged(); void removeDisplacedTransitionChanged(); + void displacedTransitionChanged(); void highlightChanged(); void highlightItemChanged(); diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp index 3e3a99f553..0f092b76c3 100644 --- a/src/quick/items/qquickitemviewtransition.cpp +++ b/src/quick/items/qquickitemviewtransition.cpp @@ -90,13 +90,25 @@ void QQuickItemViewTransitionJob::startTransition(QQuickViewItem *item, QQuickIt trans = m_transitioner->populateTransition; break; case QQuickItemViewTransitioner::AddTransition: - trans = isTargetItem ? m_transitioner->addTransition : m_transitioner->addDisplacedTransition; + if (isTargetItem) + trans = m_transitioner->addTransition; + else + trans = (m_transitioner->addDisplacedTransition && m_transitioner->addDisplacedTransition->enabled()) ? + m_transitioner->addDisplacedTransition : m_transitioner->displacedTransition; break; case QQuickItemViewTransitioner::MoveTransition: - trans = isTargetItem ? m_transitioner->moveTransition : m_transitioner->moveDisplacedTransition; + if (isTargetItem) + trans = m_transitioner->moveTransition; + else + trans = (m_transitioner->moveDisplacedTransition && m_transitioner->moveDisplacedTransition->enabled()) ? + m_transitioner->moveDisplacedTransition : m_transitioner->displacedTransition; break; case QQuickItemViewTransitioner::RemoveTransition: - trans = isTargetItem ? m_transitioner->removeTransition : m_transitioner->removeDisplacedTransition; + if (isTargetItem) + trans = m_transitioner->removeTransition; + else + trans = (m_transitioner->removeDisplacedTransition && m_transitioner->removeDisplacedTransition->enabled()) ? + m_transitioner->removeDisplacedTransition : m_transitioner->displacedTransition; break; } @@ -169,6 +181,7 @@ QQuickItemViewTransitioner::QQuickItemViewTransitioner() , addTransition(0), addDisplacedTransition(0) , moveTransition(0), moveDisplacedTransition(0) , removeTransition(0), removeDisplacedTransition(0) + , displacedTransition(0) , changeListener(0) , usePopulateTransition(false) { @@ -176,6 +189,12 @@ QQuickItemViewTransitioner::QQuickItemViewTransitioner() bool QQuickItemViewTransitioner::canTransition(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const { + if (!asTarget + && type != QQuickItemViewTransitioner::NoTransition && type != QQuickItemViewTransitioner::PopulateTransition + && displacedTransition && displacedTransition->enabled()) { + return true; + } + switch (type) { case QQuickItemViewTransitioner::NoTransition: break; @@ -428,11 +447,16 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) operations: \list - \o \c add and \c addDisplaced - the transitions to run when items are added to the view - \o \c remove and \c removeDisplaced - the transitions to run when items are removed from the view - \o \c move and \c moveDisplaced - the transitions to run when items are moved within the view - (i.e. as a result of a move operation in the model) \o \c populate - the transition to run when a view is created, or when the model changes + \o \c add - the transition to apply to items that are added to the view + \o \c remove - the transition to apply to items that are removed from the view + \o \c move - the transition to apply to items that are moved within the view (i.e. as a result + of a move operation in the model) + \o \c displaced - the generic transition to be applied to any items that are displaced by an + add, move or remove operation + \o \c addDisplaced, \c removeDisplaced and \c moveDisplaced - the transitions to be applied when + items are displaced by add, move, or remove operations, respectively (these override the + generic displaced transition if specified) \endlist Such view transitions additionally have access to a ViewTransition attached property that @@ -468,14 +492,14 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) \section2 View transitions: a simple example Here is a basic example of the use of view transitions. The view below specifies transitions for - the \c add and \c addDisplaced properties, which will be run when items are added to the view: + the \c add and \c displaced properties, which will be run when items are added to the view: \snippet doc/src/snippets/declarative/viewtransitions/viewtransitions-basic.qml 0 When the space key is pressed, adding an item to the model, the new item will fade in and increase in scale over 400 milliseconds as it is added to the view. Also, any item that is displaced by the addition of a new item will animate to its new position in the view over - 400 milliseconds, as specified by the \c addDisplaced transition. + 400 milliseconds, as specified by the \c displaced transition. If five items were inserted in succession at index 0, the effect would be this: @@ -488,7 +512,7 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) values if these properties are not explicitly defined. At its simplest, a view transition may just animate an item to its new position following a - view operation, just as the \c addDisplaced transition does above, or animate some item properties, + view operation, just as the \c displaced transition does above, or animate some item properties, as in the \c add transition above. Additionally, a view transition may make use of the ViewTransition attached property to customise animation behavior for different items. Following are some examples of how this can be achieved. @@ -500,9 +524,9 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) being transitioned as well as the operation that triggered the transition. In the animation above, five items are inserted in succession at index 0. When the fifth and final insertion takes place, adding "Item 4" to the view, the \c add transition is run once (for the inserted item) and the - \c addDisplaced transition is run four times (once for each of the four existing items in the view). + \c displaced transition is run four times (once for each of the four existing items in the view). - At this point, if we examined the \c addDisplaced transition that was run for the bottom displaced + At this point, if we examined the \c displaced transition that was run for the bottom displaced item ("Item 0"), the ViewTransition property values provided to this transition would be as follows: \table @@ -541,7 +565,7 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) So, while the ViewTransition.item, ViewTransition.index and ViewTransition.destination values vary for each individual transition that is run, the ViewTransition.targetIndexes and - ViewTransition.targetItems values are the same for every \c add and \c addDisplaced transition + ViewTransition.targetItems values are the same for every \c add and \c displaced transition that is triggered by a particular add operation. @@ -552,7 +576,7 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) For example, the ListView in the previous example could use this information to create a ripple-type effect on the movement of the displaced items. - This can be achieved by modifying the \c addDisplaced transition so that it delays the animation of + This can be achieved by modifying the \c displaced transition so that it delays the animation of each displaced item based on the difference between its index (provided by ViewTransition.index) and the first removed index (provided by ViewTransition.targetIndexes): @@ -570,7 +594,7 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) applied. This can be used to access any of the item's attributes, custom \c property values, and so on. - Below is a modification of the \c addDisplaced transition from the previous example. It adds a + Below is a modification of the \c displaced transition from the previous example. It adds a ParallelAnimation with nested NumberAnimation objects that reference ViewTransition.item to access each item's \c x and \c y values at the start of their transitions. This allows each item to animate to an intermediate position relative to its starting point for the transition, before @@ -607,7 +631,7 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) applied while the original transition is in progress. For example, say Item A is inserted at index 0 and undergoes an "add" transition; then, Item B is inserted at index 0 in quick succession before Item A's transition has finished. Since Item B is inserted before Item A, it will displace Item - A, causing the view to interrupt Item A's "add" transition mid-way and start an "addDisplaced" + A, causing the view to interrupt Item A's "add" transition mid-way and start a "displaced" transition on Item A instead. For simple animations that simply animate an item's movement to its final destination, this @@ -624,11 +648,11 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) Each newly added item undergoes an \c add transition, but before the transition can finish, another item is added, displacing the previously added item. Because of this, the \c add - transition on the previously added item is interrupted and an \c addDisplaced transition is + transition on the previously added item is interrupted and a \c displaced transition is started on the item instead. Due to the interruption, the \c opacity and \c scale animations have not completed, thus producing items with opacity and scale that are below 1.0. - To fix this, the \c addDisplaced transition should additionally ensure the item properties are + To fix this, the \c displaced transition should additionally ensure the item properties are set to the end values specified in the \c add transition, effectively resetting these values whenever an item is displaced. In this case, it means setting the item opacity and scale to 1.0: diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h index c388bed17e..8dd2f86899 100644 --- a/src/quick/items/qquickitemviewtransition_p.h +++ b/src/quick/items/qquickitemviewtransition_p.h @@ -99,6 +99,7 @@ public: QDeclarativeTransition *moveDisplacedTransition; QDeclarativeTransition *removeTransition; QDeclarativeTransition *removeDisplacedTransition; + QDeclarativeTransition *displacedTransition; private: friend class QQuickItemViewTransitionJob; diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 2190952c69..876859eeb1 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -2301,8 +2301,8 @@ void QQuickListView::setSnapMode(SnapMode mode) Whenever an item is added to the above view, the item will be animated from the position (100,100) to its final x,y position within the view, over one second. The transition only applies to the new items that are added to the view; it does not apply to the items below that are - displaced by the addition of the new items. To animate the displaced items, set the \l - addDisplaced property. + displaced by the addition of the new items. To animate the displaced items, set the \l displaced + or \l addDisplaced properties. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2338,9 +2338,10 @@ void QQuickListView::setSnapMode(SnapMode mode) the new item that has been added to the view; to animate the added items, set the \l add property. - If an item is displaced by multiple types of operations at the same time, it is not - defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition - will be applied. + If an item is displaced by multiple types of operations at the same time, it is not defined as to + whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, + if it is not necessary to specify different transitions depending on whether an item is displaced + by an add, move or remove operation, consider setting the \l displaced property instead. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2349,7 +2350,7 @@ void QQuickListView::setSnapMode(SnapMode mode) populated, or when the view's \l model changes. In those cases, the \l populate transition is applied instead. - \sa add, populate, ViewTransition + \sa displaced, add, populate, ViewTransition */ /*! @@ -2373,7 +2374,7 @@ void QQuickListView::setSnapMode(SnapMode mode) respective items in the view will be animated to their new positions in the view over one second. The transition only applies to the items that are the subject of the move operation in the model; it does not apply to items below them that are displaced by the move operation. - To animate the displaced items, set the \l moveDisplaced property. + To animate the displaced items, set the \l displaced or \l moveDisplaced properties. For more details and examples on how to use view transitions, see the ViewTransition documentation. @@ -2406,14 +2407,15 @@ void QQuickListView::setSnapMode(SnapMode mode) the items that are the actual subjects of the move operation; to animate the moved items, set the \l move property. - If an item is displaced by multiple types of operations at the same time, it is not - defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition - will be applied. + If an item is displaced by multiple types of operations at the same time, it is not defined as to + whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, + if it is not necessary to specify different transitions depending on whether an item is displaced + by an add, move or remove operation, consider setting the \l displaced property instead. For more details and examples on how to use view transitions, see the ViewTransition documentation. - \sa move, ViewTransition + \sa displaced, move, ViewTransition */ /*! @@ -2438,8 +2440,8 @@ void QQuickListView::setSnapMode(SnapMode mode) Whenever an item is removed from the above view, the item will be animated to the position (100,100) over one second, and in parallel will also change its opacity to 0. The transition only applies to the items that are removed from the view; it does not apply to the items below - them that are displaced by the removal of the items. To animate the displaced items, set the \l - removeDisplaced property. + them that are displaced by the removal of the items. To animate the displaced items, set the + \l displaced or \l removeDisplaced properties. Note that by the time the transition is applied, the item has already been removed from the model; any references to the model data for the removed index will not be valid. @@ -2477,16 +2479,52 @@ void QQuickListView::setSnapMode(SnapMode mode) the item that has actually been removed from the view; to animate the removed items, set the \l remove property. - If an item is displaced by multiple types of operations at the same time, it is not - defined as to whether the addDisplaced, moveDisplaced or removeDisplaced transition - will be applied. + If an item is displaced by multiple types of operations at the same time, it is not defined as to + whether the addDisplaced, moveDisplaced or removeDisplaced transition will be applied. Additionally, + if it is not necessary to specify different transitions depending on whether an item is displaced + by an add, move or remove operation, consider setting the \l displaced property instead. For more details and examples on how to use view transitions, see the ViewTransition documentation. - \sa remove, ViewTransition + \sa displaced, remove, ViewTransition */ +/*! + \qmlproperty Transition QtQuick2::ListView::displaced + This property holds the generic transition to apply to items that have been displaced by + any model operation that affects the view. + + This is a convenience for specifying the generic transition to be applied to any items + that are displaced by an add, move or remove operation, without having to specify the + individual addDisplaced, moveDisplaced and removeDisplaced properties. For example, here + is a view that specifies a displaced transition: + + \code + ListView { + ... + displaced: Transition { + NumberAnimation { properties: "x,y"; duration: 1000 } + } + } + \endcode + + When any item is added, moved or removed within the above view, the items below it are + displaced, causing them to move down (or sideways, if horizontally orientated) within the + view. As this displacement occurs, the items' movement to their new x,y positions within + the view will be animated by a NumberAnimation over one second, as specified. + + If a view specifies this generic displaced transition as well as a specific addDisplaced, + moveDisplaced or removeDisplaced transition, the more specific transition will be used + instead of the generic displaced transition when the relevant operation occurs, providing that + the more specific transition has not been disabled (by setting \l {Transition::enabled}{enabled} + to false). If it has indeed been disabled, the generic displaced transition is applied instead. + + For more details and examples on how to use view transitions, see the ViewTransition + documentation. + + \sa addDisplaced, moveDisplaced, removeDisplaced, ViewTransition +*/ void QQuickListView::viewportMoved() { diff --git a/tests/auto/qtquick2/qquickgridview/data/displacedTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/displacedTransitions.qml new file mode 100644 index 0000000000..d9353c0639 --- /dev/null +++ b/tests/auto/qtquick2/qquickgridview/data/displacedTransitions.qml @@ -0,0 +1,138 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 500 + height: 600 + + property int duration: 10 + property int count: grid.count + + Component { + id: myDelegate + Rectangle { + id: wrapper + + property string nameData: name + + objectName: "wrapper" + width: 80 + height: 60 + Text { + text: index + } + Text { + x: 40 + text: wrapper.x + ", " + wrapper.y + } + Text { + y: 20 + id: textName + objectName: "textName" + text: name + } + Text { + y: 40 + id: textNumber + objectName: "textNumber" + text: number + } + color: GridView.isCurrentItem ? "lightsteelblue" : "white" + + onXChanged: checkPos() + onYChanged: checkPos() + + function checkPos() { + if (Qt.point(x, y) == displaced_transitionVia) + model_displaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == addDisplaced_transitionVia) + model_addDisplaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == moveDisplaced_transitionVia) + model_moveDisplaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == removeDisplaced_transitionVia) + model_removeDisplaced_transitionVia.addItem(name, "") + } + } + } + + GridView { + id: grid + + property int targetTransitionsDone + property int displaceTransitionsDone + + objectName: "grid" + focus: true + anchors.centerIn: parent + width: 240 + height: 320 + cellWidth: 80 + cellHeight: 60 + model: testModel + delegate: myDelegate + + displaced: useDisplaced ? displaced : null + addDisplaced: useAddDisplaced ? addDisplaced : null + moveDisplaced: useMoveDisplaced ? moveDisplaced : null + removeDisplaced: useRemoveDisplaced ? removeDisplaced : null + + Transition { + id: displaced + enabled: displacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: displaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: displaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: addDisplaced + enabled: addDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: addDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: addDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: moveDisplaced + enabled: moveDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: moveDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: moveDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: removeDisplaced + enabled: removeDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: removeDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: removeDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: grid; property: "displaceTransitionsDone"; value: true } + } + } + } + + Rectangle { + anchors.fill: grid + color: "lightsteelblue" + opacity: 0.2 + } +} + diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index 5765a67b77..6d755a64c7 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -138,6 +138,8 @@ private slots: void moveTransitions_data(); void removeTransitions(); void removeTransitions_data(); + void displacedTransitions(); + void displacedTransitions_data(); void multipleTransitions(); void multipleTransitions_data(); @@ -4557,6 +4559,215 @@ void tst_QQuickGridView::removeTransitions_data() << 18 << 3 << ListRange(); } +void tst_QQuickGridView::displacedTransitions() +{ + QFETCH(bool, useDisplaced); + QFETCH(bool, displacedEnabled); + QFETCH(bool, useAddDisplaced); + QFETCH(bool, addDisplacedEnabled); + QFETCH(bool, useMoveDisplaced); + QFETCH(bool, moveDisplacedEnabled); + QFETCH(bool, useRemoveDisplaced); + QFETCH(bool, removeDisplacedEnabled); + QFETCH(ListChange, change); + QFETCH(ListRange, expectedDisplacedIndexes); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_displaced_transitionVia; + QaimModel model_addDisplaced_transitionVia; + QaimModel model_moveDisplaced_transitionVia; + QaimModel model_removeDisplaced_transitionVia; + + QPointF displaced_transitionVia(-50, -100); + QPointF addDisplaced_transitionVia(-150, 100); + QPointF moveDisplaced_transitionVia(50, -100); + QPointF removeDisplaced_transitionVia(150, 100); + + QQuickView *canvas = createView(); + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia); + ctxt->setContextProperty("model_addDisplaced_transitionVia", &model_addDisplaced_transitionVia); + ctxt->setContextProperty("model_moveDisplaced_transitionVia", &model_moveDisplaced_transitionVia); + ctxt->setContextProperty("model_removeDisplaced_transitionVia", &model_removeDisplaced_transitionVia); + ctxt->setContextProperty("displaced_transitionVia", displaced_transitionVia); + ctxt->setContextProperty("addDisplaced_transitionVia", addDisplaced_transitionVia); + ctxt->setContextProperty("moveDisplaced_transitionVia", moveDisplaced_transitionVia); + ctxt->setContextProperty("removeDisplaced_transitionVia", removeDisplaced_transitionVia); + ctxt->setContextProperty("useDisplaced", useDisplaced); + ctxt->setContextProperty("displacedEnabled", displacedEnabled); + ctxt->setContextProperty("useAddDisplaced", useAddDisplaced); + ctxt->setContextProperty("addDisplacedEnabled", addDisplacedEnabled); + ctxt->setContextProperty("useMoveDisplaced", useMoveDisplaced); + ctxt->setContextProperty("moveDisplacedEnabled", moveDisplacedEnabled); + ctxt->setContextProperty("useRemoveDisplaced", useRemoveDisplaced); + ctxt->setContextProperty("removeDisplacedEnabled", removeDisplacedEnabled); + canvas->setSource(testFileUrl("displacedTransitions.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + QQuickItem *contentItem = gridview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + gridview->setProperty("displaceTransitionsDone", false); + + switch (change.type) { + case ListChange::Inserted: + { + QList > targetItemData; + for (int i=change.index; icount()); + break; + } + case ListChange::Removed: + model.removeItems(change.index, change.count); + QTRY_COMPARE(model.count(), gridview->count()); + break; + case ListChange::Moved: + model.moveItems(change.index, change.to, change.count); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + break; + case ListChange::SetCurrent: + case ListChange::SetContentY: + break; + } + if ((useDisplaced && displacedEnabled) + || (useAddDisplaced && addDisplacedEnabled) + || (useMoveDisplaced && moveDisplacedEnabled) + || (useRemoveDisplaced && removeDisplacedEnabled)) { + QTRY_VERIFY(gridview->property("displaceTransitionsDone").toBool()); + } + + if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled) + model_addDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with add displaced", "shouldn't have been animated with add displaced"); + else + QCOMPARE(model_addDisplaced_transitionVia.count(), 0); + if (change.type == ListChange::Moved && useMoveDisplaced && moveDisplacedEnabled) + model_moveDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with move displaced", "shouldn't have been animated with move displaced"); + else + QCOMPARE(model_moveDisplaced_transitionVia.count(), 0); + if (change.type == ListChange::Removed && useRemoveDisplaced && removeDisplacedEnabled) + model_removeDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with remove displaced", "shouldn't have been animated with remove displaced"); + else + QCOMPARE(model_removeDisplaced_transitionVia.count(), 0); + + if (useDisplaced && displacedEnabled + && ( (change.type == ListChange::Inserted && (!useAddDisplaced || !addDisplacedEnabled)) + || (change.type == ListChange::Moved && (!useMoveDisplaced || !moveDisplacedEnabled)) + || (change.type == ListChange::Removed && (!useRemoveDisplaced || !removeDisplacedEnabled))) ) { + model_displaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with generic displaced", "shouldn't have been animated with generic displaced"); + } else { + QCOMPARE(model_displaced_transitionVia.count(), 0); + } + + // verify all items moved to the correct final positions + QList items = findItems(contentItem, "wrapper"); + for (int i=0; i < model.count() && i < items.count(); ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), (i%3)*80.0); + QCOMPARE(item->y(), (i/3)*60.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; +} + +void tst_QQuickGridView::displacedTransitions_data() +{ + QTest::addColumn("useDisplaced"); + QTest::addColumn("displacedEnabled"); + QTest::addColumn("useAddDisplaced"); + QTest::addColumn("addDisplacedEnabled"); + QTest::addColumn("useMoveDisplaced"); + QTest::addColumn("moveDisplacedEnabled"); + QTest::addColumn("useRemoveDisplaced"); + QTest::addColumn("removeDisplacedEnabled"); + QTest::addColumn("change"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("no displaced transitions at all") + << false << false + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 17); + + QTest::newRow("just displaced") + << true << true + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 17); + + QTest::newRow("just displaced (not enabled)") + << true << false + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 17); + + QTest::newRow("displaced + addDisplaced") + << true << true + << true << true + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 17); + + QTest::newRow("displaced + addDisplaced (not enabled)") + << true << true + << true << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 17); + + QTest::newRow("displaced + moveDisplaced") + << true << true + << false << false + << true << true + << false << false + << ListChange::move(0, 10, 1) << ListRange(1, 10); + + QTest::newRow("displaced + moveDisplaced (not enabled)") + << true << true + << false << false + << true << false + << false << false + << ListChange::move(0, 10, 1) << ListRange(1, 10); + + QTest::newRow("displaced + removeDisplaced") + << true << true + << false << false + << false << false + << true << true + << ListChange::remove(0, 1) << ListRange(1, 18); + + QTest::newRow("displaced + removeDisplaced (not enabled)") + << true << true + << false << false + << false << false + << true << false + << ListChange::remove(0, 1) << ListRange(1, 18); + + + QTest::newRow("displaced + add, should use generic displaced for a remove") + << true << true + << true << true + << false << false + << true << false + << ListChange::remove(0, 1) << ListRange(1, 18); +} + void tst_QQuickGridView::multipleTransitions() { // Tests that if you interrupt a transition in progress with another action that diff --git a/tests/auto/qtquick2/qquicklistview/data/displacedTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/displacedTransitions.qml new file mode 100644 index 0000000000..cc7892e930 --- /dev/null +++ b/tests/auto/qtquick2/qquicklistview/data/displacedTransitions.qml @@ -0,0 +1,128 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 500 + height: 600 + + property int duration: 10 + property int count: list.count + + Component { + id: myDelegate + Rectangle { + id: wrapper + + property string nameData: name + + objectName: "wrapper" + height: 20 + width: 240 + Text { text: index } + Text { + x: 30 + id: textName + objectName: "textName" + text: name + } + Text { + x: 200 + text: wrapper.y + } + color: ListView.isCurrentItem ? "lightsteelblue" : "white" + + onXChanged: checkPos() + onYChanged: checkPos() + + function checkPos() { + if (Qt.point(x, y) == displaced_transitionVia) + model_displaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == addDisplaced_transitionVia) + model_addDisplaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == moveDisplaced_transitionVia) + model_moveDisplaced_transitionVia.addItem(name, "") + if (Qt.point(x, y) == removeDisplaced_transitionVia) + model_removeDisplaced_transitionVia.addItem(name, "") + } + } + } + + ListView { + id: list + + property int targetTransitionsDone + property int displaceTransitionsDone + + objectName: "list" + focus: true + anchors.centerIn: parent + width: 240 + height: 320 + model: testModel + delegate: myDelegate + + displaced: useDisplaced ? displaced : null + addDisplaced: useAddDisplaced ? addDisplaced : null + moveDisplaced: useMoveDisplaced ? moveDisplaced : null + removeDisplaced: useRemoveDisplaced ? removeDisplaced : null + + Transition { + id: displaced + enabled: displacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: displaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: displaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: addDisplaced + enabled: addDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: addDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: addDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: moveDisplaced + enabled: moveDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: moveDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: moveDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + + Transition { + id: removeDisplaced + enabled: removeDisplacedEnabled + SequentialAnimation { + ParallelAnimation { + NumberAnimation { properties: "x"; to: removeDisplaced_transitionVia.x; duration: root.duration } + NumberAnimation { properties: "y"; to: removeDisplaced_transitionVia.y; duration: root.duration } + } + NumberAnimation { properties: "x,y"; duration: root.duration } + PropertyAction { target: list; property: "displaceTransitionsDone"; value: true } + } + } + } + + Rectangle { + anchors.fill: list + color: "lightsteelblue" + opacity: 0.2 + } +} + diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index 04da3f732f..a834f1aa03 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -179,6 +179,8 @@ private slots: void moveTransitions_data(); void removeTransitions(); void removeTransitions_data(); + void displacedTransitions(); + void displacedTransitions_data(); void multipleTransitions(); void multipleTransitions_data(); @@ -5564,6 +5566,217 @@ void tst_QQuickListView::removeTransitions_data() << 17 << 3 << ListRange(); } +void tst_QQuickListView::displacedTransitions() +{ + QFETCH(bool, useDisplaced); + QFETCH(bool, displacedEnabled); + QFETCH(bool, useAddDisplaced); + QFETCH(bool, addDisplacedEnabled); + QFETCH(bool, useMoveDisplaced); + QFETCH(bool, moveDisplacedEnabled); + QFETCH(bool, useRemoveDisplaced); + QFETCH(bool, removeDisplacedEnabled); + QFETCH(ListChange, change); + QFETCH(ListRange, expectedDisplacedIndexes); + + QaimModel model; + for (int i = 0; i < 30; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_displaced_transitionVia; + QaimModel model_addDisplaced_transitionVia; + QaimModel model_moveDisplaced_transitionVia; + QaimModel model_removeDisplaced_transitionVia; + + QPointF displaced_transitionVia(-50, -100); + QPointF addDisplaced_transitionVia(-150, 100); + QPointF moveDisplaced_transitionVia(50, -100); + QPointF removeDisplaced_transitionVia(150, 100); + + QQuickView *canvas = createView(); + QDeclarativeContext *ctxt = canvas->rootContext(); + TestObject *testObject = new TestObject(canvas); + ctxt->setContextProperty("testModel", &model); + ctxt->setContextProperty("testObject", testObject); + ctxt->setContextProperty("model_displaced_transitionVia", &model_displaced_transitionVia); + ctxt->setContextProperty("model_addDisplaced_transitionVia", &model_addDisplaced_transitionVia); + ctxt->setContextProperty("model_moveDisplaced_transitionVia", &model_moveDisplaced_transitionVia); + ctxt->setContextProperty("model_removeDisplaced_transitionVia", &model_removeDisplaced_transitionVia); + ctxt->setContextProperty("displaced_transitionVia", displaced_transitionVia); + ctxt->setContextProperty("addDisplaced_transitionVia", addDisplaced_transitionVia); + ctxt->setContextProperty("moveDisplaced_transitionVia", moveDisplaced_transitionVia); + ctxt->setContextProperty("removeDisplaced_transitionVia", removeDisplaced_transitionVia); + ctxt->setContextProperty("useDisplaced", useDisplaced); + ctxt->setContextProperty("displacedEnabled", displacedEnabled); + ctxt->setContextProperty("useAddDisplaced", useAddDisplaced); + ctxt->setContextProperty("addDisplacedEnabled", addDisplacedEnabled); + ctxt->setContextProperty("useMoveDisplaced", useMoveDisplaced); + ctxt->setContextProperty("moveDisplacedEnabled", moveDisplacedEnabled); + ctxt->setContextProperty("useRemoveDisplaced", useRemoveDisplaced); + ctxt->setContextProperty("removeDisplacedEnabled", removeDisplacedEnabled); + canvas->setSource(testFileUrl("displacedTransitions.qml")); + canvas->show(); + qApp->processEvents(); + + QQuickListView *listview = findItem(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + QQuickItem *contentItem = listview->contentItem(); + QVERIFY(contentItem != 0); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + listview->setProperty("displaceTransitionsDone", false); + + switch (change.type) { + case ListChange::Inserted: + { + QList > targetItemData; + for (int i=change.index; icount()); + break; + } + case ListChange::Removed: + model.removeItems(change.index, change.count); + QTRY_COMPARE(model.count(), listview->count()); + break; + case ListChange::Moved: + model.moveItems(change.index, change.to, change.count); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + break; + case ListChange::SetCurrent: + case ListChange::SetContentY: + break; + } + if ((useDisplaced && displacedEnabled) + || (useAddDisplaced && addDisplacedEnabled) + || (useMoveDisplaced && moveDisplacedEnabled) + || (useRemoveDisplaced && removeDisplacedEnabled)) { + QTRY_VERIFY(listview->property("displaceTransitionsDone").toBool()); + } + + if (change.type == ListChange::Inserted && useAddDisplaced && addDisplacedEnabled) + model_addDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with add displaced", "shouldn't have been animated with add displaced"); + else + QCOMPARE(model_addDisplaced_transitionVia.count(), 0); + if (change.type == ListChange::Moved && useMoveDisplaced && moveDisplacedEnabled) + model_moveDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with move displaced", "shouldn't have been animated with move displaced"); + else + QCOMPARE(model_moveDisplaced_transitionVia.count(), 0); + if (change.type == ListChange::Removed && useRemoveDisplaced && removeDisplacedEnabled) + model_removeDisplaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with remove displaced", "shouldn't have been animated with remove displaced"); + else + QCOMPARE(model_removeDisplaced_transitionVia.count(), 0); + + if (useDisplaced && displacedEnabled + && ( (change.type == ListChange::Inserted && (!useAddDisplaced || !addDisplacedEnabled)) + || (change.type == ListChange::Moved && (!useMoveDisplaced || !moveDisplacedEnabled)) + || (change.type == ListChange::Removed && (!useRemoveDisplaced || !removeDisplacedEnabled))) ) { + model_displaced_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with generic displaced", "shouldn't have been animated with generic displaced"); + } else { + QCOMPARE(model_displaced_transitionVia.count(), 0); + } + + // verify all items moved to the correct final positions + QList items = findItems(contentItem, "wrapper"); + for (int i=0; i < model.count() && i < items.count(); ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + QCOMPARE(item->x(), 0.0); + QCOMPARE(item->y(), i * 20.0); + QQuickText *name = findItem(contentItem, "textName", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model.name(i)); + } + + delete canvas; +} + +void tst_QQuickListView::displacedTransitions_data() +{ + QTest::addColumn("useDisplaced"); + QTest::addColumn("displacedEnabled"); + QTest::addColumn("useAddDisplaced"); + QTest::addColumn("addDisplacedEnabled"); + QTest::addColumn("useMoveDisplaced"); + QTest::addColumn("moveDisplacedEnabled"); + QTest::addColumn("useRemoveDisplaced"); + QTest::addColumn("removeDisplacedEnabled"); + QTest::addColumn("change"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("no displaced transitions at all") + << false << false + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 15); + + QTest::newRow("just displaced") + << true << true + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 15); + + QTest::newRow("just displaced (not enabled)") + << true << false + << false << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 15); + + QTest::newRow("displaced + addDisplaced") + << true << true + << true << true + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 15); + + QTest::newRow("displaced + addDisplaced (not enabled)") + << true << true + << true << false + << false << false + << false << false + << ListChange::insert(0, 1) << ListRange(0, 15); + + QTest::newRow("displaced + moveDisplaced") + << true << true + << false << false + << true << true + << false << false + << ListChange::move(0, 10, 1) << ListRange(1, 10); + + QTest::newRow("displaced + moveDisplaced (not enabled)") + << true << true + << false << false + << true << false + << false << false + << ListChange::move(0, 10, 1) << ListRange(1, 10); + + QTest::newRow("displaced + removeDisplaced") + << true << true + << false << false + << false << false + << true << true + << ListChange::remove(0, 1) << ListRange(1, 16); + + QTest::newRow("displaced + removeDisplaced (not enabled)") + << true << true + << false << false + << false << false + << true << false + << ListChange::remove(0, 1) << ListRange(1, 16); + + + QTest::newRow("displaced + add, should use generic displaced for a remove") + << true << true + << true << true + << false << false + << true << false + << ListChange::remove(0, 1) << ListRange(1, 16); +} + void tst_QQuickListView::multipleTransitions() { QSKIP("QTBUG-24523"); diff --git a/tests/auto/qtquick2/shared/viewtestutil.h b/tests/auto/qtquick2/shared/viewtestutil.h index 71fd5065df..ebee1787d3 100644 --- a/tests/auto/qtquick2/shared/viewtestutil.h +++ b/tests/auto/qtquick2/shared/viewtestutil.h @@ -174,6 +174,7 @@ namespace QQuickViewTestUtil }; } +Q_DECLARE_METATYPE(QQuickViewTestUtil::ListChange) Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange) -- cgit v1.2.3 From ab727e6702e949c8f36649f16a81780746ebb2de Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 28 Feb 2012 13:03:30 +1000 Subject: Add and use a method for querying whether a property is revisioned. Accessor data and the revision are now unioned, so querying the value directly can give incorrect results. Change-Id: I0ba6c53d8bd6b012507bfb32d33dc414348379b0 Reviewed-by: Chris Adams --- src/declarative/qml/qdeclarativepropertycache_p.h | 1 + src/declarative/qml/v4/qv4irbuilder.cpp | 6 +++--- src/declarative/qml/v8/qv8qobjectwrapper.cpp | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/declarative/qml/qdeclarativepropertycache_p.h b/src/declarative/qml/qdeclarativepropertycache_p.h index d5d7095667..301f70bfe8 100644 --- a/src/declarative/qml/qdeclarativepropertycache_p.h +++ b/src/declarative/qml/qdeclarativepropertycache_p.h @@ -149,6 +149,7 @@ public: bool hasOverride() const { return !(flags & IsValueTypeVirtual) && !(flags & HasAccessors) && overrideIndex >= 0; } + bool hasRevision() const { return !(flags & HasAccessors) && revision != 0; } // Returns -1 if not a value type virtual property inline int getValueTypeCoreIndex() const; diff --git a/src/declarative/qml/v4/qv4irbuilder.cpp b/src/declarative/qml/v4/qv4irbuilder.cpp index 604eeaa713..522bc01684 100644 --- a/src/declarative/qml/v4/qv4irbuilder.cpp +++ b/src/declarative/qml/v4/qv4irbuilder.cpp @@ -437,7 +437,7 @@ bool QV4IRBuilder::visit(AST::IdentifierExpression *ast) QDeclarativePropertyData *data = cache->property(name); - if (data && data->revision != 0) { + if (data && data->hasRevision()) { if (qmlVerboseCompiler()) qWarning() << "*** versioned symbol:" << name; discard(); @@ -458,7 +458,7 @@ bool QV4IRBuilder::visit(AST::IdentifierExpression *ast) QDeclarativePropertyData *data = cache->property(name); - if (data && data->revision != 0) { + if (data && data->hasRevision()) { if (qmlVerboseCompiler()) qWarning() << "*** versioned symbol:" << name; discard(); @@ -609,7 +609,7 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast) if (!data || data->isFunction()) return false; // Don't support methods (or non-existing properties ;) - if (data->revision != 0) { + if (data->hasRevision()) { if (qmlVerboseCompiler()) qWarning() << "*** versioned symbol:" << name; discard(); diff --git a/src/declarative/qml/v8/qv8qobjectwrapper.cpp b/src/declarative/qml/v8/qv8qobjectwrapper.cpp index 11733be5fd..9c4e07ae4f 100644 --- a/src/declarative/qml/v8/qv8qobjectwrapper.cpp +++ b/src/declarative/qml/v8/qv8qobjectwrapper.cpp @@ -513,7 +513,7 @@ v8::Handle QV8QObjectWrapper::GetProperty(QV8Engine *engine, QObject if (!result) return v8::Handle(); - if (revisionMode == QV8QObjectWrapper::CheckRevision && result->revision != 0) { + if (revisionMode == QV8QObjectWrapper::CheckRevision && result->hasRevision()) { QDeclarativeData *ddata = QDeclarativeData::get(object); if (ddata && ddata->propertyCache && !ddata->propertyCache->isAllowedInRevision(result)) return v8::Handle(); @@ -673,7 +673,7 @@ bool QV8QObjectWrapper::SetProperty(QV8Engine *engine, QObject *object, const QH if (!result) return false; - if (revisionMode == QV8QObjectWrapper::CheckRevision && result->revision != 0) { + if (revisionMode == QV8QObjectWrapper::CheckRevision && result->hasRevision()) { QDeclarativeData *ddata = QDeclarativeData::get(object); if (ddata && ddata->propertyCache && !ddata->propertyCache->isAllowedInRevision(result)) return false; -- cgit v1.2.3 From 7fa6fcd30cb4a688eae744cae4abf9f263c16616 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Wed, 22 Feb 2012 18:13:29 +1000 Subject: Avoid unneccessary duplication of string data. Check for the existence of new line characters before trying to replace them. There's some redundancy if the characters are found but for single line strings we avoid the detach in replace. Change-Id: I48ccc614601a6f356b3d2e68f617e112c100bbdd Reviewed-by: Yann Bodson --- src/quick/items/qquicktext.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 28491d8f75..fd8ffe501b 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -305,9 +305,17 @@ void QQuickTextPrivate::updateLayout() formatModifiesFontSize = fontSizeModified; } else { layout.clearAdditionalFormats(); - multilengthEos = text.indexOf(QLatin1Char('\x9c')); - QString tmp = multilengthEos != -1 ? text.mid(0, multilengthEos) : text; - tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); + QString tmp = text; + multilengthEos = tmp.indexOf(QLatin1Char('\x9c')); + if (multilengthEos != -1) { + tmp = tmp.mid(0, multilengthEos); + tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); + } else if (tmp.contains(QLatin1Char('\n'))) { + // Replace always does a detach. Checking for the new line character first + // means iterating over those items again if found but prevents a realloc + // otherwise. + tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); + } layout.setText(tmp); } textHasChanged = false; -- cgit v1.2.3 From 4e0e0e5cc59a0e5379dcc1964976288d3c3e1b82 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 23 Feb 2012 13:25:58 +1000 Subject: Don't round Text dimensions. Painting issues in QtQuick1 meant drawing had to be aligned to pixel boundaries, since this is no longer a problem we should use qreal everywhere. Change-Id: I58e88e10270fa603170f1cedf471bfb53bd89b73 Reviewed-by: Yann Bodson --- src/quick/items/qquicktext.cpp | 37 +++++++++++----------- src/quick/items/qquicktext_p_p.h | 6 ++-- .../qquicktext/data/multilengthStrings.qml | 2 +- .../qquicktext/data/multilengthStringsWrapped.qml | 2 +- tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 8 ++--- 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index fd8ffe501b..656440f2d3 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -386,7 +386,7 @@ void QQuickTextPrivate::updateSize() return; } - QFontMetrics fm(font); + QFontMetricsF fm(font); if (text.isEmpty()) { qreal fontHeight = fm.height(); q->setImplicitSize(0, fontHeight); @@ -399,16 +399,16 @@ void QQuickTextPrivate::updateSize() qreal naturalWidth = 0; - int dy = q->height(); - QSize size(0, 0); - QSize previousSize = layedOutTextRect.size(); + qreal dy = q->height(); + QSizeF size(0, 0); + QSizeF previousSize = layedOutTextRect.size(); #if defined(Q_OS_MAC) layoutThread = QThread::currentThread(); #endif //setup instance of QTextLayout for all cases other than richtext if (!richText) { - QRect textRect = setupTextLayout(&naturalWidth); + QRectF textRect = setupTextLayout(&naturalWidth); layedOutTextRect = textRect; size = textRect.size(); dy -= size.height(); @@ -436,12 +436,12 @@ void QQuickTextPrivate::updateSize() doc->setTextWidth(q->width()); else doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) - dy -= (int)doc->size().height(); - QSize dsize = doc->size().toSize(); - layedOutTextRect = QRect(QPoint(0,0), dsize); - size = QSize(int(doc->idealWidth()),dsize.height()); + dy -= doc->size().height(); + QSizeF dsize = doc->size(); + layedOutTextRect = QRectF(QPointF(0,0), dsize); + size = QSizeF(doc->idealWidth(),dsize.height()); } - int yoff = 0; + qreal yoff = 0; if (q->heightValid()) { if (vAlign == QQuickText::AlignBottom) @@ -601,13 +601,13 @@ void QQuickTextPrivate::setupCustomLineGeometry(QTextLine &line, qreal &height, #endif } -QString QQuickTextPrivate::elidedText(int lineWidth, const QTextLine &line, QTextLine *nextLine) const +QString QQuickTextPrivate::elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine) const { if (nextLine) { nextLine->setLineWidth(INT_MAX); return layout.engine()->elidedText( Qt::TextElideMode(elideMode), - lineWidth, + QFixed::fromReal(lineWidth), 0, line.textStart(), line.textLength() + nextLine->textLength()); @@ -630,7 +630,7 @@ QString QQuickTextPrivate::elidedText(int lineWidth, const QTextLine &line, QTex already absolutely positioned horizontally). */ -QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) +QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) { Q_Q(QQuickText); layout.setCacheEnabled(true); @@ -673,8 +673,9 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) return QRect(0, 0, 0, height); } - const int lineWidth = q->widthValid() ? q->width() : INT_MAX; + const qreal lineWidth = q->widthValid() ? q->width() : FLT_MAX; const qreal maxHeight = q->heightValid() ? q->height() : FLT_MAX; + const bool customLayout = isLineLaidOutConnected(); const bool wasTruncated = truncated; @@ -783,7 +784,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) height = preLayoutHeight; elideText = layout.engine()->elidedText( Qt::TextElideMode(elideMode), - lineWidth, + QFixed::fromReal(lineWidth), 0, line.textStart(), line.textLength()); @@ -941,7 +942,7 @@ QRect QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) if (truncated != wasTruncated) emit q->truncatedChanged(); - return QRect(qRound(br.x()), qRound(br.y()), qCeil(br.width()), qCeil(br.height())); + return br; } void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height) @@ -1897,7 +1898,7 @@ QRectF QQuickText::boundingRect() const { Q_D(const QQuickText); - QRect rect = d->layedOutTextRect; + QRectF rect = d->layedOutTextRect; if (d->style != Normal) rect.adjust(-1, 0, 1, 2); @@ -1915,7 +1916,7 @@ QRectF QQuickText::boundingRect() const break; } - return QRectF(rect); + return rect; } /*! \internal */ diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h index e060cc1cd2..d0770e6962 100644 --- a/src/quick/items/qquicktext_p_p.h +++ b/src/quick/items/qquicktext_p_p.h @@ -82,9 +82,9 @@ public: QTextDocument *textDocument(); bool isLineLaidOutConnected(); void setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height); - QString elidedText(int lineWidth, const QTextLine &line, QTextLine *nextLine = 0) const; + QString elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine = 0) const; - QRect layedOutTextRect; + QRectF layedOutTextRect; qreal lineHeight; @@ -156,7 +156,7 @@ public: void ensureDoc(); - QRect setupTextLayout(qreal *const naturalWidth); + QRectF setupTextLayout(qreal *const naturalWidth); void setupCustomLineGeometry(QTextLine &line, qreal &height, int lineOffset = 0); bool isLinkActivatedConnected(); QString anchorAt(const QPointF &pos); diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml b/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml index d26576eacd..6b9dc71fbc 100644 --- a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml +++ b/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml @@ -7,7 +7,7 @@ Item { Text { id: myText objectName: "myText" - width: 100 + width: 60 font.pixelSize: 15 font.family: "Helvetica" } diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml b/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml index 0da9bc353a..21f1b20619 100644 --- a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml +++ b/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml @@ -7,7 +7,7 @@ Item { Text { id: myText objectName: "myText" - width: 100 + width: 60 height: 36 font.pixelSize: 15 font.family: "Helvetica" diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index c28de8b53c..5f13f6211d 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -295,11 +295,10 @@ void tst_qquicktext::width() layout.endLayout(); - metricWidth = qCeil(layout.boundingRect().width()); + metricWidth = layout.boundingRect().width(); } else { QFontMetricsF fm(f); - qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); - metricWidth = qCeil(metricWidth); + metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); } QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }"; @@ -2422,9 +2421,6 @@ void tst_qquicktext::multilengthStrings() QCOMPARE(myText->contentWidth(), mediumWidth); QCOMPARE(myText->contentHeight(), mediumHeight); -#ifdef Q_OS_MAC - QEXPECT_FAIL("Wrap", "QTBUG-24310", Continue); -#endif QCOMPARE(myText->truncated(), true); myText->setSize(QSizeF(shortWidth, shortHeight)); -- cgit v1.2.3 From 7002ef6142250cfd7edc81f739ddafee7e71bdbf Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 28 Feb 2012 16:49:17 +1000 Subject: Make sure positioners remove change listeners for invisible items. Children that are invisble weren't having their change listeners removed, which showed illegal accesses on destruction in valgrind. Change-Id: Icae798e773168323781e9ab88b3dae6a5aea0952 Reviewed-by: Alan Alpert --- src/quick/items/qquickpositioners.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp index 77d2a360b8..95ee9bfb58 100644 --- a/src/quick/items/qquickpositioners.cpp +++ b/src/quick/items/qquickpositioners.cpp @@ -111,6 +111,8 @@ QQuickBasePositioner::~QQuickBasePositioner() Q_D(QQuickBasePositioner); for (int i = 0; i < positionedItems.count(); ++i) d->unwatchChanges(positionedItems.at(i).item); + for (int i = 0; i < unpositionedItems.count(); ++i) + d->unwatchChanges(unpositionedItems.at(i).item); positionedItems.clear(); } @@ -187,6 +189,9 @@ void QQuickBasePositioner::itemChange(ItemChange change, const ItemChangeData &v if (idx >= 0) { d->unwatchChanges(child); positionedItems.remove(idx); + } else if ((idx = unpositionedItems.find(posItem)) >= 0) { + d->unwatchChanges(child); + unpositionedItems.remove(idx); } d->setPositioningDirty(); } -- cgit v1.2.3 From 38722cae7bd5c8b853427dd74d1d5e680df302e8 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 28 Feb 2012 17:09:14 +1000 Subject: Fix particle system on windows To preserve correctness, just use a non-point-sprite performance level on windows until QTBUG-24540 is resolved. Change-Id: I7608fbe21233534fb22c9d352aafae759e68c143 Reviewed-by: Martin Jones --- src/quick/particles/qquickimageparticle.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/quick/particles/qquickimageparticle.cpp b/src/quick/particles/qquickimageparticle.cpp index 83687ae234..562a6c5dc7 100644 --- a/src/quick/particles/qquickimageparticle.cpp +++ b/src/quick/particles/qquickimageparticle.cpp @@ -1342,6 +1342,10 @@ void QQuickImageParticle::finishBuildParticleNodes() } } } +#ifdef Q_OS_WIN + if (perfLevel < Deformable) //QTBUG-24540 , point sprite 'extension' isn't working on windows. + perfLevel = Deformable; +#endif if (perfLevel >= Colored && !m_color.isValid()) m_color = QColor(Qt::white);//Hidden default, but different from unset -- cgit v1.2.3 From 82a2faadb83d74fec82c7ade443e64558670f3a7 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 7 Feb 2012 13:29:58 +0100 Subject: QFastMetaBuilder: Generate revision 6 meta-objects Support for old meta-object revisions (<= 6) will be dropped in Qt5. The first, simple step towards revision 7 is to move from rev 4 to 6. Also avoid copy/paste of the flags/types defined in qmetaobject_p.h (in preparation of porting to revision 7). Change-Id: I8ec3ad0811295528303abb5cce86011fc869ec30 Reviewed-by: Aaron Kennedy --- src/declarative/qml/ftw/qfastmetabuilder.cpp | 64 ++-------------------------- 1 file changed, 4 insertions(+), 60 deletions(-) diff --git a/src/declarative/qml/ftw/qfastmetabuilder.cpp b/src/declarative/qml/ftw/qfastmetabuilder.cpp index 0395ab3309..327ed861f6 100644 --- a/src/declarative/qml/ftw/qfastmetabuilder.cpp +++ b/src/declarative/qml/ftw/qfastmetabuilder.cpp @@ -42,6 +42,8 @@ #include "qfastmetabuilder_p.h" #include +#include +#include QT_BEGIN_NAMESPACE @@ -50,65 +52,6 @@ struct QFastMetaBuilderHeader int fieldCount; }; -struct QMetaObjectPrivate -{ - int revision; - int className; - int classInfoCount, classInfoData; - int methodCount, methodData; - int propertyCount, propertyData; - int enumeratorCount, enumeratorData; - int constructorCount, constructorData; //since revision 2 - int flags; //since revision 3 - int signalCount; //since revision 4 -}; - -enum MetaObjectFlag { - DynamicMetaObject = 0x01 -}; - -enum PropertyFlags { - Invalid = 0x00000000, - Readable = 0x00000001, - Writable = 0x00000002, - Resettable = 0x00000004, - EnumOrFlag = 0x00000008, - StdCppSet = 0x00000100, -// Override = 0x00000200, - Constant = 0x00000400, - Final = 0x00000800, - Designable = 0x00001000, - ResolveDesignable = 0x00002000, - Scriptable = 0x00004000, - ResolveScriptable = 0x00008000, - Stored = 0x00010000, - ResolveStored = 0x00020000, - Editable = 0x00040000, - ResolveEditable = 0x00080000, - User = 0x00100000, - ResolveUser = 0x00200000, - Notify = 0x00400000, - Revisioned = 0x00800000 -}; - -enum MethodFlags { - AccessPrivate = 0x00, - AccessProtected = 0x01, - AccessPublic = 0x02, - AccessMask = 0x03, //mask - - MethodMethod = 0x00, - MethodSignal = 0x04, - MethodSlot = 0x08, - MethodConstructor = 0x0c, - MethodTypeMask = 0x0c, - - MethodCompatibility = 0x10, - MethodCloned = 0x20, - MethodScriptable = 0x40, - MethodRevisioned = 0x80 -}; - #define FMBHEADER_FIELD_COUNT 1 #define HEADER_FIELD_COUNT 14 @@ -175,7 +118,7 @@ QFastMetaBuilder::StringRef QFastMetaBuilder::init(int classNameLength, int dataIndex = HEADER_FIELD_COUNT; - p->revision = 4; + p->revision = 6; p->className = 0; // Class infos @@ -364,6 +307,7 @@ void QFastMetaBuilder::fromData(QMetaObject *output, const QMetaObject *parent, output->d.superdata = parent; output->d.stringdata = data.constData() + header(data)->fieldCount * sizeof(uint); output->d.data = fieldPointer(data); + output->d.extradata = 0; } QT_END_NAMESPACE -- cgit v1.2.3 From 9593df26c4a87130947dbdacf5ddb2f7a3412cbc Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Mon, 20 Feb 2012 14:56:12 +0100 Subject: FolderListModel: remove widget and QDirModel use FolderListModel used the obsolete QDirModel internally. Because of this it needed widgets to work. I have made a threaded model instead that use QDir internally. Change-Id: Ibd1267a135ee3c6df7bcde420073866b7a76d0d1 Reviewed-by: Alan Alpert --- src/imports/folderlistmodel/fileinfothread.cpp | 280 ++++++++++++ src/imports/folderlistmodel/fileinfothread_p.h | 107 +++++ src/imports/folderlistmodel/fileproperty_p.h | 94 ++++ src/imports/folderlistmodel/folderlistmodel.pro | 9 +- .../qdeclarativefolderlistmodel.cpp | 494 ++++++++++++++------- .../folderlistmodel/qdeclarativefolderlistmodel.h | 60 +-- .../tst_qdeclarativefolderlistmodel.cpp | 4 +- 7 files changed, 855 insertions(+), 193 deletions(-) create mode 100644 src/imports/folderlistmodel/fileinfothread.cpp create mode 100644 src/imports/folderlistmodel/fileinfothread_p.h create mode 100644 src/imports/folderlistmodel/fileproperty_p.h diff --git a/src/imports/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp new file mode 100644 index 0000000000..3c4d60bb89 --- /dev/null +++ b/src/imports/folderlistmodel/fileinfothread.cpp @@ -0,0 +1,280 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "fileinfothread_p.h" +#include + +#include + + +FileInfoThread::FileInfoThread(QObject *parent) + : QThread(parent), + abort(false), + watcher(0), + sortFlags(QDir::Name), + needUpdate(true), + folderUpdate(false), + sortUpdate(false), + showDirs(true), + showDirsFirst(false), + showDotDot(false), + showOnlyReadable(false) +{ + watcher = new QFileSystemWatcher(this); + connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(dirChanged(QString))); + connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(updateFile(QString))); + start(LowPriority); +} + +FileInfoThread::~FileInfoThread() +{ + QMutexLocker locker(&mutex); + abort = true; + condition.wakeOne(); + locker.unlock(); + wait(); +} + +void FileInfoThread::clear() +{ + QMutexLocker locker(&mutex); + watcher->removePaths(watcher->files()); + watcher->removePaths(watcher->directories()); +} + +void FileInfoThread::removePath(const QString &path) +{ + QMutexLocker locker(&mutex); + watcher->removePath(path); + currentPath.clear(); +} + +void FileInfoThread::setPath(const QString &path) +{ + Q_ASSERT(!path.isEmpty()); + + QMutexLocker locker(&mutex); + watcher->addPath(path); + currentPath = path; + needUpdate = true; + condition.wakeAll(); +} + +void FileInfoThread::setRootPath(const QString &path) +{ + Q_ASSERT(!path.isEmpty()); + + QMutexLocker locker(&mutex); + rootPath = path; +} + +void FileInfoThread::dirChanged(const QString &directoryPath) +{ + Q_UNUSED(directoryPath); + QMutexLocker locker(&mutex); + folderUpdate = true; + condition.wakeAll(); +} + +void FileInfoThread::setSortFlags(QDir::SortFlags flags) +{ + QMutexLocker locker(&mutex); + sortFlags = flags; + sortUpdate = true; + condition.wakeAll(); +} + +void FileInfoThread::setNameFilters(const QStringList & filters) +{ + QMutexLocker locker(&mutex); + nameFilters = filters; + folderUpdate = true; + condition.wakeAll(); +} + +void FileInfoThread::setShowDirs(bool showFolders) +{ + QMutexLocker locker(&mutex); + showDirs = showFolders; + folderUpdate = true; + condition.wakeAll(); +} + +void FileInfoThread::setShowDirsFirst(bool showDirsFirst) +{ + QMutexLocker locker(&mutex); + showDirsFirst = showDirsFirst; + folderUpdate = true; + condition.wakeAll(); +} + +void FileInfoThread::setShowDotDot(bool on) +{ + QMutexLocker locker(&mutex); + showDotDot = on; + folderUpdate = true; + condition.wakeAll(); +} + +void FileInfoThread::setShowOnlyReadable(bool on) +{ + QMutexLocker locker(&mutex); + showOnlyReadable = on; + folderUpdate = true; + condition.wakeAll(); +} + +void FileInfoThread::updateFile(const QString &path) +{ + Q_UNUSED(path); + QMutexLocker locker(&mutex); + folderUpdate = true; + condition.wakeAll(); +} + +void FileInfoThread::run() +{ + forever { + bool updateFiles = false; + QMutexLocker locker(&mutex); + if (abort) { + return; + } + if (currentPath.isEmpty() || !needUpdate) + condition.wait(&mutex); + + if (abort) { + return; + } + + if (!currentPath.isEmpty()) { + updateFiles = true; + } + if (updateFiles) + getFileInfos(currentPath); + locker.unlock(); + } +} + + +void FileInfoThread::getFileInfos(const QString &path) +{ + QDir::Filters filter; + filter = QDir::Files | QDir::NoDot | QDir::CaseSensitive; + if (showDirs) + filter = filter | QDir::AllDirs | QDir::Drives; + if ((path == rootPath) || !showDotDot) + filter = filter | QDir::NoDotDot; + if (showOnlyReadable) + filter = filter | QDir::Readable; + if (showDirsFirst) + sortFlags = sortFlags | QDir::DirsFirst; + + QDir currentDir(path, QString(), sortFlags); + QFileInfoList fileInfoList; + QList filePropertyList; + + fileInfoList = currentDir.entryInfoList(nameFilters, filter, sortFlags); + + if (!fileInfoList.isEmpty()) { + foreach (QFileInfo info, fileInfoList) { + //qDebug() << "Adding file : " << info.fileName() << "to list "; + filePropertyList << FileProperty(info); + } + if (folderUpdate) { + int fromIndex = 0; + int toIndex = currentFileList.size()-1; + findChangeRange(filePropertyList, fromIndex, toIndex); + folderUpdate = false; + currentFileList = filePropertyList; + //qDebug() << "emit directoryUpdated : " << fromIndex << " " << toIndex; + emit directoryUpdated(path, filePropertyList, fromIndex, toIndex); + } else { + currentFileList = filePropertyList; + if (sortUpdate) { + emit sortFinished(filePropertyList); + sortUpdate = false; + } else + emit directoryChanged(path, filePropertyList); + } + } else { + // The directory is empty + if (folderUpdate) { + int fromIndex = 0; + int toIndex = currentFileList.size()-1; + folderUpdate = false; + currentFileList.clear(); + emit directoryUpdated(path, filePropertyList, fromIndex, toIndex); + } else { + currentFileList.clear(); + emit directoryChanged(path, filePropertyList); + } + } + needUpdate = false; +} + +void FileInfoThread::findChangeRange(const QList &list, int &fromIndex, int &toIndex) +{ + if (currentFileList.size() == 0) { + fromIndex = 0; + toIndex = list.size(); + return; + } + + int i; + int listSize = list.size() < currentFileList.size() ? list.size() : currentFileList.size(); + bool changeFound = false; + + for (i=0; i < listSize; i++) { + if (list.at(i) != currentFileList.at(i)) { + changeFound = true; + break; + } + } + + if (changeFound) + fromIndex = i; + else + fromIndex = i-1; + + // For now I let the rest of the list be updated.. + toIndex = list.size() > currentFileList.size() ? list.size() - 1 : currentFileList.size() - 1; +} diff --git a/src/imports/folderlistmodel/fileinfothread_p.h b/src/imports/folderlistmodel/fileinfothread_p.h new file mode 100644 index 0000000000..a5be6e6fcc --- /dev/null +++ b/src/imports/folderlistmodel/fileinfothread_p.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FILEINFOTHREAD_P_H +#define FILEINFOTHREAD_P_H + +#include +#include +#include +#include +#include +#include + +#include "fileproperty_p.h" + +class FileInfoThread : public QThread +{ + Q_OBJECT + +Q_SIGNALS: + void directoryChanged(const QString &directory, const QList &list) const; + void directoryUpdated(const QString &directory, const QList &list, int fromIndex, int toIndex) const; + void sortFinished(const QList &list) const; + +public: + FileInfoThread(QObject *parent = 0); + ~FileInfoThread(); + + void clear(); + void removePath(const QString &path); + void setPath(const QString &path); + void setRootPath(const QString &path); + void setSortFlags(QDir::SortFlags flags); + void setNameFilters(const QStringList & nameFilters); + void setShowDirs(bool showFolders); + void setShowDirsFirst(bool showDirsFirst); + void setShowDotDot(bool on); + void setShowOnlyReadable(bool on); + +public Q_SLOTS: + void dirChanged(const QString &directoryPath); + void updateFile(const QString &path); + +protected: + void run(); + void getFileInfos(const QString &path); + void findChangeRange(const QList &list, int &fromIndex, int &toIndex); + +private: + QMutex mutex; + QWaitCondition condition; + volatile bool abort; + + QFileSystemWatcher *watcher; + QList currentFileList; + QDir::SortFlags sortFlags; + QString currentPath; + QString rootPath; + QStringList nameFilters; + bool needUpdate; + bool folderUpdate; + bool sortUpdate; + bool showDirs; + bool showDirsFirst; + bool showDotDot; + bool showOnlyReadable; +}; + +#endif // FILEINFOTHREAD_P_H diff --git a/src/imports/folderlistmodel/fileproperty_p.h b/src/imports/folderlistmodel/fileproperty_p.h new file mode 100644 index 0000000000..690581a9a3 --- /dev/null +++ b/src/imports/folderlistmodel/fileproperty_p.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FILEPROPERTY_P_H +#define FILEPROPERTY_P_H + +#include +#include + +class FileProperty +{ +public: + FileProperty(const QFileInfo &info) + { + mFileName = info.fileName(); + mFilePath = info.filePath(); + mBaseName = info.baseName(); + mSize = info.size(); + mSuffix = info.completeSuffix(); + mIsDir = info.isDir(); + mIsFile = info.isFile(); + mLastModified = info.lastModified(); + mLastRead = info.lastRead(); + } + ~FileProperty() + {} + + inline QString fileName() const { return mFileName; } + inline QString filePath() const { return mFilePath; } + inline QString baseName() const { return mBaseName; } + inline qint64 size() const { return mSize; } + inline QString suffix() const { return mSuffix; } + inline bool isDir() const { return mIsDir; } + inline bool isFile() const { return mIsFile; } + inline QDateTime lastModified() const { return mLastModified; } + inline QDateTime lastRead() const { return mLastRead; } + + inline bool operator !=(const FileProperty &fileInfo) const { + return !operator==(fileInfo); + } + bool operator ==(const FileProperty &property) const { + return ((mFileName == property.mFileName) && (isDir() == property.isDir())); + } + +private: + QString mFileName; + QString mFilePath; + QString mBaseName; + QString mSuffix; + qint64 mSize; + bool mIsDir; + bool mIsFile; + QDateTime mLastModified; + QDateTime mLastRead; +}; +#endif // FILEPROPERTY_P_H diff --git a/src/imports/folderlistmodel/folderlistmodel.pro b/src/imports/folderlistmodel/folderlistmodel.pro index 26efc654b8..9727b513e6 100644 --- a/src/imports/folderlistmodel/folderlistmodel.pro +++ b/src/imports/folderlistmodel/folderlistmodel.pro @@ -2,10 +2,13 @@ TARGET = qmlfolderlistmodelplugin TARGETPATH = Qt/labs/folderlistmodel include(../qimportbase.pri) -QT += widgets declarative +QT += declarative -SOURCES += qdeclarativefolderlistmodel.cpp plugin.cpp -HEADERS += qdeclarativefolderlistmodel.h +SOURCES += qdeclarativefolderlistmodel.cpp plugin.cpp \ + fileinfothread.cpp +HEADERS += qdeclarativefolderlistmodel.h \ + fileproperty_p.h \ + fileinfothread_p.h DESTDIR = $$QT.declarative.imports/$$TARGETPATH target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp index 870479afad..fa1a181e1f 100644 --- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp @@ -41,25 +41,71 @@ //![code] #include "qdeclarativefolderlistmodel.h" -#include +#include "fileinfothread_p.h" +#include "fileproperty_p.h" #include #include -#ifndef QT_NO_DIRMODEL - QT_BEGIN_NAMESPACE class QDeclarativeFolderListModelPrivate { + Q_DECLARE_PUBLIC(QDeclarativeFolderListModel) + public: - QDeclarativeFolderListModelPrivate() - : sortField(QDeclarativeFolderListModel::Name), sortReversed(false), count(0), showDirs(true), showDots(false), showOnlyReadable(false), insideRefresh(false) { + QDeclarativeFolderListModelPrivate(QDeclarativeFolderListModel *q) + : q_ptr(q), + sortField(QDeclarativeFolderListModel::Name), sortReversed(false), showDirs(true), showDirsFirst(false), showDots(false), showOnlyReadable(false) + { nameFilters << QLatin1String("*"); } - void updateSorting() { - QDir::SortFlags flags = 0; - switch(sortField) { + + QDeclarativeFolderListModel *q_ptr; + QUrl currentDir; + QUrl rootDir; + FileInfoThread fileInfoThread; + QList data; + QHash roleNames; + QDeclarativeFolderListModel::SortField sortField; + QStringList nameFilters; + bool sortReversed; + bool showDirs; + bool showDirsFirst; + bool showDots; + bool showOnlyReadable; + + ~QDeclarativeFolderListModelPrivate() {} + void init(); + void updateSorting(); + + // private slots + void _q_directoryChanged(const QString &directory, const QList &list); + void _q_directoryUpdated(const QString &directory, const QList &list, int fromIndex, int toIndex); + void _q_sortFinished(const QList &list); +}; + + +void QDeclarativeFolderListModelPrivate::init() +{ + Q_Q(QDeclarativeFolderListModel); + qRegisterMetaType >("QList"); + q->connect(&fileInfoThread, SIGNAL(directoryChanged(QString, QList)), + q, SLOT(_q_directoryChanged(QString, QList))); + q->connect(&fileInfoThread, SIGNAL(directoryUpdated(QString, QList, int, int)), + q, SLOT(_q_directoryUpdated(QString, QList, int, int))); + q->connect(&fileInfoThread, SIGNAL(sortFinished(QList)), + q, SLOT(_q_sortFinished(QList))); +} + + +void QDeclarativeFolderListModelPrivate::updateSorting() +{ + Q_Q(QDeclarativeFolderListModel); + + QDir::SortFlags flags = 0; + + switch (sortField) { case QDeclarativeFolderListModel::Unsorted: flags |= QDir::Unsorted; break; @@ -75,26 +121,80 @@ public: case QDeclarativeFolderListModel::Type: flags |= QDir::Type; break; - } + default: + break; + } + + emit q->layoutAboutToBeChanged(); + + if (sortReversed) + flags |= QDir::Reversed; + + fileInfoThread.setSortFlags(flags); +} + +void QDeclarativeFolderListModelPrivate::_q_directoryChanged(const QString &directory, const QList &list) +{ + Q_Q(QDeclarativeFolderListModel); + Q_UNUSED(directory); + + data = list; + q->endResetModel(); + emit q->rowCountChanged(); + emit q->folderChanged(); +} - if (sortReversed) - flags |= QDir::Reversed; - model.setSorting(flags); +void QDeclarativeFolderListModelPrivate::_q_directoryUpdated(const QString &directory, const QList &list, int fromIndex, int toIndex) +{ + Q_Q(QDeclarativeFolderListModel); + Q_UNUSED(directory); + + QModelIndex parent; + if (data.size() > list.size()) { + //File(s) removed. Since I do not know how many + //or where I need to update the whole list from the first item. + data = list; + q->beginRemoveRows(parent, fromIndex, toIndex); + q->endRemoveRows(); + q->beginInsertRows(parent, fromIndex, list.size()-1); + q->endInsertRows(); + emit q->rowCountChanged(); + } else if (data.size() < list.size()) { + //qDebug() << "File added. FromIndex: " << fromIndex << " toIndex: " << toIndex << " list size: " << list.size(); + //File(s) added. Calculate how many and insert + //from the first changed one. + toIndex = fromIndex + (list.size() - data.size()-1); + q->beginInsertRows(parent, fromIndex, toIndex); + q->endInsertRows(); + data = list; + emit q->rowCountChanged(); + QModelIndex modelIndexFrom = q->createIndex(fromIndex, 0); + QModelIndex modelIndexTo = q->createIndex(toIndex, 0); + emit q->dataChanged(modelIndexFrom, modelIndexTo); + } else { + //qDebug() << "File has been updated"; + QModelIndex modelIndexFrom = q->createIndex(fromIndex, 0); + QModelIndex modelIndexTo = q->createIndex(toIndex, 0); + data = list; + emit q->dataChanged(modelIndexFrom, modelIndexTo); } +} + +void QDeclarativeFolderListModelPrivate::_q_sortFinished(const QList &list) +{ + Q_Q(QDeclarativeFolderListModel); + + QModelIndex parent; + q->beginRemoveRows(parent, 0, data.size()-1); + data.clear(); + q->endRemoveRows(); + + q->beginInsertRows(parent, 0, list.size()-1); + data = list; + q->endInsertRows(); +} - QDirModel model; - QUrl folder; - QStringList nameFilters; - QModelIndex folderIndex; - QDeclarativeFolderListModel::SortField sortField; - bool sortReversed; - int count; - bool showDirs; - bool showDots; - bool showOnlyReadable; - bool insideRefresh; -}; /*! \qmlclass FolderListModel QDeclarativeFolderListModel @@ -115,8 +215,14 @@ public: Components access names and paths via the following roles: \list - \o fileName - \o filePath + \o \c fileName + \o \c filePath + \o \c fileBaseName + \o \c fileSuffix + \o \c fileSize + \o \c fileModified + \o \c fileAccessed + \o \c fileIsDir \endlist Additionally a file entry can be differentiated from a folder entry via the @@ -157,39 +263,62 @@ public: */ QDeclarativeFolderListModel::QDeclarativeFolderListModel(QObject *parent) - : QAbstractListModel(parent) + : QAbstractListModel(parent), d_ptr(new QDeclarativeFolderListModelPrivate(this)) { - QHash roles; - roles[FileNameRole] = "fileName"; - roles[FilePathRole] = "filePath"; - setRoleNames(roles); - - d = new QDeclarativeFolderListModelPrivate; - d->model.setFilter(QDir::AllDirs | QDir::Files | QDir::Drives | QDir::NoDotAndDotDot); - connect(&d->model, SIGNAL(rowsInserted(const QModelIndex&,int,int)) - , this, SLOT(inserted(const QModelIndex&,int,int))); - connect(&d->model, SIGNAL(rowsRemoved(const QModelIndex&,int,int)) - , this, SLOT(removed(const QModelIndex&,int,int))); - connect(&d->model, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)) - , this, SLOT(handleDataChanged(const QModelIndex&,const QModelIndex&))); - connect(&d->model, SIGNAL(modelReset()), this, SLOT(refresh())); - connect(&d->model, SIGNAL(layoutChanged()), this, SLOT(refresh())); + Q_D(QDeclarativeFolderListModel); + d->roleNames[FileNameRole] = "fileName"; + d->roleNames[FilePathRole] = "filePath"; + d->roleNames[FileBaseNameRole] = "fileBaseName"; + d->roleNames[FileSuffixRole] = "fileSuffix"; + d->roleNames[FileSizeRole] = "fileSize"; + d->roleNames[FileLastModifiedRole] = "fileModified"; + d->roleNames[FileLastReadRole] = "fileAccessed"; + d->roleNames[FileIsDirRole] = "fileIsDir"; + setRoleNames(d->roleNames); + + d->init(); } QDeclarativeFolderListModel::~QDeclarativeFolderListModel() { - delete d; } QVariant QDeclarativeFolderListModel::data(const QModelIndex &index, int role) const { + Q_D(const QDeclarativeFolderListModel); QVariant rv; - QModelIndex modelIndex = d->model.index(index.row(), 0, d->folderIndex); - if (modelIndex.isValid()) { - if (role == FileNameRole) - rv = d->model.data(modelIndex, QDirModel::FileNameRole).toString(); - else if (role == FilePathRole) - rv = QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString()); + + if (index.row() >= d->data.size()) + return rv; + + switch (role) + { + case FileNameRole: + rv = d->data.at(index.row()).fileName(); + break; + case FilePathRole: + rv = d->data.at(index.row()).filePath(); + break; + case FileBaseNameRole: + rv = d->data.at(index.row()).baseName(); + break; + case FileSuffixRole: + rv = d->data.at(index.row()).suffix(); + break; + case FileSizeRole: + rv = d->data.at(index.row()).size(); + break; + case FileLastModifiedRole: + rv = d->data.at(index.row()).lastModified().date().toString(Qt::ISODate) + " " + d->data.at(index.row()).lastModified().time().toString(); + break; + case FileLastReadRole: + rv = d->data.at(index.row()).lastRead().date().toString(Qt::ISODate) + " " + d->data.at(index.row()).lastRead().time().toString(); + break; + case FileIsDirRole: + rv = d->data.at(index.row()).isDir(); + break; + default: + break; } return rv; } @@ -202,8 +331,14 @@ QVariant QDeclarativeFolderListModel::data(const QModelIndex &index, int role) c */ int QDeclarativeFolderListModel::rowCount(const QModelIndex &parent) const { + Q_D(const QDeclarativeFolderListModel); Q_UNUSED(parent); - return d->count; + return d->data.size(); +} + +QModelIndex QDeclarativeFolderListModel::index(int row, int , const QModelIndex &) const +{ + return createIndex(row, 0); } /*! @@ -219,46 +354,70 @@ int QDeclarativeFolderListModel::rowCount(const QModelIndex &parent) const */ QUrl QDeclarativeFolderListModel::folder() const { - return d->folder; + Q_D(const QDeclarativeFolderListModel); + return d->currentDir; } void QDeclarativeFolderListModel::setFolder(const QUrl &folder) { - if (folder == d->folder) + Q_D(QDeclarativeFolderListModel); + + if (folder == d->currentDir) return; - QModelIndex index = d->model.index(folder.toLocalFile()); // This can modify the filtering rules. - if ((index.isValid() && d->model.isDir(index)) || folder.toLocalFile().isEmpty()) { - d->folder = folder; - QMetaObject::invokeMethod(this, "resetFiltering", Qt::QueuedConnection); // resetFiltering will invoke refresh(). - emit folderChanged(); + QString resolvedPath = QDir::cleanPath(folder.path()); + + beginResetModel(); + + //Remove the old path for the file system watcher + if (!d->currentDir.isEmpty()) + d->fileInfoThread.removePath(d->currentDir.path()); + + d->currentDir = folder; + + QFileInfo info(resolvedPath); + if (!info.exists() || !info.isDir()) { + d->data.clear(); + endResetModel(); + emit rowCountChanged(); + return; } + + d->fileInfoThread.setPath(resolvedPath); +} + + +/*! + \qmlproperty string QDeclarativeFolderListModel::rootFolder + + When the rootFolder is set, then this folder will + be threated as the root in the file system, so that + you can only travers sub folders from this rootFolder. +*/ +QUrl QDeclarativeFolderListModel::rootFolder() const +{ + Q_D(const QDeclarativeFolderListModel); + return d->rootDir; } -void QDeclarativeFolderListModel::resetFiltering() +void QDeclarativeFolderListModel::setRootFolder(const QUrl &path) { - // ensure that we reset the filtering rules, because the QDirModel::index() - // function isn't quite as const as it claims to be. - QDir::Filters filt = d->model.filter(); + Q_D(QDeclarativeFolderListModel); - if (d->showDirs) - filt |= (QDir::AllDirs | QDir::Drives); - else - filt &= ~(QDir::AllDirs | QDir::Drives); + if (path.isEmpty()) + return; - if (d->showDots) - filt &= ~QDir::NoDotAndDotDot; - else - filt |= QDir::NoDotAndDotDot; + QString resolvedPath = QDir::cleanPath(path.path()); - if (d->showOnlyReadable) - filt |= QDir::Readable; - else - filt &= ~QDir::Readable; + QFileInfo info(resolvedPath); + if (!info.exists() || !info.isDir()) + return; - d->model.setFilter(filt); // this causes a refresh(). + d->fileInfoThread.setRootPath(resolvedPath); + d->rootDir = path; } + /*! \qmlproperty url FolderListModel::parentFolder @@ -266,7 +425,9 @@ void QDeclarativeFolderListModel::resetFiltering() */ QUrl QDeclarativeFolderListModel::parentFolder() const { - QString localFile = d->folder.toLocalFile(); + Q_D(const QDeclarativeFolderListModel); + + QString localFile = d->currentDir.toLocalFile(); if (!localFile.isEmpty()) { QDir dir(localFile); #if defined(Q_OS_WIN) @@ -277,10 +438,10 @@ QUrl QDeclarativeFolderListModel::parentFolder() const dir.cdUp(); localFile = dir.path(); } else { - int pos = d->folder.path().lastIndexOf(QLatin1Char('/')); + int pos = d->currentDir.path().lastIndexOf(QLatin1Char('/')); if (pos == -1) return QUrl(); - localFile = d->folder.path().left(pos); + localFile = d->currentDir.path().left(pos); } return QUrl::fromLocalFile(localFile); } @@ -303,13 +464,15 @@ QUrl QDeclarativeFolderListModel::parentFolder() const */ QStringList QDeclarativeFolderListModel::nameFilters() const { + Q_D(const QDeclarativeFolderListModel); return d->nameFilters; } void QDeclarativeFolderListModel::setNameFilters(const QStringList &filters) { + Q_D(QDeclarativeFolderListModel); + d->fileInfoThread.setNameFilters(filters); d->nameFilters = filters; - d->model.setNameFilters(d->nameFilters); } void QDeclarativeFolderListModel::classBegin() @@ -318,11 +481,10 @@ void QDeclarativeFolderListModel::classBegin() void QDeclarativeFolderListModel::componentComplete() { - if (!d->folder.isValid() || d->folder.toLocalFile().isEmpty() || !QDir().exists(d->folder.toLocalFile())) - setFolder(QUrl(QLatin1String("file://")+QDir::currentPath())); + Q_D(QDeclarativeFolderListModel); - if (!d->folderIndex.isValid()) - QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection); + if (!d->currentDir.isValid() || d->currentDir.toLocalFile().isEmpty() || !QDir().exists(d->currentDir.toLocalFile())) + setFolder(QUrl(QLatin1String("file://")+QDir::currentPath())); } /*! @@ -331,9 +493,9 @@ void QDeclarativeFolderListModel::componentComplete() The \a sortField property contains field to use for sorting. sortField may be one of: \list - \o Unsorted - no sorting is applied. The order is system default. + \o Unsorted - no sorting is applied. \o Name - sort by filename - \o Time - sort by time modified + \o LastModified - sort by time modified \o Size - sort by file size \o Type - sort by file type (extension) \endlist @@ -342,17 +504,25 @@ void QDeclarativeFolderListModel::componentComplete() */ QDeclarativeFolderListModel::SortField QDeclarativeFolderListModel::sortField() const { + Q_D(const QDeclarativeFolderListModel); return d->sortField; } void QDeclarativeFolderListModel::setSortField(SortField field) { + Q_D(QDeclarativeFolderListModel); if (field != d->sortField) { d->sortField = field; d->updateSorting(); } } +int QDeclarativeFolderListModel::roleFromString(const QString &roleName) const +{ + Q_D(const QDeclarativeFolderListModel); + return d->roleNames.key(roleName.toLatin1(), -1); +} + /*! \qmlproperty bool FolderListModel::sortReversed @@ -362,11 +532,14 @@ void QDeclarativeFolderListModel::setSortField(SortField field) */ bool QDeclarativeFolderListModel::sortReversed() const { + Q_D(const QDeclarativeFolderListModel); return d->sortReversed; } void QDeclarativeFolderListModel::setSortReversed(bool rev) { + Q_D(QDeclarativeFolderListModel); + if (rev != d->sortReversed) { d->sortReversed = rev; d->updateSorting(); @@ -382,91 +555,66 @@ void QDeclarativeFolderListModel::setSortReversed(bool rev) bool QDeclarativeFolderListModel::isFolder(int index) const { if (index != -1) { - QModelIndex idx = d->model.index(index, 0, d->folderIndex); - if (idx.isValid()) - return d->model.isDir(idx); + QModelIndex idx = createIndex(index, 0); + if (idx.isValid()) { + QVariant var = data(idx, FileIsDirRole); + if (var.isValid()) + return var.toBool(); + } } return false; } -void QDeclarativeFolderListModel::refresh() -{ - if (d->insideRefresh) - return; - d->insideRefresh = true; +/*! + \qmlproperty bool FolderListModel::showDirs - d->folderIndex = QModelIndex(); - if (d->count) { - emit beginRemoveRows(QModelIndex(), 0, d->count-1); - d->count = 0; - emit endRemoveRows(); - } + If true, directories are included in the model; otherwise only files + are included. - d->folderIndex = d->model.index(d->folder.toLocalFile()); - int newcount = d->model.rowCount(d->folderIndex); - if (newcount) { - emit beginInsertRows(QModelIndex(), 0, newcount-1); - d->count = newcount; - emit endInsertRows(); - } + By default, this property is true. - d->insideRefresh = false; // finished refreshing. -} + Note that the nameFilters are not applied to directories. -void QDeclarativeFolderListModel::inserted(const QModelIndex &index, int start, int end) + \sa showDotAndDotDot +*/ +bool QDeclarativeFolderListModel::showDirs() const { - if (index == d->folderIndex) { - emit beginInsertRows(QModelIndex(), start, end); - d->count = d->model.rowCount(d->folderIndex); - emit endInsertRows(); - } + Q_D(const QDeclarativeFolderListModel); + return d->showDirs; } -void QDeclarativeFolderListModel::removed(const QModelIndex &index, int start, int end) +void QDeclarativeFolderListModel::setShowDirs(bool on) { - if (index == d->folderIndex) { - emit beginRemoveRows(QModelIndex(), start, end); - d->count = d->model.rowCount(d->folderIndex); - emit endRemoveRows(); - } -} + Q_D(QDeclarativeFolderListModel); -void QDeclarativeFolderListModel::handleDataChanged(const QModelIndex &start, const QModelIndex &end) -{ - if (start.parent() == d->folderIndex) - emit dataChanged(index(start.row(),0), index(end.row(),0)); + d->fileInfoThread.setShowDirs(on); + d->showDirs = on; } /*! - \qmlproperty bool FolderListModel::showDirs + \qmlproperty bool FolderListModel::showDirsFirst - If true, directories are included in the model; otherwise only files - are included. + If true, if directories are included in the model they will + always be shown first, then the files. - By default, this property is true. - - Note that the nameFilters are not applied to directories. + By default, this property is false. - \sa showDotAndDotDot */ -bool QDeclarativeFolderListModel::showDirs() const +bool QDeclarativeFolderListModel::showDirsFirst() const { - return d->model.filter() & QDir::AllDirs; + Q_D(const QDeclarativeFolderListModel); + return d->showDirsFirst; } -void QDeclarativeFolderListModel::setShowDirs(bool on) +void QDeclarativeFolderListModel::setShowDirsFirst(bool on) { - if (!(d->model.filter() & QDir::AllDirs) == !on) - return; - if (on) { - d->showDirs = true; - d->model.setFilter(d->model.filter() | QDir::AllDirs | QDir::Drives); - } else { - d->showDirs = false; - d->model.setFilter(d->model.filter() & ~(QDir::AllDirs | QDir::Drives)); - } + Q_D(QDeclarativeFolderListModel); + + d->fileInfoThread.setShowDirsFirst(on); + d->showDirsFirst = on; } + /*! \qmlproperty bool FolderListModel::showDotAndDotDot @@ -479,19 +627,16 @@ void QDeclarativeFolderListModel::setShowDirs(bool on) */ bool QDeclarativeFolderListModel::showDotAndDotDot() const { - return !(d->model.filter() & QDir::NoDotAndDotDot); + Q_D(const QDeclarativeFolderListModel); + return d->showDots; } void QDeclarativeFolderListModel::setShowDotAndDotDot(bool on) { - if (!(d->model.filter() & QDir::NoDotAndDotDot) == on) - return; - if (on) { - d->showDots = true; - d->model.setFilter(d->model.filter() & ~QDir::NoDotAndDotDot); - } else { - d->showDots = false; - d->model.setFilter(d->model.filter() | QDir::NoDotAndDotDot); + Q_D(QDeclarativeFolderListModel); + + if (on != d->showDots) { + d->fileInfoThread.setShowDotDot(on); } } @@ -507,23 +652,46 @@ void QDeclarativeFolderListModel::setShowDotAndDotDot(bool on) */ bool QDeclarativeFolderListModel::showOnlyReadable() const { - return d->model.filter() & QDir::Readable; + Q_D(const QDeclarativeFolderListModel); + return d->showOnlyReadable; } void QDeclarativeFolderListModel::setShowOnlyReadable(bool on) { - if (!(d->model.filter() & QDir::Readable) == !on) - return; - if (on) { - d->showOnlyReadable = true; - d->model.setFilter(d->model.filter() | QDir::Readable); - } else { - d->showOnlyReadable = false; - d->model.setFilter(d->model.filter() & ~QDir::Readable); + Q_D(QDeclarativeFolderListModel); + + if (on != d->showOnlyReadable) { + d->fileInfoThread.setShowOnlyReadable(on); } } +/*! + \qmlmethod QVariant QDeclarativeFolderListModel::get(int idx, const QString &property) const + + Get the folder property for the given index. The following properties + are available. + + \list + \o \c fileName + \o \c filePath + \o \c fileBaseName + \o \c fileSuffix + \o \c fileSize + \o \c fileModified + \o \c fileAccessed + \o \c fileIsDir + \endlist +*/ +QVariant QDeclarativeFolderListModel::get(int idx, const QString &property) const +{ + int role = roleFromString(property); + if (role >= 0 && idx >= 0) + return data(index(idx, 0), role); + else + return QVariant(); +} + +#include "moc_qdeclarativefolderlistmodel.cpp" + //![code] QT_END_NAMESPACE - -#endif // QT_NO_DIRMODEL diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h index 5f9cb0e81a..27a7bc00a1 100644 --- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h @@ -47,8 +47,6 @@ #include #include -#ifndef QT_NO_DIRMODEL - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -68,14 +66,16 @@ class QDeclarativeFolderListModel : public QAbstractListModel, public QDeclarati //![class props] Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged) + Q_PROPERTY(QUrl rootFolder READ rootFolder WRITE setRootFolder) Q_PROPERTY(QUrl parentFolder READ parentFolder NOTIFY folderChanged) Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters) Q_PROPERTY(SortField sortField READ sortField WRITE setSortField) Q_PROPERTY(bool sortReversed READ sortReversed WRITE setSortReversed) Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs) + Q_PROPERTY(bool showDirsFirst READ showDirsFirst WRITE setShowDirsFirst) Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot) Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable) - Q_PROPERTY(int count READ count) + Q_PROPERTY(int count READ count NOTIFY rowCountChanged) //![class props] //![abslistmodel] @@ -83,10 +83,20 @@ public: QDeclarativeFolderListModel(QObject *parent = 0); ~QDeclarativeFolderListModel(); - enum Roles { FileNameRole = Qt::UserRole+1, FilePathRole = Qt::UserRole+2 }; - - int rowCount(const QModelIndex &parent) const; - QVariant data(const QModelIndex &index, int role) const; + enum Roles { + FileNameRole = Qt::UserRole + 1, + FilePathRole = Qt::UserRole + 2, + FileBaseNameRole = Qt::UserRole + 3, + FileSuffixRole = Qt::UserRole + 4, + FileSizeRole = Qt::UserRole + 5, + FileLastModifiedRole = Qt::UserRole + 6, + FileLastReadRole = Qt::UserRole +7, + FileIsDirRole = Qt::UserRole + 8 + }; + + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; //![abslistmodel] //![count] @@ -96,6 +106,8 @@ public: //![prop funcs] QUrl folder() const; void setFolder(const QUrl &folder); + QUrl rootFolder() const; + void setRootFolder(const QUrl &path); QUrl parentFolder() const; @@ -111,49 +123,47 @@ public: void setSortReversed(bool rev); bool showDirs() const; - void setShowDirs(bool); + void setShowDirs(bool showDirs); + bool showDirsFirst() const; + void setShowDirsFirst(bool showDirsFirst); bool showDotAndDotDot() const; - void setShowDotAndDotDot(bool); + void setShowDotAndDotDot(bool on); bool showOnlyReadable() const; - void setShowOnlyReadable(bool); + void setShowOnlyReadable(bool on); //![prop funcs] -//![isfolder] Q_INVOKABLE bool isFolder(int index) const; -//![isfolder] + Q_INVOKABLE QVariant get(int idx, const QString &property) const; //![parserstatus] virtual void classBegin(); virtual void componentComplete(); //![parserstatus] + int roleFromString(const QString &roleName) const; + //![notifier] Q_SIGNALS: void folderChanged(); + void rowCountChanged() const; //![notifier] //![class end] -private Q_SLOTS: - void refresh(); - void resetFiltering(); - void inserted(const QModelIndex &index, int start, int end); - void removed(const QModelIndex &index, int start, int end); - void handleDataChanged(const QModelIndex &start, const QModelIndex &end); + private: Q_DISABLE_COPY(QDeclarativeFolderListModel) - QDeclarativeFolderListModelPrivate *d; + Q_DECLARE_PRIVATE(QDeclarativeFolderListModel) + QScopedPointer d_ptr; + + Q_PRIVATE_SLOT(d_func(), void _q_directoryChanged(const QString &directory, const QList &list)) + Q_PRIVATE_SLOT(d_func(), void _q_directoryUpdated(const QString &directory, const QList &list, int fromIndex, int toIndex)) + Q_PRIVATE_SLOT(d_func(), void _q_sortFinished(const QList &list)) }; //![class end] QT_END_NAMESPACE -//![qml decl] -QML_DECLARE_TYPE(QDeclarativeFolderListModel) -//![qml decl] - QT_END_HEADER -#endif // QT_NO_DIRMODEL - #endif // QDECLARATIVEFOLDERLISTMODEL_H diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp index 07eb6e87e1..708f3c90bb 100644 --- a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp @@ -170,8 +170,8 @@ void tst_qdeclarativefolderlistmodel::refresh() flm->setProperty("sortReversed", true); - QCOMPARE(removeStart, 0); - QCOMPARE(removeEnd, count-1); + QTRY_COMPARE(removeStart, 0); + QTRY_COMPARE(removeEnd, count-1); // wait for refresh } QTEST_MAIN(tst_qdeclarativefolderlistmodel) -- cgit v1.2.3 From 648337d19abde0bc1d3f248f11ad4a40890f532f Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 7 Feb 2012 19:37:38 +0100 Subject: Add autotest for QML meta-objects This autotest checks that the QMetaObject generated from a QML type can be introspected from C++ (properties, class info, signals and slots). Change-Id: I9a50f138f911690f5c55cd28e5b49f0682450d07 Reviewed-by: Aaron Kennedy --- tests/auto/declarative/declarative.pro | 1 + .../qdeclarativemetaobject/data/method.1.qml | 5 + .../qdeclarativemetaobject/data/method.2.qml | 5 + .../qdeclarativemetaobject/data/method.3.qml | 5 + .../data/property.MyQmlObject.qml | 6 + .../data/property.QtObject.qml | 5 + .../data/property.alias.2.qml | 6 + .../data/property.alias.3.qml | 7 + .../qdeclarativemetaobject/data/property.alias.qml | 7 + .../qdeclarativemetaobject/data/property.bool.qml | 5 + .../qdeclarativemetaobject/data/property.color.qml | 5 + .../qdeclarativemetaobject/data/property.date.qml | 5 + .../qdeclarativemetaobject/data/property.int.qml | 5 + .../data/property.list.MyQmlObject.qml | 6 + .../data/property.list.QtObject.qml | 5 + .../qdeclarativemetaobject/data/property.real.qml | 5 + .../data/property.string.qml | 5 + .../qdeclarativemetaobject/data/property.url.qml | 5 + .../qdeclarativemetaobject/data/property.var.qml | 5 + .../data/property.variant.qml | 5 + .../qdeclarativemetaobject/data/signal.1.qml | 5 + .../qdeclarativemetaobject/data/signal.2.qml | 5 + .../qdeclarativemetaobject/data/signal.3.qml | 5 + .../qdeclarativemetaobject/data/signal.4.qml | 5 + .../qdeclarativemetaobject/data/signal.5.qml | 5 + .../qdeclarativemetaobject.pro | 14 + .../tst_qdeclarativemetaobject.cpp | 364 +++++++++++++++++++++ 27 files changed, 506 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/method.1.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/method.2.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/method.3.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.MyQmlObject.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.QtObject.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.alias.2.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.alias.3.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.alias.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.bool.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.color.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.date.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.int.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.list.MyQmlObject.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.list.QtObject.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.real.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.string.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.url.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.var.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/property.variant.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/signal.1.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/signal.2.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/signal.3.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/signal.4.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/data/signal.5.qml create mode 100644 tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro create mode 100644 tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 7288da27ba..85de8618e2 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -15,6 +15,7 @@ PUBLICTESTS += \ qdeclarativeinfo \ qdeclarativelistreference \ qdeclarativelocale \ + qdeclarativemetaobject \ qdeclarativemoduleplugin \ qdeclarativeqt \ qdeclarativetranslation \ diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/method.1.qml b/tests/auto/declarative/qdeclarativemetaobject/data/method.1.qml new file mode 100644 index 0000000000..a021881743 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/method.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + function testFunction() { return 19; } +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/method.2.qml b/tests/auto/declarative/qdeclarativemetaobject/data/method.2.qml new file mode 100644 index 0000000000..d514955f47 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/method.2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + function testFunction(foo) { return 19; } +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/method.3.qml b/tests/auto/declarative/qdeclarativemetaobject/data/method.3.qml new file mode 100644 index 0000000000..d6d19758c9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/method.3.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + function testFunction(foo, bar, baz) { return 19; } +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.MyQmlObject.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.MyQmlObject.qml new file mode 100644 index 0000000000..8903bbb3e9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.MyQmlObject.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +QtObject { + property MyQmlObject test: MyQmlObject {} +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.QtObject.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.QtObject.qml new file mode 100644 index 0000000000..20c42b5851 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.QtObject.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property QtObject test: QtObject {} +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.2.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.2.qml new file mode 100644 index 0000000000..cae1ae6696 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.2.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + id: me + property alias test: me +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.3.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.3.qml new file mode 100644 index 0000000000..86422ae367 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.3.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Text { + id: me + font.family: "Arial" + property alias test: me.font.family +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.qml new file mode 100644 index 0000000000..33a4a1c5b0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.alias.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +QtObject { + objectName: "Joe" + id: me + property alias test: me.objectName +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.bool.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.bool.qml new file mode 100644 index 0000000000..9459cb6394 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.bool.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property bool test: true +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.color.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.color.qml new file mode 100644 index 0000000000..7451a27101 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.color.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property color test: "#ff0000" +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.date.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.date.qml new file mode 100644 index 0000000000..05fcb2516c --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.date.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property date test: "2012-02-07" +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.int.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.int.qml new file mode 100644 index 0000000000..ae419d08cb --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.int.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int test: 19 +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.list.MyQmlObject.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.list.MyQmlObject.qml new file mode 100644 index 0000000000..602762cba2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.list.MyQmlObject.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 +import QtQuick 2.0 + +QtObject { + property list test: [ MyQmlObject {} ] +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.list.QtObject.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.list.QtObject.qml new file mode 100644 index 0000000000..e774d70b42 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.list.QtObject.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property list test: [ QtObject {} ] +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.real.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.real.qml new file mode 100644 index 0000000000..de2baf5be2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.real.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property real test: 21 +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.string.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.string.qml new file mode 100644 index 0000000000..2a625c4fe4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.string.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property string test: "dog" +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.url.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.url.qml new file mode 100644 index 0000000000..c820c82515 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.url.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property url test: "http://foo.bar" +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.var.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.var.qml new file mode 100644 index 0000000000..9ea9245317 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.var.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property var test: [5, true, "ciao"] +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/property.variant.qml b/tests/auto/declarative/qdeclarativemetaobject/data/property.variant.qml new file mode 100644 index 0000000000..edffa173c4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/property.variant.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + default property variant test: "12,34" +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.1.qml b/tests/auto/declarative/qdeclarativemetaobject/data/signal.1.qml new file mode 100644 index 0000000000..113130f3cc --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/signal.1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.2.qml b/tests/auto/declarative/qdeclarativemetaobject/data/signal.2.qml new file mode 100644 index 0000000000..db860cc7cd --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/signal.2.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(string foo) +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.3.qml b/tests/auto/declarative/qdeclarativemetaobject/data/signal.3.qml new file mode 100644 index 0000000000..4d04041f8f --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/signal.3.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(int foo, bool bar, real baz) +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.4.qml b/tests/auto/declarative/qdeclarativemetaobject/data/signal.4.qml new file mode 100644 index 0000000000..ad9b002176 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/signal.4.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(variant foo, var bar) +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/data/signal.5.qml b/tests/auto/declarative/qdeclarativemetaobject/data/signal.5.qml new file mode 100644 index 0000000000..b848bb5cb5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/data/signal.5.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + signal testSignal(color foo, date bar, url baz) +} diff --git a/tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro b/tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro new file mode 100644 index 0000000000..206f510506 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/qdeclarativemetaobject.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qdeclarativemetaobject +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativemetaobject.cpp + +include (../../shared/util.pri) + +testDataFiles.files = data +testDataFiles.path = . +DEPLOYMENT += testDataFiles + +CONFIG += parallel_test +QT += declarative testlib diff --git a/tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp b/tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp new file mode 100644 index 0000000000..424de872b7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemetaobject/tst_qdeclarativemetaobject.cpp @@ -0,0 +1,364 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include "../../shared/util.h" + +Q_DECLARE_METATYPE(QMetaMethod::MethodType) + +class MyQmlObject : public QObject +{ + Q_OBJECT +}; +QML_DECLARE_TYPE(MyQmlObject) + +class tst_QDeclarativeMetaObject : public QDeclarativeDataTest +{ + Q_OBJECT +private slots: + void initTestCase(); + + void property_data(); + void property(); + void method_data(); + void method(); + +private: + MyQmlObject myQmlObject; +}; + +void tst_QDeclarativeMetaObject::initTestCase() +{ + QDeclarativeDataTest::initTestCase(); + + qmlRegisterType("Qt.test", 1,0, "MyQmlObject"); +} + +void tst_QDeclarativeMetaObject::property_data() +{ + QTest::addColumn("testFile"); + QTest::addColumn("cppTypeName"); + QTest::addColumn("cppType"); + QTest::addColumn("isDefault"); + QTest::addColumn("expectedValue"); + QTest::addColumn("isWritable"); + QTest::addColumn("newValue"); + + QTest::newRow("int") << "property.int.qml" + << QByteArray("int") << int(QMetaType::Int) + << false // default + << QVariant(19) << true << QVariant(42); + QTest::newRow("bool") << "property.bool.qml" + << QByteArray("bool") << int(QMetaType::Bool) + << true // default + << QVariant(true) << true << QVariant(false); + QTest::newRow("real") << "property.real.qml" + << QByteArray("double") << int(QMetaType::Double) + << false // default + << QVariant(double(21)) + << true // writable + << QVariant(double(37)); + QTest::newRow("string") << "property.string.qml" + << QByteArray("QString") << int(QMetaType::QString) + << true // default + << QVariant(QString::fromLatin1("dog")) + << true // writable + << QVariant(QString::fromLatin1("food")); + QTest::newRow("url") << "property.url.qml" + << QByteArray("QUrl") << int(QMetaType::QUrl) + << false // default + << QVariant(QUrl("http://foo.bar")) + << true //writable + << QVariant(QUrl("http://bar.baz")); + QTest::newRow("color") << "property.color.qml" + << QByteArray("QColor") << int(QMetaType::QColor) + << true // default + << QVariant(QColor("#ff0000")) + << true // writable + << QVariant(QColor("#00ff00")); + QTest::newRow("date") << "property.date.qml" + << QByteArray("QDateTime") << int(QMetaType::QDateTime) + << false // default + << QVariant(QDateTime(QDate(2012, 2, 7))) + << true // writable + << QVariant(QDateTime(QDate(2010, 7, 2))); + QTest::newRow("variant") << "property.variant.qml" + << QByteArray("QVariant") << int(QMetaType::QVariant) + << true // default + << QVariant(QPointF(12, 34)) + << true // writable + << QVariant(QSizeF(45, 67)); + QTest::newRow("var") << "property.var.qml" + << QByteArray("QVariant") << int(QMetaType::QVariant) + << false // default + << QVariant(QVariantList() << 5 << true << "ciao") + << true // writable + << QVariant(QVariantList() << 17.0); + QTest::newRow("QtObject") << "property.QtObject.qml" + << QByteArray("QObject*") << int(QMetaType::QObjectStar) + << false // default + << QVariant() + << true // writable + << QVariant::fromValue(static_cast(this)); + QTest::newRow("list") << "property.list.QtObject.qml" + << QByteArray("QDeclarativeListProperty") + << qMetaTypeId >() + << false // default + << QVariant() + << false // writable + << QVariant(); + QTest::newRow("MyQmlObject") << "property.MyQmlObject.qml" + << QByteArray("MyQmlObject*") << qMetaTypeId() + << false // default + << QVariant() + << true // writable + << QVariant::fromValue(&myQmlObject); + QTest::newRow("list") << "property.list.MyQmlObject.qml" + << QByteArray("QDeclarativeListProperty") + << qMetaTypeId >() + << false // default + << QVariant() + << false // writable + << QVariant(); + QTest::newRow("alias") << "property.alias.qml" + << QByteArray("QString") << int(QMetaType::QString) + << false // default + << QVariant(QString::fromLatin1("Joe")) + << true // writable + << QVariant(QString::fromLatin1("Bob")); + QTest::newRow("alias-2") << "property.alias.2.qml" + << QByteArray("QObject*") << int(QMetaType::QObjectStar) + << false // default + << QVariant() + << false // writable + << QVariant(); + QTest::newRow("alias-3") << "property.alias.3.qml" + << QByteArray("QString") << int(QMetaType::QString) + << false // default + << QVariant(QString::fromLatin1("Arial")) + << true // writable + << QVariant(QString::fromLatin1("Helvetica")); +} + +void tst_QDeclarativeMetaObject::property() +{ + QFETCH(QString, testFile); + QFETCH(QByteArray, cppTypeName); + QFETCH(int, cppType); + QFETCH(bool, isDefault); + QFETCH(QVariant, expectedValue); + QFETCH(bool, isWritable); + QFETCH(QVariant, newValue); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, testFileUrl(testFile)); + QObject *object = component.create(); + QVERIFY(object != 0); + + const QMetaObject *mo = object->metaObject(); + QVERIFY(mo->superClass() != 0); + QVERIFY(QByteArray(mo->className()).contains("_QML_")); + QCOMPARE(mo->propertyOffset(), mo->superClass()->propertyCount()); + QCOMPARE(mo->propertyCount(), mo->superClass()->propertyCount() + 1); + + QMetaProperty prop = mo->property(mo->propertyOffset()); + QCOMPARE(prop.name(), "test"); + + QCOMPARE(QByteArray(prop.typeName()), cppTypeName); + QEXPECT_FAIL("QtObject", "prop.type() returns UserType for QtObject properties", Continue); + QEXPECT_FAIL("alias-2", "prop.type() returns UserType for QtObject properties", Continue); + if (prop.userType() < QMetaType::User) + QCOMPARE(prop.type(), QVariant::Type(cppType)); + QCOMPARE(prop.userType(), cppType); + + QVERIFY(!prop.isConstant()); + QVERIFY(!prop.isDesignable()); + QVERIFY(!prop.isEnumType()); + QVERIFY(!prop.isFinal()); + QVERIFY(!prop.isFlagType()); + QVERIFY(prop.isReadable()); + QVERIFY(!prop.isResettable()); + QVERIFY(prop.isScriptable()); + QVERIFY(!prop.isStored()); + QVERIFY(!prop.isUser()); + QVERIFY(prop.isValid()); + QCOMPARE(prop.isWritable(), isWritable); + + QCOMPARE(mo->classInfoOffset(), mo->superClass()->classInfoCount()); + QCOMPARE(mo->classInfoCount(), mo->superClass()->classInfoCount() + (isDefault ? 1 : 0)); + if (isDefault) { + QMetaClassInfo info = mo->classInfo(mo->classInfoOffset()); + QCOMPARE(info.name(), "DefaultProperty"); + QCOMPARE(info.value(), "test"); + } + + QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount()); + QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1); // the signal + + QVERIFY(prop.notifySignalIndex() != -1); + QMetaMethod signal = prop.notifySignal(); + QCOMPARE(signal.methodType(), QMetaMethod::Signal); + QCOMPARE(signal.signature(), "testChanged()"); + QCOMPARE(signal.access(), QMetaMethod::Protected); + QCOMPARE(signal.parameterTypes(), QList()); + QCOMPARE(signal.parameterNames(), QList()); + QCOMPARE(signal.tag(), ""); + QCOMPARE(signal.typeName(), ""); + + QSignalSpy changedSpy(object, SIGNAL(testChanged())); + QObject::connect(object, SIGNAL(testChanged()), object, SLOT(deleteLater())); + + if (expectedValue.isValid()) + QCOMPARE(prop.read(object), expectedValue); + else + QVERIFY(prop.read(object).isValid()); + QCOMPARE(changedSpy.count(), 0); + + if (isWritable) { + QVERIFY(prop.write(object, newValue)); + QCOMPARE(changedSpy.count(), 1); + QCOMPARE(prop.read(object), newValue); + } else { + QVERIFY(!prop.write(object, prop.read(object))); + QCOMPARE(changedSpy.count(), 0); + } + + delete object; +} + +void tst_QDeclarativeMetaObject::method_data() +{ + QTest::addColumn("testFile"); + QTest::addColumn("signature"); + QTest::addColumn("methodType"); + QTest::addColumn("returnTypeName"); + QTest::addColumn >("parameterTypeNames"); + QTest::addColumn >("parameterNames"); + + QTest::newRow("testFunction()") << "method.1.qml" + << "testFunction()" + << QMetaMethod::Slot + << "QVariant" + << QList() + << QList(); + QTest::newRow("testFunction(foo)") << "method.2.qml" + << "testFunction(QVariant)" + << QMetaMethod::Slot + << "QVariant" + << (QList() << "QVariant") + << (QList() << "foo"); + QTest::newRow("testFunction(foo, bar, baz)") << "method.3.qml" + << "testFunction(QVariant,QVariant,QVariant)" + << QMetaMethod::Slot + << "QVariant" + << (QList() << "QVariant" << "QVariant" << "QVariant") + << (QList() << "foo" << "bar" << "baz"); + QTest::newRow("testSignal") << "signal.1.qml" + << "testSignal()" + << QMetaMethod::Signal + << "" + << QList() + << QList(); + QTest::newRow("testSignal(string foo)") << "signal.2.qml" + << "testSignal(QString)" + << QMetaMethod::Signal + << "" + << (QList() << "QString") + << (QList() << "foo"); + QTest::newRow("testSignal(int foo, bool bar, real baz)") << "signal.3.qml" + << "testSignal(int,bool,qreal)" + << QMetaMethod::Signal + << "" + << (QList() << "int" << "bool" << "qreal") + << (QList() << "foo" << "bar" << "baz"); + QTest::newRow("testSignal(variant foo, var bar)") << "signal.4.qml" + << "testSignal(QVariant,QVariant)" + << QMetaMethod::Signal + << "" + << (QList() << "QVariant" << "QVariant") + << (QList() << "foo" << "bar"); + QTest::newRow("testSignal(color foo, date bar, url baz)") << "signal.5.qml" + << "testSignal(QColor,QDateTime,QUrl)" + << QMetaMethod::Signal + << "" + << (QList() << "QColor" << "QDateTime" << "QUrl") + << (QList() << "foo" << "bar" << "baz"); +} + +void tst_QDeclarativeMetaObject::method() +{ + QFETCH(QString, testFile); + QFETCH(QString, signature); + QFETCH(QMetaMethod::MethodType, methodType); + QFETCH(QString, returnTypeName); + QFETCH(QList, parameterTypeNames); + QFETCH(QList, parameterNames); + + QCOMPARE(parameterTypeNames.size(), parameterNames.size()); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, testFileUrl(testFile)); + QObject *object = component.create(); + QVERIFY(object != 0); + + const QMetaObject *mo = object->metaObject(); + QVERIFY(mo->superClass() != 0); + QVERIFY(QByteArray(mo->className()).contains("_QML_")); + QCOMPARE(mo->methodOffset(), mo->superClass()->methodCount()); + QCOMPARE(mo->methodCount(), mo->superClass()->methodCount() + 1); + + QMetaMethod method = mo->method(mo->methodOffset()); + QCOMPARE(method.methodType(), methodType); + QCOMPARE(QString::fromUtf8(method.signature()), signature); + QCOMPARE(method.access(), QMetaMethod::Protected); + QCOMPARE(method.parameterTypes(), parameterTypeNames); + QCOMPARE(method.parameterNames(), parameterNames); + QCOMPARE(method.tag(), ""); + QCOMPARE(QString::fromUtf8(method.typeName()), returnTypeName); + + delete object; +} + +QTEST_MAIN(tst_QDeclarativeMetaObject) + +#include "tst_qdeclarativemetaobject.moc" -- cgit v1.2.3 From 1ebad3a320e69b82a7a135f618fd38f650791539 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Thu, 1 Mar 2012 10:10:07 +1000 Subject: Fix QQuickDropArea test compilation. Change-Id: I5feaabe235201af842ca6bc4f3496b1861b06fb9 Reviewed-by: Michael Brasser --- .../qtquick2/qquickdroparea/qquickdroparea.pro | 2 + .../qtquick2/qquickdroparea/tst_qquickdroparea.cpp | 75 +++++++++++----------- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro b/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro index 46fe08c145..6c6de13d5f 100644 --- a/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro +++ b/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro @@ -7,3 +7,5 @@ SOURCES += tst_qquickdroparea.cpp CONFIG += parallel_test QT += core-private gui-private declarative-private quick-private network testlib + +mac: CONFIG += insignificant_test # QTBUG-24588 diff --git a/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp index 0cd3fa9416..88cf1ec009 100644 --- a/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp +++ b/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp @@ -48,6 +48,7 @@ #include #include +#include template static T evaluate(QObject *scope, const QString &expression) { @@ -193,14 +194,14 @@ void tst_QQuickDropArea::containsDrag_external() QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "hasDrag"), false); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "hasDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(evaluate(dropArea, "exitEvents"), 0); evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "hasDrag"), false); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); @@ -208,13 +209,13 @@ void tst_QQuickDropArea::containsDrag_external() evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "hasDrag"), false); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); QCOMPARE(evaluate(dropArea, "exitEvents"), 0); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "hasDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); @@ -222,13 +223,13 @@ void tst_QQuickDropArea::containsDrag_external() evaluate(dropArea, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "hasDrag"), false); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); QCOMPARE(evaluate(dropArea, "exitEvents"), 1); - QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50)); + QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50), Qt::CopyAction); } void tst_QQuickDropArea::keys_internal() @@ -363,80 +364,80 @@ void tst_QQuickDropArea::keys_external() QCOMPARE(evaluate(dropArea, "containsDrag"), false); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); evaluate(dropArea, "keys = \"text/x-blue\""); QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-blue"); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-blue"); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); evaluate(dropArea, "keys = \"text/x-red\""); QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red"); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red"); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); evaluate(dropArea, "keys = \"text/x-green\""); QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-green"); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-green"); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); evaluate(dropArea, "keys = [\"text/x-red\", \"text/x-green\"]"); QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red" << "text/x-green"); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red" << "text/x-green"); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); data.removeFormat("text/x-red"); data.removeFormat("text/x-blue"); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), false); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); evaluate(dropArea, "keys = []"); QCOMPARE(dropArea->property("keys").toStringList(), QStringList()); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList()); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList()); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); data.setData("text/x-red", "red"); data.setData("text/x-blue", "blue"); QCOMPARE(dropArea->property("keys").toStringList(), QStringList()); QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList()); evaluate(dropArea, "{ enterEvents = 0; dragKeys = undefined }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "containsDrag"), true); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue"); - QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50), Qt::CopyAction); } void tst_QQuickDropArea::source_internal() @@ -589,7 +590,7 @@ void tst_QQuickDropArea::position_external() QMimeData data; - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "enterEvents"), 1); QCOMPARE(evaluate(dropArea, "moveEvents"), 1); QCOMPARE(evaluate(dropArea, "drag.x"), qreal(50)); @@ -600,7 +601,7 @@ void tst_QQuickDropArea::position_external() QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); QCOMPARE(evaluate(dropArea, "moveEvents"), 1); QCOMPARE(evaluate(dropArea, "drag.x"), qreal(40)); @@ -611,7 +612,7 @@ void tst_QQuickDropArea::position_external() QCOMPARE(evaluate(dropArea, "eventY"), qreal(50)); evaluate(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25), Qt::CopyAction); QCOMPARE(evaluate(dropArea, "enterEvents"), 0); QCOMPARE(evaluate(dropArea, "moveEvents"), 1); QCOMPARE(evaluate(dropArea, "drag.x"), qreal(75)); @@ -621,7 +622,7 @@ void tst_QQuickDropArea::position_external() QCOMPARE(evaluate(dropArea, "eventX"), qreal(75)); QCOMPARE(evaluate(dropArea, "eventY"), qreal(25)); - QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25)); + QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25), Qt::CopyAction); } void tst_QQuickDropArea::drop_internal() @@ -886,7 +887,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -894,7 +895,7 @@ void tst_QQuickDropArea::simultaneousDrags() QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -902,7 +903,7 @@ void tst_QQuickDropArea::simultaneousDrags() QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -920,7 +921,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), false); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -931,7 +932,7 @@ void tst_QQuickDropArea::simultaneousDrags() // external then internal. evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 1); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -965,7 +966,7 @@ void tst_QQuickDropArea::simultaneousDrags() QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); QCOMPARE(evaluate(dropArea2, "exitEvents"), 0); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), false); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 1); @@ -1061,7 +1062,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -1071,7 +1072,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -1081,7 +1082,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), true); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -1101,7 +1102,7 @@ void tst_QQuickDropArea::simultaneousDrags() evaluate(dropArea1, "{ enterEvents = 0; exitEvents = 0 }"); evaluate(dropArea2, "{ enterEvents = 0; exitEvents = 0 }"); - QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); QCOMPARE(evaluate(dropArea1, "containsDrag"), false); QCOMPARE(evaluate(dropArea1, "enterEvents"), 0); QCOMPARE(evaluate(dropArea1, "exitEvents"), 0); @@ -1109,7 +1110,7 @@ void tst_QQuickDropArea::simultaneousDrags() QCOMPARE(evaluate(dropArea2, "enterEvents"), 0); QCOMPARE(evaluate(dropArea2, "exitEvents"), 1); - QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50)); + QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50), Qt::CopyAction); } QTEST_MAIN(tst_QQuickDropArea) -- cgit v1.2.3 From e3a43b3ca3b1e2d6fd92945d6d7f42aed8203abc Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 24 Feb 2012 09:27:12 +1000 Subject: Reduce size of QQuickTextPrivate Move less used members to an extra struct lazily allocated Change-Id: I87e464af4b9d29303705dd7e766f734309ed7763 Reviewed-by: Andrew den Exter --- src/quick/items/qquicktext.cpp | 193 ++++++++++++---------- src/quick/items/qquicktext_p_p.h | 37 +++-- tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 13 +- 3 files changed, 137 insertions(+), 106 deletions(-) diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 656440f2d3..f0ce26ed62 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -71,17 +71,16 @@ QT_BEGIN_NAMESPACE const QChar QQuickTextPrivate::elideChar = QChar(0x2026); QQuickTextPrivate::QQuickTextPrivate() - : lineHeight(1) - , elideLayout(0), textLine(0), doc(0) + : elideLayout(0), textLine(0) #if defined(Q_OS_MAC) , layoutThread(0), paintingThread(0) #endif , color(0xFF000000), linkColor(0xFF0000FF), styleColor(0xFF000000) - , lineCount(1), maximumLineCount(INT_MAX), multilengthEos(-1), minimumPixelSize(12), minimumPointSize(12), nbActiveDownloads(0) - , hAlign(QQuickText::AlignLeft), vAlign(QQuickText::AlignTop), elideMode(QQuickText::ElideNone) + , lineCount(1), multilengthEos(-1) + , elideMode(QQuickText::ElideNone), hAlign(QQuickText::AlignLeft), vAlign(QQuickText::AlignTop) , format(QQuickText::AutoText), wrapMode(QQuickText::NoWrap) - , lineHeightMode(QQuickText::ProportionalHeight), style(QQuickText::Normal) - , fontSizeMode(QQuickText::FixedSize), updateType(UpdatePaintNode) + , style(QQuickText::Normal) + , updateType(UpdatePaintNode) , maximumLineCountValid(false), updateOnComponentComplete(true), richText(false) , styledText(false), singleline(false), internalWidthUpdate(false), requireImplicitWidth(false) , truncated(false), hAlignImplicit(true), rightToLeftText(false) @@ -89,6 +88,18 @@ QQuickTextPrivate::QQuickTextPrivate() { } +QQuickTextPrivate::ExtraData::ExtraData() + : lineHeight(1.0) + , doc(0) + , minimumPixelSize(12) + , minimumPointSize(12) + , nbActiveDownloads(0) + , maximumLineCount(INT_MAX) + , lineHeightMode(QQuickText::ProportionalHeight) + , fontSizeMode(QQuickText::FixedSize) +{ +} + void QQuickTextPrivate::init() { Q_Q(QQuickText); @@ -323,10 +334,10 @@ void QQuickTextPrivate::updateLayout() } else { ensureDoc(); QTextBlockFormat::LineHeightTypes type; - type = lineHeightMode == QQuickText::FixedHeight ? QTextBlockFormat::FixedHeight : QTextBlockFormat::ProportionalHeight; + type = lineHeightMode() == QQuickText::FixedHeight ? QTextBlockFormat::FixedHeight : QTextBlockFormat::ProportionalHeight; QTextBlockFormat blockFormat; - blockFormat.setLineHeight((lineHeightMode == QQuickText::FixedHeight ? lineHeight : lineHeight * 100), type); - for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next()) { + blockFormat.setLineHeight((lineHeightMode() == QQuickText::FixedHeight ? lineHeight() : lineHeight() * 100), type); + for (QTextBlock it = extra->doc->begin(); it != extra->doc->end(); it = it.next()) { QTextCursor cursor(it); cursor.mergeBlockFormat(blockFormat); } @@ -345,13 +356,13 @@ void QQuickText::imageDownloadFinished() { Q_D(QQuickText); - (d->nbActiveDownloads)--; + (d->extra->nbActiveDownloads)--; // when all the remote images have been downloaded, // if one of the sizes was not specified at parsing time // we use the implicit size from pixmapcache and re-layout. - if (d->nbActiveDownloads == 0) { + if (d->extra.isAllocated() && d->extra->nbActiveDownloads == 0) { bool needToUpdateLayout = false; foreach (QDeclarativeStyledTextImgTag *img, d->visibleImgTags) { if (!img->size.isValid()) { @@ -415,7 +426,7 @@ void QQuickTextPrivate::updateSize() } else { singleline = false; // richtext can't elide or be optimized for single-line case ensureDoc(); - doc->setDefaultFont(font); + extra->doc->setDefaultFont(font); QQuickText::HAlignment horizontalAlignment = q->effectiveHAlign(); if (rightToLeftText) { if (horizontalAlignment == QQuickText::AlignLeft) @@ -427,19 +438,19 @@ void QQuickTextPrivate::updateSize() option.setAlignment((Qt::Alignment)int(horizontalAlignment | vAlign)); option.setWrapMode(QTextOption::WrapMode(wrapMode)); option.setUseDesignMetrics(true); - doc->setDefaultTextOption(option); + extra->doc->setDefaultTextOption(option); if (requireImplicitWidth && q->widthValid()) { - doc->setTextWidth(-1); - naturalWidth = doc->idealWidth(); + extra->doc->setTextWidth(-1); + naturalWidth = extra->doc->idealWidth(); } if (wrapMode != QQuickText::NoWrap && q->widthValid()) - doc->setTextWidth(q->width()); + extra->doc->setTextWidth(q->width()); else - doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) - dy -= doc->size().height(); - QSizeF dsize = doc->size(); + extra->doc->setTextWidth(extra->doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) + dy -= extra->doc->size().height(); + QSizeF dsize = extra->doc->size(); layedOutTextRect = QRectF(QPointF(0,0), dsize); - size = QSizeF(doc->idealWidth(),dsize.height()); + size = QSizeF(extra->doc->idealWidth(),dsize.height()); } qreal yoff = 0; @@ -581,8 +592,8 @@ void QQuickTextPrivate::setupCustomLineGeometry(QTextLine &line, qreal &height, textLine->setWidth(q->width()); else textLine->setWidth(INT_MAX); - if (lineHeight != 1.0) - textLine->setHeight((lineHeightMode == QQuickText::FixedHeight) ? lineHeight : line.height() * lineHeight); + if (lineHeight() != 1.0) + textLine->setHeight((lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : line.height() * lineHeight()); emit q->lineLaidOut(textLine); @@ -658,7 +669,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) // Layout to determine the implicit width. layout.beginLayout(); - for (int i = 0; i < maximumLineCount; ++i) { + for (int i = 0; i < maximumLineCount(); ++i) { QTextLine line = layout.createLine(); if (!line.isValid()) break; @@ -669,7 +680,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) } QFontMetrics fm(font); - qreal height = (lineHeightMode == QQuickText::FixedHeight) ? lineHeight : fm.height() * lineHeight; + qreal height = (lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : fm.height() * lineHeight(); return QRect(0, 0, 0, height); } @@ -686,15 +697,15 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) && (q->heightValid() || maximumLineCountValid); const bool canWrap = wrapMode != QQuickText::NoWrap && q->widthValid(); - const bool horizontalFit = fontSizeMode & QQuickText::HorizontalFit && q->widthValid(); - const bool verticalFit = fontSizeMode & QQuickText::VerticalFit + const bool horizontalFit = fontSizeMode() & QQuickText::HorizontalFit && q->widthValid(); + const bool verticalFit = fontSizeMode() & QQuickText::VerticalFit && (q->heightValid() || (maximumLineCountValid && canWrap)); const bool pixelSize = font.pixelSize() != -1; QString layoutText = layout.text(); int largeFont = pixelSize ? font.pixelSize() : font.pointSize(); - int smallFont = fontSizeMode != QQuickText::FixedSize - ? qMin(pixelSize ? minimumPixelSize : minimumPointSize, largeFont) + int smallFont = fontSizeMode() != QQuickText::FixedSize + ? qMin(pixelSize ? minimumPixelSize() : minimumPointSize(), largeFont) : largeFont; int scaledFontSize = largeFont; @@ -732,6 +743,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) elide = false; int characterCount = 0; int unwrappedLineCount = 1; + int maxLineCount = maximumLineCount(); height = 0; br = QRectF(); line = layout.createLine(); @@ -767,7 +779,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) line.setPosition(QPointF(FLT_MAX, FLT_MAX)); line = previousLine; --visibleCount; - height -= (lineHeightMode == QQuickText::FixedHeight) ? lineHeight : previousLine.height() * lineHeight; + height -= (lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : previousLine.height() * lineHeight(); break; } @@ -801,7 +813,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) // Stop if the maximum number of lines has been reached and elide the last line // if enabled. - if (visibleCount == maximumLineCount) { + if (visibleCount == maxLineCount) { truncated = true; characterCount = nextLine.textStart() + nextLine.textLength(); @@ -835,13 +847,13 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) if (requireImplicitWidth && characterCount < layoutText.length() - && unwrappedLineCount < maximumLineCount) { + && unwrappedLineCount < maxLineCount) { // Use a new layout to get the maximum width for the remaining text. Using a // different layout excludes the truncated text from rendering. QTextLayout widthLayout(layoutText.mid(characterCount), scaledFont); widthLayout.setTextOption(layout.textOption()); - for (; unwrappedLineCount <= maximumLineCount; ++unwrappedLineCount) { + for (; unwrappedLineCount <= maxLineCount; ++unwrappedLineCount) { QTextLine line = widthLayout.createLine(); if (!line.isValid()) break; @@ -952,7 +964,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal if (imgTags.isEmpty()) { line.setPosition(QPointF(line.position().x(), height)); - height += (lineHeightMode == QQuickText::FixedHeight) ? lineHeight : line.height() * lineHeight; + height += (lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : line.height() * lineHeight(); return; } @@ -971,7 +983,9 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal image->pix = new QDeclarativePixmap(qmlEngine(q), url, image->size); if (image->pix->isLoading()) { image->pix->connectFinished(q, SLOT(imageDownloadFinished())); - nbActiveDownloads++; + if (!extra.isAllocated() || !extra->nbActiveDownloads) + extra.value().nbActiveDownloads = 0; + extra->nbActiveDownloads++; } else if (image->pix->isReady()) { if (!image->size.isValid()) { image->size = image->pix->implicitSize(); @@ -1004,7 +1018,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal } line.setPosition(QPointF(line.position().x(), height + textTop)); - height += (lineHeightMode == QQuickText::FixedHeight) ? lineHeight : totalLineHeight * lineHeight; + height += (lineHeightMode() == QQuickText::FixedHeight) ? lineHeight() : totalLineHeight * lineHeight(); } /*! @@ -1012,12 +1026,12 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal */ void QQuickTextPrivate::ensureDoc() { - if (!doc) { + if (!extra.isAllocated() || !extra->doc) { Q_Q(QQuickText); - doc = new QQuickTextDocumentWithImageResources(q); - doc->setDocumentMargin(0); - doc->setBaseUrl(q->baseUrl()); - FAST_CONNECT(doc, SIGNAL(imagesLoaded()), q, SLOT(q_imagesLoaded())); + extra.value().doc = new QQuickTextDocumentWithImageResources(q); + extra->doc->setDocumentMargin(0); + extra->doc->setBaseUrl(q->baseUrl()); + FAST_CONNECT(extra->doc, SIGNAL(imagesLoaded()), q, SLOT(q_imagesLoaded())); } } @@ -1304,8 +1318,8 @@ void QQuickText::setText(const QString &n) if (isComponentComplete()) { if (d->richText) { d->ensureDoc(); - d->doc->setText(n); - d->rightToLeftText = d->doc->toPlainText().isRightToLeft(); + d->extra->doc->setText(n); + d->rightToLeftText = d->extra->doc->toPlainText().isRightToLeft(); } else { d->rightToLeftText = d->text.isRightToLeft(); } @@ -1569,11 +1583,6 @@ void QQuickTextPrivate::mirrorChange() } } -QTextDocument *QQuickTextPrivate::textDocument() -{ - return doc; -} - QQuickText::VAlignment QQuickText::vAlign() const { Q_D(const QQuickText); @@ -1666,7 +1675,7 @@ bool QQuickText::truncated() const int QQuickText::maximumLineCount() const { Q_D(const QQuickText); - return d->maximumLineCount; + return d->maximumLineCount(); } void QQuickText::setMaximumLineCount(int lines) @@ -1674,8 +1683,8 @@ void QQuickText::setMaximumLineCount(int lines) Q_D(QQuickText); d->maximumLineCountValid = lines==INT_MAX ? false : true; - if (d->maximumLineCount != lines) { - d->maximumLineCount = lines; + if (d->maximumLineCount() != lines) { + d->extra.value().maximumLineCount = lines; d->updateLayout(); emit maximumLineCountChanged(); } @@ -1777,8 +1786,8 @@ void QQuickText::setTextFormat(TextFormat format) if (isComponentComplete()) { if (!wasRich && d->richText) { d->ensureDoc(); - d->doc->setText(d->text); - d->rightToLeftText = d->doc->toPlainText().isRightToLeft(); + d->extra->doc->setText(d->text); + d->rightToLeftText = d->extra->doc->toPlainText().isRightToLeft(); } else { d->rightToLeftText = d->text.isRightToLeft(); } @@ -1831,7 +1840,7 @@ void QQuickText::setElideMode(QQuickText::TextElideMode mode) d->elideMode = mode; d->updateLayout(); - emit elideModeChanged(d->elideMode); + emit elideModeChanged(mode); } /*! @@ -1873,8 +1882,10 @@ void QQuickText::setBaseUrl(const QUrl &url) if (baseUrl() != url) { d->baseUrl = url; - if (d->doc) - d->doc->setBaseUrl(url); + if (d->richText) { + d->ensureDoc(); + d->extra->doc->setBaseUrl(url); + } if (d->styledText) { d->textHasChanged = true; qDeleteAll(d->imgTags); @@ -1933,7 +1944,7 @@ void QQuickText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo bool leftAligned = effectiveHAlign() == QQuickText::AlignLeft; bool wrapped = d->wrapMode != QQuickText::NoWrap; bool elide = d->elideMode != QQuickText::ElideNone; - bool scaleFont = d->fontSizeMode != QQuickText::FixedSize && (widthValid() || heightValid()); + bool scaleFont = d->fontSizeMode() != QQuickText::FixedSize && (widthValid() || heightValid()); if ((!widthChanged && !heightChanged) || d->internalWidthUpdate) goto geomChangeDone; @@ -1954,7 +1965,7 @@ void QQuickText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo if (d->elideMode == QQuickText::ElideRight && wrapped && newGeometry.height() > oldGeometry.height() && !scaleFont) { if (!d->truncated) goto geomChangeDone; // Multiline eliding not affected if we're not currently truncated and we get higher. - if (d->maximumLineCountValid && d->lineCount == d->maximumLineCount) + if (d->maximumLineCountValid && d->lineCount == d->maximumLineCount()) goto geomChangeDone; // Multiline eliding not affected if we're already at max line count and we get higher. } @@ -2021,7 +2032,7 @@ QSGNode *QQuickText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data if (d->richText) { d->ensureDoc(); - node->addTextDocument(bounds.topLeft(), d->doc, color, d->style, styleColor, linkColor); + node->addTextDocument(bounds.topLeft(), d->extra->doc, color, d->style, styleColor, linkColor); } else if (d->elideMode == QQuickText::ElideNone || bounds.width() > 0.) { node->addTextLayout(QPoint(0, bounds.y()), &d->layout, color, d->style, styleColor, linkColor); if (d->elideLayout) @@ -2081,17 +2092,17 @@ qreal QQuickText::contentHeight() const qreal QQuickText::lineHeight() const { Q_D(const QQuickText); - return d->lineHeight; + return d->lineHeight(); } void QQuickText::setLineHeight(qreal lineHeight) { Q_D(QQuickText); - if ((d->lineHeight == lineHeight) || (lineHeight < 0.0)) + if ((d->lineHeight() == lineHeight) || (lineHeight < 0.0)) return; - d->lineHeight = lineHeight; + d->extra.value().lineHeight = lineHeight; d->updateLayout(); emit lineHeightChanged(lineHeight); } @@ -2111,16 +2122,16 @@ void QQuickText::setLineHeight(qreal lineHeight) QQuickText::LineHeightMode QQuickText::lineHeightMode() const { Q_D(const QQuickText); - return d->lineHeightMode; + return d->lineHeightMode(); } void QQuickText::setLineHeightMode(LineHeightMode mode) { Q_D(QQuickText); - if (mode == d->lineHeightMode) + if (mode == d->lineHeightMode()) return; - d->lineHeightMode = mode; + d->extra.value().lineHeightMode = mode; d->updateLayout(); emit lineHeightModeChanged(mode); @@ -2154,18 +2165,18 @@ void QQuickText::setLineHeightMode(LineHeightMode mode) QQuickText::FontSizeMode QQuickText::fontSizeMode() const { Q_D(const QQuickText); - return d->fontSizeMode; + return d->fontSizeMode(); } void QQuickText::setFontSizeMode(FontSizeMode mode) { Q_D(QQuickText); - if (d->fontSizeMode == mode) + if (d->fontSizeMode() == mode) return; polish(); - d->fontSizeMode = mode; + d->extra.value().fontSizeMode = mode; emit fontSizeModeChanged(); } @@ -2182,18 +2193,18 @@ void QQuickText::setFontSizeMode(FontSizeMode mode) int QQuickText::minimumPixelSize() const { Q_D(const QQuickText); - return d->minimumPixelSize; + return d->minimumPixelSize(); } void QQuickText::setMinimumPixelSize(int size) { Q_D(QQuickText); - if (d->minimumPixelSize == size) + if (d->minimumPixelSize() == size) return; - if (d->fontSizeMode != FixedSize && (widthValid() || heightValid())) + if (d->fontSizeMode() != FixedSize && (widthValid() || heightValid())) polish(); - d->minimumPixelSize = size; + d->extra.value().minimumPixelSize = size; emit minimumPixelSizeChanged(); } @@ -2210,18 +2221,18 @@ void QQuickText::setMinimumPixelSize(int size) int QQuickText::minimumPointSize() const { Q_D(const QQuickText); - return d->minimumPointSize; + return d->minimumPointSize(); } void QQuickText::setMinimumPointSize(int size) { Q_D(QQuickText); - if (d->minimumPointSize == size) + if (d->minimumPointSize() == size) return; - if (d->fontSizeMode != FixedSize && (widthValid() || heightValid())) + if (d->fontSizeMode() != FixedSize && (widthValid() || heightValid())) polish(); - d->minimumPointSize = size; + d->extra.value().minimumPointSize = size; emit minimumPointSizeChanged(); } @@ -2231,7 +2242,9 @@ void QQuickText::setMinimumPointSize(int size) int QQuickText::resourcesLoading() const { Q_D(const QQuickText); - return d->doc ? d->doc->resourcesLoading() : 0; + if (d->richText && d->extra.isAllocated() && d->extra->doc) + return d->extra->doc->resourcesLoading(); + return 0; } /*! \internal */ @@ -2241,8 +2254,8 @@ void QQuickText::componentComplete() if (d->updateOnComponentComplete) { if (d->richText) { d->ensureDoc(); - d->doc->setText(d->text); - d->rightToLeftText = d->doc->toPlainText().isRightToLeft(); + d->extra->doc->setText(d->text); + d->rightToLeftText = d->extra->doc->toPlainText().isRightToLeft(); } else { d->rightToLeftText = d->text.isRightToLeft(); } @@ -2289,15 +2302,21 @@ void QQuickText::mousePressEvent(QMouseEvent *event) { Q_D(QQuickText); + QString link; if (d->isLinkActivatedConnected()) { if (d->styledText) - d->activeLink = d->anchorAt(event->localPos()); - else if (d->richText && d->doc) - d->activeLink = d->doc->documentLayout()->anchorAt(event->localPos()); + link = d->anchorAt(event->localPos()); + else if (d->richText) { + d->ensureDoc(); + link = d->extra->doc->documentLayout()->anchorAt(event->localPos()); + } } - if (d->activeLink.isEmpty()) + if (link.isEmpty()) { event->setAccepted(false); + } else { + d->extra.value().activeLink = link; + } // ### may malfunction if two of the same links are clicked & dragged onto each other) @@ -2317,12 +2336,14 @@ void QQuickText::mouseReleaseEvent(QMouseEvent *event) if (d->isLinkActivatedConnected()) { if (d->styledText) link = d->anchorAt(event->localPos()); - else if (d->richText && d->doc) - link = d->doc->documentLayout()->anchorAt(event->localPos()); + else if (d->richText) { + d->ensureDoc(); + link = d->extra->doc->documentLayout()->anchorAt(event->localPos()); + } } - if (!link.isEmpty() && d->activeLink == link) - emit linkActivated(d->activeLink); + if (!link.isEmpty() && d->extra.isAllocated() && d->extra->activeLink == link) + emit linkActivated(d->extra->activeLink); else event->setAccepted(false); diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h index d0770e6962..e61eea90ae 100644 --- a/src/quick/items/qquicktext_p_p.h +++ b/src/quick/items/qquicktext_p_p.h @@ -60,6 +60,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -79,17 +80,28 @@ public: bool determineHorizontalAlignment(); bool setHAlign(QQuickText::HAlignment, bool forceAlign = false); void mirrorChange(); - QTextDocument *textDocument(); bool isLineLaidOutConnected(); void setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height); QString elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine = 0) const; QRectF layedOutTextRect; - qreal lineHeight; + struct ExtraData { + ExtraData(); + + qreal lineHeight; + QQuickTextDocumentWithImageResources *doc; + QString activeLink; + int minimumPixelSize; + int minimumPointSize; + int nbActiveDownloads; + int maximumLineCount; + QQuickText::LineHeightMode lineHeightMode; + QQuickText::FontSizeMode fontSizeMode; + }; + QLazilyAllocated extra; QString text; - QString activeLink; QUrl baseUrl; QFont font; QFont sourceFont; @@ -99,7 +111,6 @@ public: QTextLayout layout; QTextLayout *elideLayout; QQuickTextLine *textLine; - QQuickTextDocumentWithImageResources *doc; #if defined(Q_OS_MAC) QList linesRects; @@ -112,11 +123,7 @@ public: QRgb styleColor; int lineCount; - int maximumLineCount; int multilengthEos; - int minimumPixelSize; - int minimumPointSize; - int nbActiveDownloads; enum UpdateType { UpdateNone, @@ -124,14 +131,12 @@ public: UpdatePaintNode }; + QQuickText::TextElideMode elideMode; QQuickText::HAlignment hAlign; QQuickText::VAlignment vAlign; - QQuickText::TextElideMode elideMode; QQuickText::TextFormat format; QQuickText::WrapMode wrapMode; - QQuickText::LineHeightMode lineHeightMode; QQuickText::TextStyle style; - QQuickText::FontSizeMode fontSizeMode; UpdateType updateType; bool maximumLineCountValid:1; @@ -161,9 +166,13 @@ public: bool isLinkActivatedConnected(); QString anchorAt(const QPointF &pos); - static inline QQuickTextPrivate *get(QQuickText *t) { - return t->d_func(); - } + inline qreal lineHeight() const { return extra.isAllocated() ? extra->lineHeight : 1.0; } + inline int maximumLineCount() const { return extra.isAllocated() ? extra->maximumLineCount : INT_MAX; } + inline QQuickText::LineHeightMode lineHeightMode() const { return extra.isAllocated() ? extra->lineHeightMode : QQuickText::ProportionalHeight; } + inline QQuickText::FontSizeMode fontSizeMode() const { return extra.isAllocated() ? extra->fontSizeMode : QQuickText::FixedSize; } + inline int minimumPixelSize() const { return extra.isAllocated() ? extra->minimumPixelSize : 12; } + inline int minimumPointSize() const { return extra.isAllocated() ? extra->minimumPointSize : 12; } + static inline QQuickTextPrivate *get(QQuickText *t) { return t->d_func(); } }; class QDeclarativePixmap; diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index 5f13f6211d..2be2dcd43d 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -326,8 +326,9 @@ void tst_qquicktext::width() QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject); QVERIFY(textPrivate != 0); + QVERIFY(textPrivate->extra.isAllocated()); - QTextDocument *doc = textPrivate->textDocument(); + QTextDocument *doc = textPrivate->extra->doc; QVERIFY(doc != 0); QCOMPARE(int(textObject->width()), int(doc->idealWidth())); @@ -677,19 +678,20 @@ void tst_qquicktext::horizontalAlignment_RightToLeft() // implicitly aligned rich text should follow the reading direction of text QCOMPARE(text->hAlign(), QQuickText::AlignRight); QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); + QVERIFY(textPrivate->extra.isAllocated()); + QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignLeft); // explicitly left aligned rich text text->setHAlign(QQuickText::AlignLeft); QCOMPARE(text->hAlign(), QQuickText::AlignLeft); QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignRight); + QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignRight); // explicitly right aligned rich text text->setHAlign(QQuickText::AlignRight); QCOMPARE(text->hAlign(), QQuickText::AlignRight); QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); + QVERIFY(textPrivate->extra->doc->defaultTextOption().alignment() & Qt::AlignLeft); text->setText(textString); text->setTextFormat(QQuickText::PlainText); @@ -1623,8 +1625,7 @@ void tst_qquicktext::lineLaidOut() QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText); QVERIFY(textPrivate != 0); - QTextDocument *doc = textPrivate->textDocument(); - QVERIFY(doc == 0); + QVERIFY(!textPrivate->extra.isAllocated()); #if defined(Q_OS_MAC) QVERIFY(myText->lineCount() == textPrivate->linesRects.count()); -- cgit v1.2.3 From beecd8388bc5f3f95c221027318642429f1902cb Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 28 Feb 2012 13:20:56 +1000 Subject: Update ImageElement examples Now more consistently formed. Required a UI redesign for border image, you now view one at a time, with a selector control. Change-Id: Idf64119b644c1a79779ea0a46412247d6d013cb1 Reviewed-by: Alan Alpert Reviewed-by: Yann Bodson --- doc/src/examples/examples-groups.qdoc | 10 -- examples/qtquick/imageelements/animatedsprite.qml | 8 +- examples/qtquick/imageelements/borderimage.qml | 28 +++-- .../imageelements/content/BorderImageSelector.qml | 96 +++++++++++++++++ .../imageelements/content/MyBorderImage.qml | 2 +- examples/qtquick/imageelements/image.qml | 34 +++--- examples/qtquick/imageelements/imageelements.pro | 10 ++ examples/qtquick/imageelements/imageelements.qml | 25 ++++- examples/qtquick/imageelements/main.cpp | 41 ++++++++ examples/qtquick/imageelements/spriteimage.qml | 116 --------------------- examples/qtquick/imageelements/spritesequence.qml | 116 +++++++++++++++++++++ 11 files changed, 327 insertions(+), 159 deletions(-) create mode 100644 examples/qtquick/imageelements/content/BorderImageSelector.qml create mode 100644 examples/qtquick/imageelements/imageelements.pro create mode 100644 examples/qtquick/imageelements/main.cpp delete mode 100644 examples/qtquick/imageelements/spriteimage.qml create mode 100644 examples/qtquick/imageelements/spritesequence.qml diff --git a/doc/src/examples/examples-groups.qdoc b/doc/src/examples/examples-groups.qdoc index a346794b96..0ecd117128 100644 --- a/doc/src/examples/examples-groups.qdoc +++ b/doc/src/examples/examples-groups.qdoc @@ -39,16 +39,6 @@ This example demonstrates the positioners and some of their animations. */ -/*! - \title QML Examples - Image Elements - \example declarative/imageelements - \brief This is a collection of QML examples - \image qml-imageelements-example.png - - This is a collection of small QML examples relating to image elements. Each example is - a small QML file, usually containing or emphasizing a particular element or - feature. You can run and observe the behavior of each example. -*/ /*! \title QML Examples - Models and Views \example declarative/modelviews diff --git a/examples/qtquick/imageelements/animatedsprite.qml b/examples/qtquick/imageelements/animatedsprite.qml index 3a597bba71..337456f785 100644 --- a/examples/qtquick/imageelements/animatedsprite.qml +++ b/examples/qtquick/imageelements/animatedsprite.qml @@ -40,15 +40,17 @@ import QtQuick 2.0 Item { - width: 400 - height: 400 + width: 320 + height: 480 Rectangle { anchors.fill: parent color: "white" } AnimatedSprite { id: sprite - anchors.fill: parent + width: 170 + height: 170 + anchors.centerIn: parent source: "content/speaker.png" frameCount: 60 frameSync: true diff --git a/examples/qtquick/imageelements/borderimage.qml b/examples/qtquick/imageelements/borderimage.qml index 7e132494db..30120fe60d 100644 --- a/examples/qtquick/imageelements/borderimage.qml +++ b/examples/qtquick/imageelements/borderimage.qml @@ -46,32 +46,48 @@ Rectangle { width: 320 height: 480 + BorderImageSelector { + id: selector + curIdx: 0 + maxIdx: 3 + gridWidth: 240 + flickable: mainFlickable + width: parent.width + height: 64 + } + Flickable { - anchors.fill: parent + id: mainFlickable + width: parent.width + anchors.bottom: parent.bottom + anchors.top: selector.bottom + interactive: false //Animated through selector control + contentX: -120 + Behavior on contentX { NumberAnimation {}} contentWidth: 1030 - contentHeight: 540 + contentHeight: 420 Grid { anchors.centerIn: parent; spacing: 20 MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 200 source: "content/colors.png"; margin: 30 } MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 200 source: "content/colors.png"; margin: 30 horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat } MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 200 source: "content/colors.png"; margin: 30 horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat } MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 + minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 200 source: "content/colors.png"; margin: 30 horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round } diff --git a/examples/qtquick/imageelements/content/BorderImageSelector.qml b/examples/qtquick/imageelements/content/BorderImageSelector.qml new file mode 100644 index 0000000000..f3a534b3cd --- /dev/null +++ b/examples/qtquick/imageelements/content/BorderImageSelector.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: selector + property int curIdx: 0 + property int maxIdx: 3 + property int gridWidth: 240 + property Flickable flickable + width: parent.width + height: 64 + function advance(steps) { + var nextIdx = curIdx + steps + if (nextIdx < 0 || nextIdx > maxIdx) + return; + flickable.contentX += gridWidth * steps; + curIdx += steps; + } + Image { + source: "../../../shared/images/back.png" + MouseArea{ + anchors.fill: parent + onClicked: selector.advance(-1) + } + anchors.left: parent.left + anchors.leftMargin: 8 + anchors.verticalCenter: parent.verticalCenter + opacity: selector.curIdx == 0 ? 0.2 : 1.0 + Behavior on opacity {NumberAnimation{}} + } + Image { + source: "../../../shared/images/back.png" + mirror: true + MouseArea{ + anchors.fill: parent + onClicked: selector.advance(1) + } + opacity: selector.curIdx == selector.maxIdx ? 0.2 : 1.0 + Behavior on opacity {NumberAnimation{}} + anchors.right: parent.right + anchors.rightMargin: 8 + anchors.verticalCenter: parent.verticalCenter + } + Repeater { + model: [ "Scale", "Repeat", "Scale/Repeat", "Round" ] + delegate: Text { + text: model.modelData + anchors.verticalCenter: parent.verticalCenter + + x: (index - selector.curIdx) * 80 + 140 + Behavior on x { NumberAnimation{} } + + opacity: selector.curIdx == index ? 1.0 : 0.0 + Behavior on opacity { NumberAnimation{} } + } + } +} diff --git a/examples/qtquick/imageelements/content/MyBorderImage.qml b/examples/qtquick/imageelements/content/MyBorderImage.qml index 178e3706db..93880f12bb 100644 --- a/examples/qtquick/imageelements/content/MyBorderImage.qml +++ b/examples/qtquick/imageelements/content/MyBorderImage.qml @@ -53,7 +53,7 @@ Item { property int maxHeight property int margin - width: 240; height: 240 + width: 240; height: 200 BorderImage { id: image; anchors.centerIn: parent diff --git a/examples/qtquick/imageelements/image.qml b/examples/qtquick/imageelements/image.qml index 159558995d..ccefaf6b74 100644 --- a/examples/qtquick/imageelements/image.qml +++ b/examples/qtquick/imageelements/image.qml @@ -44,29 +44,23 @@ import "content" Rectangle { width: 320 height: 480 - Flickable { - anchors.fill: parent - contentWidth: 490 - contentHeight: 285 - - Grid { - property int cellWidth: (width - (spacing * (columns - 1))) / columns - property int cellHeight: (height - (spacing * (rows - 1))) / rows + Grid { + property int cellWidth: (width - (spacing * (columns - 1))) / columns + property int cellHeight: (height - (spacing * (rows - 1))) / rows - anchors.fill: parent - anchors.margins: 30 + anchors.fill: parent + anchors.margins: 30 - columns: 3 - rows: 2 - spacing: 30 + columns: 2 + rows: 3 + spacing: 30 - ImageCell { mode: Image.Stretch; caption: "Stretch" } - ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" } - ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" } + ImageCell { mode: Image.Stretch; caption: "Stretch" } + ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" } + ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" } - ImageCell { mode: Image.Tile; caption: "Tile" } - ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" } - ImageCell { mode: Image.TileVertically; caption: "TileVertically" } - } + ImageCell { mode: Image.Tile; caption: "Tile" } + ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" } + ImageCell { mode: Image.TileVertically; caption: "TileVertically" } } } diff --git a/examples/qtquick/imageelements/imageelements.pro b/examples/qtquick/imageelements/imageelements.pro new file mode 100644 index 0000000000..5300cbd870 --- /dev/null +++ b/examples/qtquick/imageelements/imageelements.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +QT += quick declarative +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/imageelements +qml.files = borderimage.qml content imageelements.qml image.qml shadows.qml simplesprite.qml spriteimage.qml +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/qtquick/imageelements +INSTALLS += target qml + diff --git a/examples/qtquick/imageelements/imageelements.qml b/examples/qtquick/imageelements/imageelements.qml index f4075ec4c3..bb23ef6979 100644 --- a/examples/qtquick/imageelements/imageelements.qml +++ b/examples/qtquick/imageelements/imageelements.qml @@ -41,9 +41,28 @@ import QtQuick 2.0 import "../../shared" +/*! + \title QML Examples - Image Elements + \example declarative/imageelements + \brief This is a collection of QML examples + \image qml-imageelements-example.png + + This is a collection of small QML examples relating to image elements. + + BorderImage shows off the various scaling modes of the BorderImage item. + + Image shows off the various tiling modes of the Image item. + + Shadows shows how to create a drop shadow for a rectangle using a BorderImage. + + AnimatedSprite shows a simple use for the AnimatedSprite element. + + SpriteSequence demonstrates using the SpriteSequence element to draw an animated and slightly interactive bear. +*/ + Item { height: 480 - width: 640 + width: 320 LauncherList { id: ll anchors.fill: parent @@ -51,8 +70,8 @@ Item { addExample("BorderImage", "An image with scaled borders", Qt.resolvedUrl("borderimage.qml")); addExample("Image", "A showcase of the options available to Image", Qt.resolvedUrl("image.qml")); addExample("Shadows", "Rectangles with a drop-shadow effect", Qt.resolvedUrl("shadows.qml")); - addExample("Simple Sprite", "A simple sprite-based animation", Qt.resolvedUrl("simplesprite.qml")); - addExample("Sprite Image", "A sprite-based animation with complex transitions", Qt.resolvedUrl("spriteimage.qml")); + addExample("AnimatedSprite", "A simple sprite-based animation", Qt.resolvedUrl("animatedsprite.qml")); + addExample("SpriteSequence", "A sprite-based animation with complex transitions", Qt.resolvedUrl("spritesequence.qml")); } } } diff --git a/examples/qtquick/imageelements/main.cpp b/examples/qtquick/imageelements/main.cpp new file mode 100644 index 0000000000..72850f93c1 --- /dev/null +++ b/examples/qtquick/imageelements/main.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "../../shared/shared.h" +DECLARATIVE_EXAMPLE_MAIN(imageelements) diff --git a/examples/qtquick/imageelements/spriteimage.qml b/examples/qtquick/imageelements/spriteimage.qml deleted file mode 100644 index 372970d1d6..0000000000 --- a/examples/qtquick/imageelements/spriteimage.qml +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 2.0 - -Item { - width: 480 - height: 1280 - MouseArea { - onClicked: anim.start(); - anchors.fill: parent - } - SequentialAnimation { - id: anim - ScriptAction { script: image.goalSprite = "falling"; } - NumberAnimation { target: image; property: "y"; to: 1480; duration: 12000; } - ScriptAction { script: {image.goalSprite = ""; image.jumpTo("still");} } - PropertyAction { target: image; property: "y"; value: 0 } - } - SpriteSequence { - id: image - width: 256 - height: 256 - anchors.horizontalCenter: parent.horizontalCenter - interpolate: false - goalSprite: "" - Sprite{ - name: "still" - source: "content/BearSheet.png" - frameCount: 1 - frameWidth: 256 - frameHeight: 256 - frameDuration: 100 - to: {"still":1, "blink":0.1, "floating":0} - } - Sprite{ - name: "blink" - source: "content/BearSheet.png" - frameCount: 3 - frameX: 256 - frameY: 1536 - frameWidth: 256 - frameHeight: 256 - frameDuration: 100 - to: {"still":1} - } - Sprite{ - name: "floating" - source: "content/BearSheet.png" - frameCount: 9 - frameX: 0 - frameY: 0 - frameWidth: 256 - frameHeight: 256 - frameDuration: 160 - to: {"still":0, "flailing":1} - } - Sprite{ - name: "flailing" - source: "content/BearSheet.png" - frameCount: 8 - frameX: 0 - frameY: 768 - frameWidth: 256 - frameHeight: 256 - frameDuration: 160 - to: {"falling":1} - } - Sprite{ - name: "falling" - source: "content/BearSheet.png" - frameCount: 5 - frameY: 1280 - frameWidth: 256 - frameHeight: 256 - frameDuration: 160 - to: {"falling":1} - } - } -} diff --git a/examples/qtquick/imageelements/spritesequence.qml b/examples/qtquick/imageelements/spritesequence.qml new file mode 100644 index 0000000000..01f34e5c7a --- /dev/null +++ b/examples/qtquick/imageelements/spritesequence.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + MouseArea { + onClicked: anim.start(); + anchors.fill: parent + } + SequentialAnimation { + id: anim + ScriptAction { script: image.goalSprite = "falling"; } + NumberAnimation { target: image; property: "y"; to: 480; duration: 12000; } + ScriptAction { script: {image.goalSprite = ""; image.jumpTo("still");} } + PropertyAction { target: image; property: "y"; value: 0 } + } + SpriteSequence { + id: image + width: 256 + height: 256 + anchors.horizontalCenter: parent.horizontalCenter + interpolate: false + goalSprite: "" + Sprite{ + name: "still" + source: "content/BearSheet.png" + frameCount: 1 + frameWidth: 256 + frameHeight: 256 + frameDuration: 100 + to: {"still":1, "blink":0.1, "floating":0} + } + Sprite{ + name: "blink" + source: "content/BearSheet.png" + frameCount: 3 + frameX: 256 + frameY: 1536 + frameWidth: 256 + frameHeight: 256 + frameDuration: 100 + to: {"still":1} + } + Sprite{ + name: "floating" + source: "content/BearSheet.png" + frameCount: 9 + frameX: 0 + frameY: 0 + frameWidth: 256 + frameHeight: 256 + frameDuration: 160 + to: {"still":0, "flailing":1} + } + Sprite{ + name: "flailing" + source: "content/BearSheet.png" + frameCount: 8 + frameX: 0 + frameY: 768 + frameWidth: 256 + frameHeight: 256 + frameDuration: 160 + to: {"falling":1} + } + Sprite{ + name: "falling" + source: "content/BearSheet.png" + frameCount: 5 + frameY: 1280 + frameWidth: 256 + frameHeight: 256 + frameDuration: 160 + to: {"falling":1} + } + } +} -- cgit v1.2.3 From c4fa565379d82050ec0c114c6cef01474ea506ed Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 29 Feb 2012 14:37:33 +1000 Subject: Fix crash when transition finishes after view is deleted Change-Id: I5bb525bab735536fa7ae3a7f60bf775cd93cf3c1 Reviewed-by: Martin Jones --- src/quick/items/qquickitemview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index 600b72dfcb..5d58cbf4f5 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -1318,6 +1318,8 @@ QQuickItemViewPrivate::QQuickItemViewPrivate() QQuickItemViewPrivate::~QQuickItemViewPrivate() { + if (transitioner) + transitioner->setChangeListener(0); delete transitioner; } -- cgit v1.2.3 From 318f15e3d379f41c2fd74d1b801586e572f3affd Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 29 Feb 2012 15:47:03 +1000 Subject: Check item before notifying transition has finished Fixes crash when using SmoothedAnimation with view transitions Change-Id: Ib9a201e417c34d64f8144a616e75cae8b67568e2 Reviewed-by: Andrew den Exter --- src/quick/items/qquickitemviewtransition.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp index 0f092b76c3..ea81e14871 100644 --- a/src/quick/items/qquickitemviewtransition.cpp +++ b/src/quick/items/qquickitemviewtransition.cpp @@ -163,8 +163,6 @@ void QQuickItemViewTransitionJob::finished() { QDeclarativeTransitionManager::finished(); - if (m_item) - m_item->finishedTransition(); if (m_transitioner) m_transitioner->finishedTransition(m_item); @@ -245,8 +243,11 @@ void QQuickItemViewTransitioner::transitionNextReposition(QQuickViewItem *item, void QQuickItemViewTransitioner::finishedTransition(QQuickViewItem *item) { - if (changeListener) - changeListener->viewItemTransitionFinished(item); + if (item) { + item->finishedTransition(); + if (changeListener) + changeListener->viewItemTransitionFinished(item); + } } -- cgit v1.2.3 From 6b3b47539967722ee18d072c004e96ba1acb3234 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 28 Feb 2012 17:29:40 +1000 Subject: Update item position in parent change atomically. Changing x and y individually generates two geometry changed events, the first of which has an invalid position as the x coordinate is relative to the new parent and the y relative to the old parent. This in turn causes the Drag item to send move events with incorrect positions. Task-number: QTBUG-24534 Change-Id: If2636a968acc0fffce21d1a7e51510426ace38a0 Reviewed-by: Michael Brasser --- src/quick/items/qquickstateoperations.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/quick/items/qquickstateoperations.cpp b/src/quick/items/qquickstateoperations.cpp index c4dd0fd146..ca2a94716a 100644 --- a/src/quick/items/qquickstateoperations.cpp +++ b/src/quick/items/qquickstateoperations.cpp @@ -132,8 +132,7 @@ void QQuickParentChangePrivate::doChange(QQuickItem *targetParent, QQuickItem *s if (ok) { //qDebug() << x << y << rotation << scale; - target->setX(x); - target->setY(y); + target->setPos(QPointF(x, y)); target->setRotation(target->rotation() + rotation); target->setScale(target->scale() * scale); } -- cgit v1.2.3 From ae4c3c14e2535fbbf439c2baeb4333bbc21c2a96 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Wed, 29 Feb 2012 11:37:42 +1000 Subject: Allow styled text to be elided. Task-number: QTBUG-24521 Change-Id: Idd451d0a8a238a60691386726e34054c0368b658 Reviewed-by: Yann Bodson --- src/quick/items/qquicktext.cpp | 72 ++- src/quick/items/qquicktext_p_p.h | 2 + .../auto/qtquick2/qquicktext/data/fontSizeMode.qml | 2 - tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp | 521 ++++++++++----------- 4 files changed, 314 insertions(+), 283 deletions(-) diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index f0ce26ed62..6d1cc0d8d2 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -612,6 +612,22 @@ void QQuickTextPrivate::setupCustomLineGeometry(QTextLine &line, qreal &height, #endif } +void QQuickTextPrivate::elideFormats( + const int start, const int length, int offset, QList *elidedFormats) +{ + const int end = start + length; + QList formats = layout.additionalFormats(); + for (int i = 0; i < formats.count(); ++i) { + QTextLayout::FormatRange format = formats.at(i); + const int formatLength = qMin(format.start + format.length, end) - qMax(format.start, start); + if (formatLength > 0) { + format.start = qMax(offset, format.start - start + offset); + format.length = formatLength; + elidedFormats->append(format); + } + } +} + QString QQuickTextPrivate::elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine) const { if (nextLine) { @@ -624,12 +640,15 @@ QString QQuickTextPrivate::elidedText(qreal lineWidth, const QTextLine &line, QT line.textLength() + nextLine->textLength()); } else { QString elideText = layout.text().mid(line.textStart(), line.textLength()); - elideText[elideText.length() - 1] = elideChar; - // Appending the elide character may push the line over the maximum width - // in which case the elided text will need to be elided. - QFontMetricsF metrics(layout.font()); - if (metrics.width(elideChar) + line.naturalTextWidth() >= lineWidth) - elideText = metrics.elidedText(elideText, Qt::TextElideMode(elideMode), lineWidth); + if (!styledText) { + // QFontMetrics won't help eliding styled text. + elideText[elideText.length() - 1] = elideChar; + // Appending the elide character may push the line over the maximum width + // in which case the elided text will need to be elided. + QFontMetricsF metrics(layout.font()); + if (metrics.width(elideChar) + line.naturalTextWidth() >= lineWidth) + elideText = metrics.elidedText(elideText, Qt::TextElideMode(elideMode), lineWidth); + } return elideText; } } @@ -690,9 +709,8 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) const bool customLayout = isLineLaidOutConnected(); const bool wasTruncated = truncated; - const bool singlelineElide = !styledText && elideMode != QQuickText::ElideNone && q->widthValid(); - const bool multilineElide = !styledText - && elideMode == QQuickText::ElideRight + const bool singlelineElide = elideMode != QQuickText::ElideNone && q->widthValid(); + const bool multilineElide = elideMode == QQuickText::ElideRight && q->widthValid() && (q->heightValid() || maximumLineCountValid); const bool canWrap = wrapMode != QQuickText::NoWrap && q->widthValid(); @@ -719,6 +737,8 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) qreal height = 0; QString elideText; bool once = true; + int elideStart = 0; + int elideEnd = 0; *naturalWidth = 0; @@ -773,6 +793,9 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) elideText = layoutText.at(line.textStart() - 1) != QChar::LineSeparator ? elidedText(lineWidth, previousLine, &line) : elidedText(lineWidth, previousLine); + elideStart = previousLine.textStart(); + // elideEnd isn't required for right eliding. + // The previous line is the last one visible so move the current one off somewhere // out of the way and back everything up one line. line.setLineWidth(0); @@ -800,6 +823,8 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) 0, line.textStart(), line.textLength()); + elideStart = line.textStart(); + elideEnd = elideStart + line.textLength(); } else { br = br.united(line.naturalTextRect()); } @@ -825,6 +850,8 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) elideText = wrappedLine ? elidedText(lineWidth, line, &nextLine) : elidedText(lineWidth, line); + elideStart = line.textStart(); + // elideEnd isn't required for right eliding. } else { br = br.united(line.naturalTextRect()); } @@ -917,6 +944,33 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const naturalWidth) if (elide) { if (!elideLayout) elideLayout = new QTextLayout; + if (styledText) { + QList formats; + switch (elideMode) { + case QQuickText::ElideRight: + elideFormats(elideStart, elideText.length() - 1, 0, &formats); + break; + case QQuickText::ElideLeft: + elideFormats(elideEnd - elideText.length() + 1, elideText.length() - 1, 1, &formats); + break; + case QQuickText::ElideMiddle: { + const int index = elideText.indexOf(elideChar); + if (index != -1) { + elideFormats(elideStart, index, 0, &formats); + elideFormats( + elideEnd - elideText.length() + index + 1, + elideText.length() - index - 1, + index + 1, + &formats); + } + break; + } + default: + break; + } + elideLayout->setAdditionalFormats(formats); + } + elideLayout->setFont(layout.font()); elideLayout->setTextOption(layout.textOption()); elideLayout->setText(elideText); diff --git a/src/quick/items/qquicktext_p_p.h b/src/quick/items/qquicktext_p_p.h index e61eea90ae..3be62541ea 100644 --- a/src/quick/items/qquicktext_p_p.h +++ b/src/quick/items/qquicktext_p_p.h @@ -82,7 +82,9 @@ public: void mirrorChange(); bool isLineLaidOutConnected(); void setLineGeometry(QTextLine &line, qreal lineWidth, qreal &height); + QString elidedText(qreal lineWidth, const QTextLine &line, QTextLine *nextLine = 0) const; + void elideFormats(int start, int length, int offset, QList *elidedFormats); QRectF layedOutTextRect; diff --git a/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml b/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml index 20f7535365..84f7ce8d50 100644 --- a/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml +++ b/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml @@ -19,6 +19,4 @@ Item { font.pixelSize: 30 font.family: "Helvetica" } - - TextInput { focus: true; objectName: "input" } } diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp index 2be2dcd43d..3fd05dbcb2 100644 --- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp @@ -58,6 +58,8 @@ DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD) +Q_DECLARE_METATYPE(QQuickText::TextFormat) + class tst_qquicktext : public QDeclarativeDataTest { Q_OBJECT @@ -69,6 +71,7 @@ private slots: void width(); void wrap(); void elide(); + void multilineElide_data(); void multilineElide(); void textFormat(); @@ -440,10 +443,12 @@ void tst_qquicktext::elide() QCOMPARE(textObject->elideMode(), m); QCOMPARE(textObject->width(), 100.); + if (m != QQuickText::ElideNone && !standard.at(i).contains('\n')) + QVERIFY(textObject->contentWidth() <= textObject->width()); + delete textObject; } - // richtext - does nothing for (int i = 0; i < richText.size(); i++) { QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }"; @@ -454,17 +459,29 @@ void tst_qquicktext::elide() QCOMPARE(textObject->elideMode(), m); QCOMPARE(textObject->width(), 100.); + if (m != QQuickText::ElideNone && standard.at(i).contains("
          ")) + QVERIFY(textObject->contentWidth() <= textObject->width()); + delete textObject; } } } +void tst_qquicktext::multilineElide_data() +{ + QTest::addColumn("format"); + QTest::newRow("plain") << QQuickText::PlainText; + QTest::newRow("styled") << QQuickText::StyledText; +} + void tst_qquicktext::multilineElide() { + QFETCH(QQuickText::TextFormat, format); QQuickView *canvas = createView(testFile("multilineelide.qml")); QQuickText *myText = qobject_cast(canvas->rootObject()); QVERIFY(myText != 0); + myText->setTextFormat(format); QCOMPARE(myText->lineCount(), 3); QCOMPARE(myText->truncated(), true); @@ -1843,17 +1860,15 @@ void tst_qquicktext::imgTagsError() void tst_qquicktext::fontSizeMode_data() { QTest::addColumn("text"); - QTest::addColumn("canElide"); - QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << true; - QTest::newRow("richtext") << "The quick red fox jumped over the lazy brown dog" << false; + QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog"; + QTest::newRow("styled") << "The quick red fox jumped over the lazy brown dog"; } void tst_qquicktext::fontSizeMode() { QFETCH(QString, text); - QFETCH(bool, canElide); - QQuickView *canvas = createView(testFile("fontSizeMode.qml")); + QScopedPointer canvas(createView(testFile("fontSizeMode.qml"))); canvas->show(); QQuickText *myText = canvas->rootObject()->findChild("myText"); @@ -1881,29 +1896,27 @@ void tst_qquicktext::fontSizeMode() QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding QVERIFY(horizontalFitHeight <= myText->height() + 2); - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -1913,29 +1926,27 @@ void tst_qquicktext::fontSizeMode() QVERIFY(verticalFitHeight <= myText->height() + 2); QVERIFY(verticalFitHeight > originalHeight); - if (canElide) { - // Elide won't affect the height of a single line with VerticalFit but will crop the width. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Elide won't affect the height of a single line with VerticalFit but will crop the width. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -1943,29 +1954,27 @@ void tst_qquicktext::fontSizeMode() QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::FixedSize); myText->setWrapMode(QQuickText::Wrap); @@ -1985,17 +1994,15 @@ void tst_qquicktext::fontSizeMode() QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2006,17 +2013,15 @@ void tst_qquicktext::fontSizeMode() QVERIFY(verticalFitHeight <= myText->height() + 2); QVERIFY(verticalFitHeight < originalHeight); - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2024,17 +2029,15 @@ void tst_qquicktext::fontSizeMode() QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::FixedSize); myText->setMaximumLineCount(2); @@ -2051,17 +2054,15 @@ void tst_qquicktext::fontSizeMode() QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2072,17 +2073,15 @@ void tst_qquicktext::fontSizeMode() QVERIFY(verticalFitHeight <= myText->height() + 2); QVERIFY(verticalFitHeight < originalHeight); - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2090,33 +2089,29 @@ void tst_qquicktext::fontSizeMode() QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); } void tst_qquicktext::fontSizeModeMultiline_data() { QTest::addColumn("text"); - QTest::addColumn("canElide"); - QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog" << true; - QTest::newRow("richtext") << "The quick red fox jumped
          over the lazy brown dog
          " << false; + QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog"; + QTest::newRow("styledtext") << "The quick red fox jumped
          over the lazy brown dog
          "; } void tst_qquicktext::fontSizeModeMultiline() { QFETCH(QString, text); - QFETCH(bool, canElide); - QQuickView *canvas = createView(testFile("fontSizeMode.qml")); + QScopedPointer canvas(createView(testFile("fontSizeMode.qml"))); canvas->show(); QQuickText *myText = canvas->rootObject()->findChild("myText"); @@ -2146,31 +2141,29 @@ void tst_qquicktext::fontSizeModeMultiline() QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding QVERIFY(horizontalFitHeight > myText->height()); - if (canElide) { - // Right eliding will remove the last line - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QCOMPARE(myText->lineCount(), 1); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(myText->contentHeight() <= myText->height() + 2); - - // Left or middle eliding wont have any effect. - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), horizontalFitWidth); - QCOMPARE(myText->contentHeight(), horizontalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Right eliding will remove the last line + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QCOMPARE(myText->lineCount(), 1); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(myText->contentHeight() <= myText->height() + 2); + + // Left or middle eliding wont have any effect. + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), horizontalFitWidth); + QCOMPARE(myText->contentHeight(), horizontalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2180,30 +2173,28 @@ void tst_qquicktext::fontSizeModeMultiline() QVERIFY(verticalFitWidth <= myText->width() + 2); QVERIFY(verticalFitHeight <= myText->height() + 2); - if (canElide) { - // Elide will have no effect. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Elide will have no effect. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2211,29 +2202,27 @@ void tst_qquicktext::fontSizeModeMultiline() QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); - - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideLeft); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideMiddle); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); + + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::FixedSize); myText->setWrapMode(QQuickText::Wrap); @@ -2253,17 +2242,15 @@ void tst_qquicktext::fontSizeModeMultiline() QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); - if (canElide) { - // Text will be elided vertically with HorizontalFit - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(myText->contentHeight() <= myText->height() + 2); + // Text will be elided vertically with HorizontalFit + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(myText->contentHeight() <= myText->height() + 2); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2274,17 +2261,15 @@ void tst_qquicktext::fontSizeModeMultiline() QVERIFY(verticalFitHeight <= myText->height() + 2); QVERIFY(verticalFitHeight < originalHeight); - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2292,17 +2277,15 @@ void tst_qquicktext::fontSizeModeMultiline() QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::FixedSize); myText->setMaximumLineCount(2); @@ -2319,17 +2302,15 @@ void tst_qquicktext::fontSizeModeMultiline() QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); - if (canElide) { - // Elide won't affect the size with HorizontalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(myText->truncated()); - QVERIFY(myText->contentWidth() <= myText->width() + 2); - QVERIFY(myText->contentHeight() <= myText->height() + 2); + // Elide won't affect the size with HorizontalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(myText->truncated()); + QVERIFY(myText->contentWidth() <= myText->width() + 2); + QVERIFY(myText->contentHeight() <= myText->height() + 2); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::VerticalFit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2340,17 +2321,15 @@ void tst_qquicktext::fontSizeModeMultiline() QVERIFY(verticalFitHeight <= myText->height() + 2); QVERIFY(verticalFitHeight < originalHeight); - if (canElide) { - // Elide won't affect the height or width of a wrapped text with VerticalFit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the height or width of a wrapped text with VerticalFit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); myText->setFontSizeMode(QQuickText::Fit); QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); @@ -2358,17 +2337,15 @@ void tst_qquicktext::fontSizeModeMultiline() QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); - if (canElide) { - // Elide won't affect the size with Fit. - myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->contentWidth(), verticalFitWidth); - QCOMPARE(myText->contentHeight(), verticalFitHeight); + // Elide won't affect the size with Fit. + myText->setElideMode(QQuickText::ElideRight); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(!myText->truncated()); + QCOMPARE(myText->contentWidth(), verticalFitWidth); + QCOMPARE(myText->contentHeight(), verticalFitHeight); - myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); - } + myText->setElideMode(QQuickText::ElideNone); + QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); } void tst_qquicktext::multilengthStrings_data() -- cgit v1.2.3 From 22a5c42b83c5bff8d3b47b3b7f0d096fa212d0a6 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Thu, 1 Mar 2012 08:57:32 +1000 Subject: Fix material compare for distance field glyph nodes. The compare function did not take into account the GL texture ID when comparing materials. This could result in a renderer merging glyph nodes into a single batch incorrectly. Change-Id: Ib62c43f93fb1bbbc231197323dced4254ffa12aa Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp index e525d2a458..f9c8349c2c 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp @@ -233,7 +233,11 @@ int QSGDistanceFieldTextMaterial::compare(const QSGMaterial *o) const } QRgb c1 = m_color.rgba(); QRgb c2 = other->m_color.rgba(); - return int(c2 < c1) - int(c1 < c2); + if (c1 != c2) + return int(c2 < c1) - int(c1 < c2); + int t0 = m_texture ? m_texture->textureId : -1; + int t1 = other->m_texture ? other->m_texture->textureId : -1; + return t0 - t1; } -- cgit v1.2.3 From 5422a86b39490c30ca86a272a111c3d7da15fb3f Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 1 Mar 2012 10:40:22 +1000 Subject: No double click event in QML_TRANSLATE_TOUCH_TO_MOUSE mode Since double clicks are delivered before the click, the initial grab may not have been established. Change-Id: Id9282489f0551d421da800294e88ead0915482cc Reviewed-by: Michael Brasser --- src/quick/items/qquickcanvas.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp index e6a3e87401..670baa8df7 100644 --- a/src/quick/items/qquickcanvas.cpp +++ b/src/quick/items/qquickcanvas.cpp @@ -378,10 +378,17 @@ void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event) QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseButtonDblClick, p); me.setTimestamp(event->timestamp()); me.setAccepted(false); - deliverMouseEvent(&me); - if (me.isAccepted()) { - touchMouseId = p.id(); - event->setAccepted(true); + if (!mouseGrabberItem) { + if (deliverInitialMousePressEvent(rootItem, &me)) { + touchMouseId = p.id(); + event->setAccepted(true); + } + } else { + deliverMouseEvent(&me); + if (me.isAccepted()) { + touchMouseId = p.id(); + event->setAccepted(true); + } } } QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseButtonPress, p); @@ -391,8 +398,9 @@ void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event) if (me.isAccepted()) { touchMouseId = p.id(); event->setAccepted(true); - break; } + if (touchMouseId != -1) + break; } else if (p.id() == touchMouseId) { if (p.state() & Qt::TouchPointMoved) { QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseMove, p); -- cgit v1.2.3 From c0da7869001a52668f4ffaa851e05dd0ca6e6d67 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 1 Mar 2012 11:24:57 +0100 Subject: Avoid unnecessary updates when using in-process cache Whenever an in-process cache is updated, it will emit itemsAvailable() signals to all listening glyph caches. This will in turn cause each of the glyph caches to update and each of the glyph nodes to be preprocessed (the entire scene graph will be updated.) This happens even if the changes to the in-process cache are requested by an external client, due to a cross-process cache sharing mechanism. However, itemsAvailable() signals are only interesting if the items were requested by the in-process cache. We therefore add a mechanism now to check if the glyphs were actually requested by the cache before updating anything. Change-Id: I529f94b3928c2a5e06fec354014fa11d21671057 Reviewed-by: Jiang Jiang --- .../qsgshareddistancefieldglyphcache.cpp | 39 +++++++++++++++++++--- .../qsgshareddistancefieldglyphcache_p.h | 2 ++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp index e762898602..951ee210c5 100644 --- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp @@ -90,7 +90,7 @@ QSGSharedDistanceFieldGlyphCache::QSGSharedDistanceFieldGlyphCache(const QByteAr this, SLOT(reportItemsAvailable(QByteArray,void*,QSize,QVector,QVector)), Qt::DirectConnection); connect(sharedGraphicsCache, SIGNAL(itemsUpdated(QByteArray,void*,QSize,QVector,QVector)), - this, SLOT(reportItemsAvailable(QByteArray,void*,QSize,QVector,QVector)), + this, SLOT(reportItemsUpdated(QByteArray,void*,QSize,QVector,QVector)), Qt::DirectConnection); connect(sharedGraphicsCache, SIGNAL(itemsInvalidated(QByteArray,QVector)), this, SLOT(reportItemsInvalidated(QByteArray,QVector)), @@ -542,9 +542,38 @@ void QSGSharedDistanceFieldGlyphCache::processPendingGlyphs() } void QSGSharedDistanceFieldGlyphCache::reportItemsAvailable(const QByteArray &cacheId, - void *bufferId, const QSize &bufferSize, - const QVector &itemIds, - const QVector &positions) + void *bufferId, + const QSize &bufferSize, + const QVector &itemIds, + const QVector &positions) +{ + bool requestedItemsInList = false; + { + QMutexLocker locker(&m_pendingGlyphsMutex); + if (m_cacheId != cacheId) + return; + +#if defined(QSGSHAREDDISTANCEFIELDGLYPHCACHE_DEBUG) + qDebug("QSGSharedDistanceFieldGlyphCache::reportItemsAvailable() called for %s (%d glyphs, bufferSize: %dx%d)", + cacheId.constData(), itemIds.size(), bufferSize.width(), bufferSize.height()); +#endif + + for (int i=0; i &itemIds, + const QVector &positions) { { QMutexLocker locker(&m_pendingGlyphsMutex); @@ -554,7 +583,7 @@ void QSGSharedDistanceFieldGlyphCache::reportItemsAvailable(const QByteArray &ca Q_ASSERT(itemIds.size() == positions.size()); #if defined(QSGSHAREDDISTANCEFIELDGLYPHCACHE_DEBUG) - qDebug("QSGSharedDistanceFieldGlyphCache::reportItemsAvailable() called for %s (%d glyphs, bufferSize: %dx%d)", + qDebug("QSGSharedDistanceFieldGlyphCache::reportItemsUpdated() called for %s (%d glyphs, bufferSize: %dx%d)", cacheId.constData(), itemIds.size(), bufferSize.width(), bufferSize.height()); #endif diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h index cadf4bc55b..8250b9706e 100644 --- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h +++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h @@ -78,6 +78,8 @@ private Q_SLOTS: void reportItemsAvailable(const QByteArray &cacheId, void *bufferId, const QSize &bufferSize, const QVector &itemIds, const QVector &positions); + void reportItemsUpdated(const QByteArray &cacheId, void *bufferId, const QSize &bufferSize, + const QVector &itemIds, const QVector &positions); void reportItemsInvalidated(const QByteArray &cacheId, const QVector &itemIds); private: -- cgit v1.2.3 From 6c5955e58f885cf5b4597b8fb0a059d204e2a5e1 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 1 Mar 2012 12:34:48 +0100 Subject: Set bind options before uploading to give hints to the driver This can prevent allocation of unused mipmap levels on some drivers. Change-Id: I2d730c04e120872367078b17a344c01b4d4aa87a Reviewed-by: Kim M. Kalland --- src/quick/scenegraph/util/qsgtexture.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/quick/scenegraph/util/qsgtexture.cpp b/src/quick/scenegraph/util/qsgtexture.cpp index 7ccedc4c48..4dff1b2a3d 100644 --- a/src/quick/scenegraph/util/qsgtexture.cpp +++ b/src/quick/scenegraph/util/qsgtexture.cpp @@ -496,6 +496,8 @@ void QSGPlainTexture::bind() ? m_image : m_image.convertToFormat(QImage::Format_ARGB32_Premultiplied); + updateBindOptions(m_dirty_bind_options); + #ifdef QT_OPENGL_ES swizzleBGRAToRGBA(&tmp); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmp.constBits()); @@ -512,7 +514,6 @@ void QSGPlainTexture::bind() m_texture_size = QSize(w, h); m_texture_rect = QRectF(0, 0, 1, 1); - updateBindOptions(m_dirty_bind_options); m_dirty_bind_options = false; } -- cgit v1.2.3 From 8af34203ec302c5ab630d2fba700a6f60d9c8096 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 29 Feb 2012 13:28:51 +0100 Subject: Profiler: Remove unused method Change-Id: I74ba20b495760034bc714d92bcf016feddf87c2c Reviewed-by: Christiaan Janssen --- src/declarative/debugger/qdeclarativeprofilerservice.cpp | 5 ----- src/declarative/debugger/qdeclarativeprofilerservice_p.h | 1 - 2 files changed, 6 deletions(-) diff --git a/src/declarative/debugger/qdeclarativeprofilerservice.cpp b/src/declarative/debugger/qdeclarativeprofilerservice.cpp index 17ee3e5836..074355fe97 100644 --- a/src/declarative/debugger/qdeclarativeprofilerservice.cpp +++ b/src/declarative/debugger/qdeclarativeprofilerservice.cpp @@ -144,11 +144,6 @@ void QDeclarativeProfilerService::rangeData(RangeType t, const QString &data) profilerInstance()->rangeDataImpl(t, data); } -void QDeclarativeProfilerService::rangeData(RangeType t, const QUrl &data) -{ - profilerInstance()->rangeDataImpl(t, data); -} - void QDeclarativeProfilerService::rangeLocation(RangeType t, const QString &fileName, int line, int column) { profilerInstance()->rangeLocationImpl(t, fileName, line, column); diff --git a/src/declarative/debugger/qdeclarativeprofilerservice_p.h b/src/declarative/debugger/qdeclarativeprofilerservice_p.h index d29690b6d6..d2f263cca6 100644 --- a/src/declarative/debugger/qdeclarativeprofilerservice_p.h +++ b/src/declarative/debugger/qdeclarativeprofilerservice_p.h @@ -134,7 +134,6 @@ public: static void addEvent(EventType); static void startRange(RangeType); static void rangeData(RangeType, const QString &); - static void rangeData(RangeType, const QUrl &); static void rangeLocation(RangeType, const QString &, int, int); static void rangeLocation(RangeType, const QUrl &, int, int); static void endRange(RangeType); -- cgit v1.2.3 From df014e5f3ea16dfaecb6852fbc2b2ab8351afafe Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 29 Feb 2012 13:29:06 +0100 Subject: Profiler: Avoid QString->QUrl->QString conversion Change-Id: Ib39b94bf6c76638dce96d6cc20a4a8f307e37878 Reviewed-by: Christiaan Janssen --- src/declarative/qml/qdeclarativetypeloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativetypeloader.cpp b/src/declarative/qml/qdeclarativetypeloader.cpp index 0524d5d661..a07e4fb04b 100644 --- a/src/declarative/qml/qdeclarativetypeloader.cpp +++ b/src/declarative/qml/qdeclarativetypeloader.cpp @@ -1583,7 +1583,7 @@ void QDeclarativeTypeData::compile() m_compiledData = new QDeclarativeCompiledData(typeLoader()->engine()); m_compiledData->url = finalUrl(); m_compiledData->name = finalUrlString(); - QDeclarativeProfilerService::rangeLocation(QDeclarativeProfilerService::Compiling, QUrl(m_compiledData->name),1,1); + QDeclarativeProfilerService::rangeLocation(QDeclarativeProfilerService::Compiling, m_compiledData->name,1,1); QDeclarativeProfilerService::rangeData(QDeclarativeProfilerService::Compiling, m_compiledData->name); QDeclarativeCompiler compiler(&scriptParser._pool); -- cgit v1.2.3 From 07aea54a90c9bee45420893be1be9761a3a488d9 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 2 Mar 2012 11:53:29 +1000 Subject: Pin to a working qtbase SHA1 A bug with qmake was introduced which is impeding the compilation of modules we depend on. Use an older qtbase and qmake until this is fixed. Task-number: QTBUG-24608 Change-Id: I7f6f1f383d4c9339e5f4c699cb8900a3b1c776e3 Reviewed-by: Toby Tomkins --- sync.profile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sync.profile b/sync.profile index efde01d952..0265d1dbe9 100644 --- a/sync.profile +++ b/sync.profile @@ -31,7 +31,7 @@ # - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch) # %dependencies = ( - "qtbase" => "refs/heads/master", + "qtbase" => "95c5be8bc1c8f9ff8e7f95e52a8abd3cd7976ba1", "qtxmlpatterns" => "refs/heads/master", "qtjsbackend" => "refs/heads/master", ); -- cgit v1.2.3 From a7c56b79d2f682b1e82b6b92d11fc942148d8c3b Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 1 Mar 2012 10:34:01 +1000 Subject: More verbose compiler stats. Report shared and unshared v8 bindings separately. Change-Id: Iaa198dcc93035a778b13d7137742a7b308aa782f Reviewed-by: Chris Adams --- src/declarative/qml/qdeclarativecompiler.cpp | 28 +++++++++++++++++++++++++--- src/declarative/qml/qdeclarativecompiler_p.h | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index b7b882cd97..aaa1acaaa3 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -3613,12 +3613,15 @@ bool QDeclarativeCompiler::completeComponentBuild() binding.property->type != qMetaTypeId()) { binding.dataType = BindingReference::V8; sharedBindings.append(b); + + if (componentStats) + componentStats->componentStat.sharedBindings.append(b->value->location); } else { binding.dataType = BindingReference::QtScript; - } - if (componentStats) - componentStats->componentStat.scriptBindings.append(b->value->location); + if (componentStats) + componentStats->componentStat.scriptBindings.append(b->value->location); + } } if (!sharedBindings.isEmpty()) { @@ -3699,6 +3702,25 @@ void QDeclarativeCompiler::dumpStats() qWarning().nospace() << output.constData(); } + qWarning().nospace() << " Shared Bindings: " << stat.sharedBindings.count(); + { + QByteArray output; + for (int ii = 0; ii < stat.sharedBindings.count(); ++ii) { + if (0 == (ii % 10)) { + if (ii) output.append("\n"); + output.append(" "); + } + + output.append("("); + output.append(QByteArray::number(stat.sharedBindings.at(ii).start.line)); + output.append(":"); + output.append(QByteArray::number(stat.sharedBindings.at(ii).start.column)); + output.append(") "); + } + if (!output.isEmpty()) + qWarning().nospace() << output.constData(); + } + qWarning().nospace() << " QScript Bindings: " << stat.scriptBindings.count(); { QByteArray output; diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h index 637cd80569..3ef4668b79 100644 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ b/src/declarative/qml/qdeclarativecompiler_p.h @@ -450,6 +450,7 @@ private: int ids; QList scriptBindings; + QList sharedBindings; QList optimizedBindings; int objects; }; -- cgit v1.2.3 From 61ab01252d928576bf9ef1d8c6cc421e1a825dde Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 29 Feb 2012 13:54:16 +1000 Subject: Reenable value type binding auto removal tests. Change-Id: I349017bf24f9f2f18024d1257eeaebb348cc8503 Reviewed-by: Chris Adams --- .../declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index e701efa2a4..15001f70c8 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -951,7 +951,6 @@ void tst_qdeclarativevaluetypes::autoBindingRemoval() delete object; } - /* { QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml")); MyTypeObject *object = qobject_cast(component.create()); @@ -976,6 +975,8 @@ void tst_qdeclarativevaluetypes::autoBindingRemoval() { QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml")); + QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QRect"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -993,7 +994,6 @@ void tst_qdeclarativevaluetypes::autoBindingRemoval() delete object; } -*/ } // Test that property value sources assign to value types -- cgit v1.2.3 From 8bcedb39a738e417fb9c159dc2eb003873d60271 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 1 Mar 2012 19:04:29 +1000 Subject: V4 handles a maximum of 32 temporary registers. Drop back to V8 if there are more than 32 being used. Change-Id: I11f6e84746d897cd9b6789a5e9e4d2848909de00 Reviewed-by: Roberto Raggi --- src/declarative/qml/v4/qv4compiler.cpp | 5 +++-- src/declarative/qml/v4/qv4compiler_p_p.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/v4/qv4compiler.cpp b/src/declarative/qml/v4/qv4compiler.cpp index 42e56d12c9..29023ae66e 100644 --- a/src/declarative/qml/v4/qv4compiler.cpp +++ b/src/declarative/qml/v4/qv4compiler.cpp @@ -62,7 +62,7 @@ static bool qmlEnableV4 = true; using namespace QDeclarativeJS; QV4CompilerPrivate::QV4CompilerPrivate() -: _function(0) , _block(0) , _discarded(false) + : _function(0) , _block(0) , _discarded(false), registerCount(0) { } @@ -74,6 +74,7 @@ void QV4CompilerPrivate::trace(int line, int column) bytecode.clear(); this->currentReg = _function->tempCount; + this->registerCount = qMax(this->registerCount, this->currentReg); foreach (IR::BasicBlock *bb, _function->basicBlocks) { if (! bb->isTerminated() && (bb->index + 1) < _function->basicBlocks.size()) @@ -1118,7 +1119,7 @@ bool QV4CompilerPrivate::compile(QDeclarativeJS::AST::Node *node) qerr << endl; } - if (discarded || subscriptionIds.count() > 0xFFFF || registeredStrings.count() > 0xFFFF) + if (discarded || subscriptionIds.count() > 0xFFFF || registeredStrings.count() > 0xFFFF || registerCount > 31) return false; return true; diff --git a/src/declarative/qml/v4/qv4compiler_p_p.h b/src/declarative/qml/v4/qv4compiler_p_p.h index 85a7c36f87..c43140663e 100644 --- a/src/declarative/qml/v4/qv4compiler_p_p.h +++ b/src/declarative/qml/v4/qv4compiler_p_p.h @@ -231,6 +231,7 @@ private: void discard() { _discarded = true; } bool _discarded; quint8 currentReg; + quint8 registerCount; bool usedSubscriptionIdsChanged; quint32 currentBlockMask; -- cgit v1.2.3 From e8ee323b9f7889ec1423cece7a3ab6f116a6ff14 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 2 Mar 2012 11:54:58 +1000 Subject: Correct QDeclarativeInspectorInterface iid Change-Id: I874c501dc1839712d2da663f13e437e3c7a0e4fe Reviewed-by: Matthew Vogt --- src/declarative/debugger/qdeclarativeinspectorinterface_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h index adfd94333d..77f208ce5b 100644 --- a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h +++ b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h @@ -74,7 +74,7 @@ public: virtual void clientMessage(const QByteArray &message) = 0; }; -#define QDeclarativeInspectorInterface_iid "org.qt-project.Qt." +#define QDeclarativeInspectorInterface_iid "org.qt-project.Qt.QDeclarativeInspectorInterface" Q_DECLARE_INTERFACE(QDeclarativeInspectorInterface, QDeclarativeInspectorInterface_iid) -- cgit v1.2.3 From 3b01983d4f21cbd53745bb9132b9b2fffb019077 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 1 Mar 2012 17:37:11 +1000 Subject: Fix if transitioner is deleted before transition job finishes Don't let TransitionJob call finishedTransition() on a deleted transitioner. Also don't use target transitions that are not enabled. Change-Id: I94d58e8c7b072f7f3d76533956cac2d63ac33ff6 Reviewed-by: Alan Alpert --- src/quick/items/qquickitemviewtransition.cpp | 163 +++++++++++++++++---------- src/quick/items/qquickitemviewtransition_p.h | 10 +- 2 files changed, 111 insertions(+), 62 deletions(-) diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp index ea81e14871..9235321418 100644 --- a/src/quick/items/qquickitemviewtransition.cpp +++ b/src/quick/items/qquickitemviewtransition.cpp @@ -45,14 +45,17 @@ QT_BEGIN_NAMESPACE +static QList qquickitemviewtransition_emptyIndexes = QList(); +static QList qquickitemviewtransition_emptyTargets = QList(); + class QQuickItemViewTransitionJob : public QDeclarativeTransitionManager { public: - QQuickItemViewTransitionJob(QQuickItemViewTransitioner *transitioner); + QQuickItemViewTransitionJob(); ~QQuickItemViewTransitionJob(); - void startTransition(QQuickViewItem *item, QQuickItemViewTransitioner::TransitionType type, const QPointF &to, bool isTargetItem); + void startTransition(QQuickViewItem *item, QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, const QPointF &to, bool isTargetItem); QQuickItemViewTransitioner *m_transitioner; QQuickViewItem *m_item; @@ -65,59 +68,41 @@ protected: }; -QQuickItemViewTransitionJob::QQuickItemViewTransitionJob(QQuickItemViewTransitioner *transitioner) - : m_transitioner(transitioner) - , m_item(0), m_type(QQuickItemViewTransitioner::NoTransition), m_isTarget(false) +QQuickItemViewTransitionJob::QQuickItemViewTransitionJob() + : m_transitioner(0) + , m_item(0) + , m_type(QQuickItemViewTransitioner::NoTransition) + , m_isTarget(false) { } QQuickItemViewTransitionJob::~QQuickItemViewTransitionJob() { + if (m_transitioner) + m_transitioner->runningJobs.remove(this); } -void QQuickItemViewTransitionJob::startTransition(QQuickViewItem *item, QQuickItemViewTransitioner::TransitionType type, const QPointF &to, bool isTargetItem) +void QQuickItemViewTransitionJob::startTransition(QQuickViewItem *item, QQuickItemViewTransitioner *transitioner, QQuickItemViewTransitioner::TransitionType type, const QPointF &to, bool isTargetItem) { + if (type == QQuickItemViewTransitioner::NoTransition) + return; if (!item) { qWarning("startTransition(): invalid item"); return; } - - QDeclarativeTransition *trans = 0; - switch (type) { - case QQuickItemViewTransitioner::NoTransition: - break; - case QQuickItemViewTransitioner::PopulateTransition: - trans = m_transitioner->populateTransition; - break; - case QQuickItemViewTransitioner::AddTransition: - if (isTargetItem) - trans = m_transitioner->addTransition; - else - trans = (m_transitioner->addDisplacedTransition && m_transitioner->addDisplacedTransition->enabled()) ? - m_transitioner->addDisplacedTransition : m_transitioner->displacedTransition; - break; - case QQuickItemViewTransitioner::MoveTransition: - if (isTargetItem) - trans = m_transitioner->moveTransition; - else - trans = (m_transitioner->moveDisplacedTransition && m_transitioner->moveDisplacedTransition->enabled()) ? - m_transitioner->moveDisplacedTransition : m_transitioner->displacedTransition; - break; - case QQuickItemViewTransitioner::RemoveTransition: - if (isTargetItem) - trans = m_transitioner->removeTransition; - else - trans = (m_transitioner->removeDisplacedTransition && m_transitioner->removeDisplacedTransition->enabled()) ? - m_transitioner->removeDisplacedTransition : m_transitioner->displacedTransition; - break; + if (!transitioner) { + qWarning("startTransition(): invalid transitioner"); + return; } + QDeclarativeTransition *trans = transitioner->transitionObject(type, isTargetItem); if (!trans) { qWarning("QQuickItemView: invalid view transition!"); return; } m_item = item; + m_transitioner = transitioner; m_toPos = to; m_type = type; m_isTarget = isTargetItem; @@ -128,23 +113,8 @@ void QQuickItemViewTransitionJob::startTransition(QQuickViewItem *item, QQuickIt attached->m_index = item->index; attached->m_item = item->item; attached->m_destination = to; - switch (type) { - case QQuickItemViewTransitioner::NoTransition: - break; - case QQuickItemViewTransitioner::PopulateTransition: - case QQuickItemViewTransitioner::AddTransition: - attached->m_targetIndexes = m_transitioner->addTransitionIndexes; - attached->m_targetItems = m_transitioner->addTransitionTargets; - break; - case QQuickItemViewTransitioner::MoveTransition: - attached->m_targetIndexes = m_transitioner->moveTransitionIndexes; - attached->m_targetItems = m_transitioner->moveTransitionTargets; - break; - case QQuickItemViewTransitioner::RemoveTransition: - attached->m_targetIndexes = m_transitioner->removeTransitionIndexes; - attached->m_targetItems = m_transitioner->removeTransitionTargets; - break; - } + attached->m_targetIndexes = m_transitioner->targetIndexes(type); + attached->m_targetItems = m_transitioner->targetItems(type); emit attached->indexChanged(); emit attached->itemChanged(); emit attached->destinationChanged(); @@ -156,6 +126,7 @@ void QQuickItemViewTransitionJob::startTransition(QQuickViewItem *item, QQuickIt actions << QDeclarativeAction(item->item, QLatin1String("x"), QVariant(to.x())); actions << QDeclarativeAction(item->item, QLatin1String("y"), QVariant(to.y())); + m_transitioner->runningJobs << this; QDeclarativeTransitionManager::transition(actions, trans, item->item); } @@ -164,7 +135,7 @@ void QQuickItemViewTransitionJob::finished() QDeclarativeTransitionManager::finished(); if (m_transitioner) - m_transitioner->finishedTransition(m_item); + m_transitioner->finishedTransition(this, m_item); m_item = 0; m_toPos.setX(0); @@ -185,6 +156,12 @@ QQuickItemViewTransitioner::QQuickItemViewTransitioner() { } +QQuickItemViewTransitioner::~QQuickItemViewTransitioner() +{ + for (QSet::iterator it = runningJobs.begin(); it != runningJobs.end(); ++it) + (*it)->m_transitioner = 0; +} + bool QQuickItemViewTransitioner::canTransition(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const { if (!asTarget @@ -241,8 +218,78 @@ void QQuickItemViewTransitioner::transitionNextReposition(QQuickViewItem *item, } } -void QQuickItemViewTransitioner::finishedTransition(QQuickViewItem *item) +QDeclarativeTransition *QQuickItemViewTransitioner::transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget) { + if (type == QQuickItemViewTransitioner::NoTransition) + return 0; + + if (type == PopulateTransition) + asTarget = true; // no separate displaced transition + + QDeclarativeTransition *trans = 0; + switch (type) { + case NoTransition: + break; + case PopulateTransition: + trans = populateTransition; + break; + case AddTransition: + trans = asTarget ? addTransition : addDisplacedTransition; + break; + case MoveTransition: + trans = asTarget ? moveTransition : moveDisplacedTransition; + break; + case RemoveTransition: + trans = asTarget ? removeTransition : removeDisplacedTransition; + break; + } + + if (!asTarget && (!trans || !trans->enabled())) + trans = displacedTransition; + if (trans && trans->enabled()) + return trans; + return 0; +} + +const QList &QQuickItemViewTransitioner::targetIndexes(QQuickItemViewTransitioner::TransitionType type) const +{ + switch (type) { + case QQuickItemViewTransitioner::NoTransition: + break; + case QQuickItemViewTransitioner::PopulateTransition: + case QQuickItemViewTransitioner::AddTransition: + return addTransitionIndexes; + case QQuickItemViewTransitioner::MoveTransition: + return moveTransitionIndexes; + case QQuickItemViewTransitioner::RemoveTransition: + return removeTransitionIndexes; + } + + return qquickitemviewtransition_emptyIndexes; +} + +const QList &QQuickItemViewTransitioner::targetItems(QQuickItemViewTransitioner::TransitionType type) const +{ + switch (type) { + case QQuickItemViewTransitioner::NoTransition: + break; + case QQuickItemViewTransitioner::PopulateTransition: + case QQuickItemViewTransitioner::AddTransition: + return addTransitionTargets; + case QQuickItemViewTransitioner::MoveTransition: + return moveTransitionTargets; + case QQuickItemViewTransitioner::RemoveTransition: + return removeTransitionTargets; + } + + return qquickitemviewtransition_emptyTargets; +} + +void QQuickItemViewTransitioner::finishedTransition(QQuickItemViewTransitionJob *job, QQuickViewItem *item) +{ + if (!runningJobs.contains(job)) + return; + runningJobs.remove(job); if (item) { item->finishedTransition(); if (changeListener) @@ -263,10 +310,6 @@ QQuickViewItem::QQuickViewItem(QQuickItem *i) QQuickViewItem::~QQuickViewItem() { - if (transition) { - transition->m_item = 0; - transition->m_transitioner = 0; - } delete transition; } @@ -385,7 +428,7 @@ void QQuickViewItem::startTransition(QQuickItemViewTransitioner *transitioner) if (!transition || transition->m_type != nextTransitionType || transition->m_isTarget != isTransitionTarget) { delete transition; - transition = new QQuickItemViewTransitionJob(transitioner); + transition = new QQuickItemViewTransitionJob; } // if item is not already moving somewhere, set it to not move anywhere @@ -393,7 +436,7 @@ void QQuickViewItem::startTransition(QQuickItemViewTransitioner *transitioner) if (!nextTransitionToSet) moveTo(item->pos()); - transition->startTransition(this, nextTransitionType, nextTransitionTo, isTransitionTarget); + transition->startTransition(this, transitioner, nextTransitionType, nextTransitionTo, isTransitionTarget); nextTransitionType = QQuickItemViewTransitioner::NoTransition; } diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h index 8dd2f86899..1ebc52c185 100644 --- a/src/quick/items/qquickitemviewtransition_p.h +++ b/src/quick/items/qquickitemviewtransition_p.h @@ -77,14 +77,20 @@ public: }; QQuickItemViewTransitioner(); - virtual ~QQuickItemViewTransitioner() {} + virtual ~QQuickItemViewTransitioner(); bool canTransition(QQuickItemViewTransitioner::TransitionType type, bool asTarget) const; void transitionNextReposition(QQuickViewItem *item, QQuickItemViewTransitioner::TransitionType type, bool isTarget); + QDeclarativeTransition *transitionObject(QQuickItemViewTransitioner::TransitionType type, bool asTarget); + const QList &targetIndexes(QQuickItemViewTransitioner::TransitionType type) const; + const QList &targetItems(QQuickItemViewTransitioner::TransitionType type) const; + inline void setPopulateTransitionEnabled(bool b) { usePopulateTransition = b; } inline void setChangeListener(QQuickItemViewTransitionChangeListener *obj) { changeListener = obj; } + QSet runningJobs; + QList addTransitionIndexes; QList moveTransitionIndexes; QList removeTransitionIndexes; @@ -107,7 +113,7 @@ private: QQuickItemViewTransitionChangeListener *changeListener; bool usePopulateTransition; - void finishedTransition(QQuickViewItem *item); + void finishedTransition(QQuickItemViewTransitionJob *job, QQuickViewItem *item); }; -- cgit v1.2.3 From 79608d6f72ea5963aed2fa161b9ef6781adbc41e Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 27 Feb 2012 13:16:11 +1000 Subject: Improved transitions for Row, Column, Grid, Flow The view transitions functionality for ListView and GridView has been integrated into the positioner elements. Not all of this functionality is available for positioners, though, since they don't have models (and thus cannot identify certain model operations) and they don't manage the lifetime of their children. Task-number: QTBUG-24336 Change-Id: I71588de289555d2ef5a763af11358bc0af7b31a7 Reviewed-by: Alan Alpert --- doc/src/whatsnew.qdoc | 7 +- src/quick/items/qquickitemviewtransition.cpp | 34 +- src/quick/items/qquickpositioners.cpp | 370 +++++++++-------- src/quick/items/qquickpositioners_p.h | 16 +- src/quick/items/qquickpositioners_p_p.h | 11 +- .../qquickpositioners/data/transitions.qml | 196 +++++++++ .../qquickpositioners/qquickpositioners.pro | 1 + .../qquickpositioners/tst_qquickpositioners.cpp | 455 +++++++++++++++++++++ tests/auto/qtquick2/shared/viewtestutil.h | 1 + 9 files changed, 908 insertions(+), 183 deletions(-) create mode 100644 tests/auto/qtquick2/qquickpositioners/data/transitions.qml diff --git a/doc/src/whatsnew.qdoc b/doc/src/whatsnew.qdoc index 88d5e91d76..1c92cdb16b 100644 --- a/doc/src/whatsnew.qdoc +++ b/doc/src/whatsnew.qdoc @@ -112,8 +112,11 @@ Setting Image sourceSize.width and sourceSize.height will now fit the image to t Grid now has rowSpacing and columnSpacing properties. Spacing properties on positioners are now real numbers instead of integers. -Positioners now have attached properties that can be used to determine a subitem's location within a -container such as Column or Row: Positioner.index, Positioner.isFirstItem, Positioner.isLastItem. +Positioner (Row, Column, Grid, Flow) improvements: +\list +\o Transitions used for \c add and \c move now have improved features: they can access a ViewTransition attached property (see the ViewTransition documentation for examples) and can now animate arbitrary item properties (instead of being restricted to animating an item's position). +\o Items in a positioner now have attached properties that can be used to determine a subitem's location: Positioner.index, Positioner.isFirstItem, Positioner.isLastItem. +\endlist Loader improvements: - "active" property added to Loader, to allow delaying instantiation of a Loader element's item property diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp index 9235321418..abff768ad3 100644 --- a/src/quick/items/qquickitemviewtransition.cpp +++ b/src/quick/items/qquickitemviewtransition.cpp @@ -377,6 +377,12 @@ bool QQuickViewItem::prepareTransition(const QRectF &viewBounds) { bool doTransition = false; + // If item is not already moving somewhere, set it to not move anywhere. + // This ensures that removed targets don't transition to the default (0,0) and that + // items set for other transition types only transition if they actually move somewhere. + if (nextTransitionType != QQuickItemViewTransitioner::NoTransition && !nextTransitionToSet) + moveTo(item->pos()); + switch (nextTransitionType) { case QQuickItemViewTransitioner::NoTransition: { @@ -390,7 +396,12 @@ bool QQuickViewItem::prepareTransition(const QRectF &viewBounds) case QQuickItemViewTransitioner::RemoveTransition: // For Add targets, do transition if item is moving into visible area // For Remove targets, do transition if item is currently in visible area - if (isTransitionTarget) { + if (viewBounds.isNull()) { + if (isTransitionTarget) + doTransition = true; + else + doTransition = (nextTransitionTo != item->pos()); + } else if (isTransitionTarget) { doTransition = (nextTransitionType == QQuickItemViewTransitioner::AddTransition) ? viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height())) : viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())); @@ -408,7 +419,8 @@ bool QQuickViewItem::prepareTransition(const QRectF &viewBounds) case QQuickItemViewTransitioner::MoveTransition: // do transition if moving from or into visible area if (nextTransitionTo != item->pos()) { - doTransition = viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())) + doTransition = viewBounds.isNull() + || viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())) || viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height())); if (!doTransition) item->setPos(nextTransitionTo); @@ -503,7 +515,19 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) generic displaced transition if specified) \endlist - Such view transitions additionally have access to a ViewTransition attached property that + For the \l Row, \l Column, \l Grid and \l Flow positioner elements, which operate with collections of child + items rather than data models, the following properties are used instead: + + \list + \o \c add - the transition to apply to items that are created for the positioner, added to + or reparented to the positioner, or items that have become \l {Item::}{visible} + \o \c move - the transition to apply to items that have moved within the positioner, including + when they are displaced due to the addition or removal of other items, or when items are otherwise + rearranged within the positioner, or when items are repositioned due to the resizing of other + items in the positioner + \endlist + + View transitions have access to a ViewTransition attached property that provides details of the items that are under transition and the operation that triggered the transition. Since view transitions are run once per item, these details can be used to customise each transition for each individual item. @@ -525,6 +549,10 @@ QQuickViewTransitionAttached::QQuickViewTransitionAttached(QObject *parent) \o ViewTransition.targetItems - the target items themselves \endlist + (Note that for the \l Row, \l Column, \l Grid and \l Flow positioner elements, the \c move transition only + provides these two additional details when the transition is triggered by the addition of items + to a positioner.) + View transitions can be written without referring to any of the attributes listed above. These attributes merely provide extra details that are useful for customising view transitions. diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp index 95ee9bfb58..6ed35a9f42 100644 --- a/src/quick/items/qquickpositioners.cpp +++ b/src/quick/items/qquickpositioners.cpp @@ -109,6 +109,7 @@ QQuickBasePositioner::QQuickBasePositioner(QQuickBasePositionerPrivate &dd, Posi QQuickBasePositioner::~QQuickBasePositioner() { Q_D(QQuickBasePositioner); + delete d->transitioner; for (int i = 0; i < positionedItems.count(); ++i) d->unwatchChanges(positionedItems.at(i).item); for (int i = 0; i < unpositionedItems.count(); ++i) @@ -142,31 +143,36 @@ void QQuickBasePositioner::setSpacing(qreal s) QDeclarativeTransition *QQuickBasePositioner::move() const { Q_D(const QQuickBasePositioner); - return d->moveTransition; + return d->transitioner ? d->transitioner->displacedTransition : 0; } void QQuickBasePositioner::setMove(QDeclarativeTransition *mt) { Q_D(QQuickBasePositioner); - if (mt == d->moveTransition) + if (!d->transitioner) + d->transitioner = new QQuickItemViewTransitioner; + if (mt == d->transitioner->displacedTransition) return; - d->moveTransition = mt; + + d->transitioner->displacedTransition = mt; emit moveChanged(); } QDeclarativeTransition *QQuickBasePositioner::add() const { Q_D(const QQuickBasePositioner); - return d->addTransition; + return d->transitioner ? d->transitioner->addTransition : 0; } void QQuickBasePositioner::setAdd(QDeclarativeTransition *add) { Q_D(QQuickBasePositioner); - if (add == d->addTransition) + if (!d->transitioner) + d->transitioner = new QQuickItemViewTransitioner; + if (add == d->transitioner->addTransition) return; - d->addTransition = add; + d->transitioner->addTransition = add; emit addChanged(); } @@ -218,6 +224,7 @@ void QQuickBasePositioner::prePositioning() for (int ii = 0; ii < unpositionedItems.count(); ii++) oldItems.append(unpositionedItems[ii]); unpositionedItems.clear(); + int addedIndex = -1; for (int ii = 0; ii < children.count(); ++ii) { QQuickItem *child = children.at(ii); @@ -229,9 +236,22 @@ void QQuickBasePositioner::prePositioning() posItem.isNew = true; if (!childPrivate->explicitVisible || !child->width() || !child->height()) { posItem.isVisible = false; + posItem.index = -1; unpositionedItems.append(posItem); } else { + posItem.index = positionedItems.count(); positionedItems.append(posItem); + + if (d->transitioner) { + if (addedIndex < 0) + addedIndex = posItem.index; + PositionedItem *theItem = &positionedItems[positionedItems.count()-1]; + + d->transitioner->transitionNextReposition(theItem, + QQuickItemViewTransitioner::AddTransition, true); + d->transitioner->addTransitionIndexes << posItem.index; + d->transitioner->addTransitionTargets << posItem.item; + } } } else { PositionedItem *item = &oldItems[wIdx]; @@ -239,75 +259,93 @@ void QQuickBasePositioner::prePositioning() // i.e. their positioning is not affected if an ancestor is hidden. if (!childPrivate->explicitVisible || !child->width() || !child->height()) { item->isVisible = false; + item->index = -1; unpositionedItems.append(*item); } else if (!item->isVisible) { + // item changed from non-visible to visible, treat it as a "new" item item->isVisible = true; item->isNew = true; + item->index = positionedItems.count(); positionedItems.append(*item); + + if (d->transitioner) { + if (addedIndex < 0) + addedIndex = item->index; + d->transitioner->transitionNextReposition(&positionedItems[positionedItems.count()-1], + QQuickItemViewTransitioner::AddTransition, true); + d->transitioner->addTransitionIndexes << item->index; + d->transitioner->addTransitionTargets << item->item; + } } else { item->isNew = false; + item->index = positionedItems.count(); positionedItems.append(*item); } } } + + if (d->transitioner) { + for (int i=0; i= 0) { + d->transitioner->transitionNextReposition(&positionedItems[i], QQuickItemViewTransitioner::AddTransition, false); + } else { + // just queue the item for a move-type displace - if the item hasn't + // moved anywhere, it won't be transitioned anyway + d->transitioner->transitionNextReposition(&positionedItems[i], QQuickItemViewTransitioner::MoveTransition, false); + } + } + } + } + QSizeF contentSize(0,0); reportConflictingAnchors(); if (!d->anchorConflict) { doPositioning(&contentSize); updateAttachedProperties(); } - if (!d->addActions.isEmpty() || !d->moveActions.isEmpty()) - finishApplyTransitions(); + + if (d->transitioner) { + QRectF viewBounds; + for (int i=0; itransitioner); + } + d->transitioner->addTransitionIndexes.clear(); + d->transitioner->addTransitionTargets.clear(); + } + d->doingPositioning = false; + //Set implicit size to the size of its children setImplicitSize(contentSize.width(), contentSize.height()); } -void QQuickBasePositioner::positionX(qreal x, const PositionedItem &target) +void QQuickBasePositioner::positionItem(qreal x, qreal y, PositionedItem *target) { Q_D(QQuickBasePositioner); - if (d->type == Horizontal || d->type == Both) { - if (target.isNew) { - if (!d->addTransition || !d->addTransition->enabled()) - target.item->setX(x); - else - d->addActions << QDeclarativeAction(target.item, QLatin1String("x"), QVariant(x)); - } else if (x != target.item->x()) { - if (!d->moveTransition || !d->moveTransition->enabled()) - target.item->setX(x); - else - d->moveActions << QDeclarativeAction(target.item, QLatin1String("x"), QVariant(x)); - } + if ( (target->itemX() != x || target->itemY() != y) + && d->type == Both) { + target->moveTo(QPointF(x, y)); } } -void QQuickBasePositioner::positionY(qreal y, const PositionedItem &target) +void QQuickBasePositioner::positionItemX(qreal x, PositionedItem *target) { Q_D(QQuickBasePositioner); - if (d->type == Vertical || d->type == Both) { - if (target.isNew) { - if (!d->addTransition || !d->addTransition->enabled()) - target.item->setY(y); - else - d->addActions << QDeclarativeAction(target.item, QLatin1String("y"), QVariant(y)); - } else if (y != target.item->y()) { - if (!d->moveTransition || !d->moveTransition->enabled()) - target.item->setY(y); - else - d->moveActions << QDeclarativeAction(target.item, QLatin1String("y"), QVariant(y)); - } + if (target->itemX() != x + && (d->type == Horizontal || d->type == Both)) { + target->moveTo(QPointF(x, target->itemY())); } } -void QQuickBasePositioner::finishApplyTransitions() +void QQuickBasePositioner::positionItemY(qreal y, PositionedItem *target) { Q_D(QQuickBasePositioner); - // Note that if a transition is not set the transition manager will - // apply the changes directly, in the case add/move aren't set - d->addTransitionManager.transition(d->addActions, d->addTransition); - d->moveTransitionManager.transition(d->moveActions, d->moveTransition); - d->addActions.clear(); - d->moveActions.clear(); + if (target->itemY() != y + && (d->type == Vertical || d->type == Both)) { + target->moveTo(QPointF(target->itemX(), y)); + } } QQuickPositionerAttached *QQuickBasePositioner::qmlAttachedProperties(QObject *obj) @@ -501,30 +539,42 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem) /*! \qmlproperty Transition QtQuick2::Column::add - This property holds the transition to be applied when adding an - item to the positioner. The transition will only be applied to the - added item(s). Positioner transitions will only affect the - position (x, y) of items. + This property holds the transition to be run for items that are added to this + positioner. For a positioner, this applies to: + + \list + \o Items that are created or reparented as a child of the positioner + \o Child items that change their \l visible property from false to true, and thus + are now visible + \endlist - For a positioner, adding an item can mean that either the object - has been created or reparented, and thus is now a child or the - positioner, or that the object has changed its \l visible property - from false to true, and thus is now visible. + The transition can use the \l ViewTransition property to access more details about + the item that is being added. See the \l ViewTransition documentation for more details + and examples on using these transitions. - \sa move + \sa move, ViewTransition, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition QtQuick2::Column::move - This property holds the transition to apply to any item that has moved - within the positioner. Positioner transitions will only affect - the position (x, y) of items. + This property holds the transition to run for items that have moved within the + positioner. For a positioner, this applies to: - This transition is applied to items that are displaced as a result of the - addition or removal of other items in the positioner, or when items move due to - a move operation in a related model, or when items resize themselves. + \list + \o Child items that move when they are displaced due to the addition, removal or + rearrangement of other items in the positioner + \o Child items that are repositioned due to the resizing of other items in the positioner + \endlist + + The transition can use the \l ViewTransition property to access more details about + the item that is being moved. Note, however, that for this move transition, the + ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when + this transition is triggered by the addition of other items in the positioner; in other + cases, these lists will be empty. + + See the \l ViewTransition documentation for more details and examples on using these transitions. - \sa add, {declarative/positioners}{Positioners example} + \sa add, ViewTransition, {declarative/positioners}{Positioners example} */ /*! \qmlproperty real QtQuick2::Column::spacing @@ -545,11 +595,8 @@ void QQuickColumn::doPositioning(QSizeF *contentSize) qreal voffset = 0; for (int ii = 0; ii < positionedItems.count(); ++ii) { - const PositionedItem &child = positionedItems.at(ii); - - if (child.item->y() != voffset) - positionY(voffset, child); - + PositionedItem &child = positionedItems[ii]; + positionItemY(voffset, &child); contentSize->setWidth(qMax(contentSize->width(), child.item->width())); voffset += child.item->height(); @@ -625,42 +672,42 @@ void QQuickColumn::reportConflictingAnchors() /*! \qmlproperty Transition QtQuick2::Row::add - This property holds the transition to be applied when adding an - item to the positioner. The transition will only be applied to the - added item(s). Positioner transitions will only affect the - position (x, y) of items. + This property holds the transition to be run for items that are added to this + positioner. For a positioner, this applies to: - For a positioner, adding an item can mean that either the object - has been created or reparented, and thus is now a child or the - positioner, or that the object has changed its \l visible property - from false to true, and thus is now visible. + \list + \o Items that are created or reparented as a child of the positioner + \o Child items that change their \l visible property from false to true, and thus + are now visible + \endlist + + The transition can use the \l ViewTransition property to access more details about + the item that is being added. See the \l ViewTransition documentation for more details + and examples on using these transitions. - \sa move + \sa move, ViewTransition, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition QtQuick2::Row::move - This property holds the transition to apply to any item that has moved - within the positioner. Positioner transitions will only affect - the position (x, y) of items. - - This transition is applied to items that are displaced as a result of the - addition or removal of other items in the positioner, or when items move due to - a move operation in a related model, or when items resize themselves. - - \qml - Row { - id: positioner - move: Transition { - NumberAnimation { - properties: "x" - duration: 1000 - } - } - } - \endqml + This property holds the transition to run for items that have moved within the + positioner. For a positioner, this applies to: + + \list + \o Child items that move when they are displaced due to the addition, removal or + rearrangement of other items in the positioner + \o Child items that are repositioned due to the resizing of other items in the positioner + \endlist + + The transition can use the \l ViewTransition property to access more details about + the item that is being moved. Note, however, that for this move transition, the + ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when + this transition is triggered by the addition of other items in the positioner; in other + cases, these lists will be empty. - \sa add, {declarative/positioners}{Positioners example} + See the \l ViewTransition documentation for more details and examples on using these transitions. + + \sa add, ViewTransition, {declarative/positioners}{Positioners example} */ /*! \qmlproperty real QtQuick2::Row::spacing @@ -736,11 +783,10 @@ void QQuickRow::doPositioning(QSizeF *contentSize) QList hoffsets; for (int ii = 0; ii < positionedItems.count(); ++ii) { - const PositionedItem &child = positionedItems.at(ii); + PositionedItem &child = positionedItems[ii]; if (d->isLeftToRight()) { - if (child.item->x() != hoffset) - positionX(hoffset, child); + positionItemX(hoffset, &child); } else { hoffsets << hoffset; } @@ -767,10 +813,9 @@ void QQuickRow::doPositioning(QSizeF *contentSize) int acc = 0; for (int ii = 0; ii < positionedItems.count(); ++ii) { - const PositionedItem &child = positionedItems.at(ii); + PositionedItem &child = positionedItems[ii]; hoffset = end - hoffsets[acc++] - child.item->width(); - if (child.item->x() != hoffset) - positionX(hoffset, child); + positionItemX(hoffset, &child); } } @@ -839,41 +884,42 @@ void QQuickRow::reportConflictingAnchors() /*! \qmlproperty Transition QtQuick2::Grid::add - This property holds the transition to be applied when adding an - item to the positioner. The transition will only be applied to the - added item(s). Positioner transitions will only affect the - position (x, y) of items. + This property holds the transition to be run for items that are added to this + positioner. For a positioner, this applies to: + + \list + \o Items that are created or reparented as a child of the positioner + \o Child items that change their \l visible property from false to true, and thus + are now visible + \endlist - For a positioner, adding an item can mean that either the object - has been created or reparented, and thus is now a child or the - positioner, or that the object has changed its \l visible property - from false to true, and thus is now visible. + The transition can use the \l ViewTransition property to access more details about + the item that is being added. See the \l ViewTransition documentation for more details + and examples on using these transitions. - \sa move + \sa move, ViewTransition, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition QtQuick2::Grid::move - This property holds the transition to apply to any item that has moved - within the positioner. Positioner transitions will only affect - the position (x, y) of items. + This property holds the transition to run for items that have moved within the + positioner. For a positioner, this applies to: + + \list + \o Child items that move when they are displaced due to the addition, removal or + rearrangement of other items in the positioner + \o Child items that are repositioned due to the resizing of other items in the positioner + \endlist - This transition is applied to items that are displaced as a result of the - addition or removal of other items in the positioner, or when items move due to - a move operation in a related model, or when items resize themselves. + The transition can use the \l ViewTransition property to access more details about + the item that is being moved. Note, however, that for this move transition, the + ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when + this transition is triggered by the addition of other items in the positioner; in other + cases, these lists will be empty. - \qml - Grid { - move: Transition { - NumberAnimation { - properties: "x,y" - duration: 1000 - } - } - } - \endqml + See the \l ViewTransition documentation for more details and examples on using these transitions. - \sa add, {declarative/positioners}{Positioners example} + \sa add, ViewTransition, {declarative/positioners}{Positioners example} */ /*! \qmlproperty qreal QtQuick2::Grid::spacing @@ -1160,14 +1206,11 @@ void QQuickGrid::doPositioning(QSizeF *contentSize) int curRow =0; int curCol =0; for (int i = 0; i < positionedItems.count(); ++i) { - const PositionedItem &child = positionedItems.at(i); + PositionedItem &child = positionedItems[i]; qreal childXOffset = xoffset; if (!d->isLeftToRight()) childXOffset -= child.item->width(); - if ((child.item->x() != childXOffset) || (child.item->y() != yoffset)) { - positionX(childXOffset, child); - positionY(yoffset, child); - } + positionItem(childXOffset, yoffset, &child); if (m_flow == LeftToRight) { if (d->isLeftToRight()) @@ -1254,42 +1297,42 @@ void QQuickGrid::reportConflictingAnchors() /*! \qmlproperty Transition QtQuick2::Flow::add - This property holds the transition to be applied when adding an - item to the positioner. The transition will only be applied to the - added item(s). Positioner transitions will only affect the - position (x, y) of items. + This property holds the transition to be run for items that are added to this + positioner. For a positioner, this applies to: + + \list + \o Items that are created or reparented as a child of the positioner + \o Child items that change their \l visible property from false to true, and thus + are now visible + \endlist - For a positioner, adding an item can mean that either the object - has been created or reparented, and thus is now a child or the - positioner, or that the object has changed its \l visible property - from false to true, and thus is now visible. + The transition can use the \l ViewTransition property to access more details about + the item that is being added. See the \l ViewTransition documentation for more details + and examples on using these transitions. - \sa move + \sa move, ViewTransition, {declarative/positioners}{Positioners example} */ /*! \qmlproperty Transition QtQuick2::Flow::move - This property holds the transition to apply to any item that has moved - within the positioner. Positioner transitions will only affect - the position (x, y) of items. - - This transition is applied to items that are displaced as a result of the - addition or removal of other items in the positioner, or when items move due to - a move operation in a related model, or when items resize themselves. - - \qml - Flow { - id: positioner - move: Transition { - NumberAnimation { - properties: "x,y" - ease: "easeOutBounce" - } - } - } - \endqml + This property holds the transition to run for items that have moved within the + positioner. For a positioner, this applies to: + + \list + \o Child items that move when they are displaced due to the addition, removal or + rearrangement of other items in the positioner + \o Child items that are repositioned due to the resizing of other items in the positioner + \endlist + + The transition can use the \l ViewTransition property to access more details about + the item that is being moved. Note, however, that for this move transition, the + ViewTransition.targetIndexes and ViewTransition.targetItems lists are only set when + this transition is triggered by the addition of other items in the positioner; in other + cases, these lists will be empty. + + See the \l ViewTransition documentation for more details and examples on using these transitions. - \sa add, {declarative/positioners}{Positioners example} + \sa add, ViewTransition, {declarative/positioners}{Positioners example} */ /*! \qmlproperty real QtQuick2::Flow::spacing @@ -1414,7 +1457,7 @@ void QQuickFlow::doPositioning(QSizeF *contentSize) QList hoffsets; for (int i = 0; i < positionedItems.count(); ++i) { - const PositionedItem &child = positionedItems.at(i); + PositionedItem &child = positionedItems[i]; if (d->flow == LeftToRight) { if (widthValid() && hoffset && hoffset + child.item->width() > width()) { @@ -1431,13 +1474,11 @@ void QQuickFlow::doPositioning(QSizeF *contentSize) } if (d->isLeftToRight()) { - if (child.item->x() != hoffset) - positionX(hoffset, child); + positionItem(hoffset, voffset, &child); } else { hoffsets << hoffset; + positionItemY(voffset, &child); } - if (child.item->y() != voffset) - positionY(voffset, child); contentSize->setWidth(qMax(contentSize->width(), hoffset + child.item->width())); contentSize->setHeight(qMax(contentSize->height(), voffset + child.item->height())); @@ -1462,10 +1503,9 @@ void QQuickFlow::doPositioning(QSizeF *contentSize) end = contentSize->width(); int acc = 0; for (int i = 0; i < positionedItems.count(); ++i) { - const PositionedItem &child = positionedItems.at(i); + PositionedItem &child = positionedItems[i]; hoffset = end - hoffsets[acc++] - child.item->width(); - if (child.item->x() != hoffset) - positionX(hoffset, child); + positionItemX(hoffset, &child); } } diff --git a/src/quick/items/qquickpositioners_p.h b/src/quick/items/qquickpositioners_p.h index a4f18cfc21..32dd9030fe 100644 --- a/src/quick/items/qquickpositioners_p.h +++ b/src/quick/items/qquickpositioners_p.h @@ -43,6 +43,7 @@ #define QQUICKPOSITIONERS_P_H #include "qquickimplicitsizeitem_p.h" +#include "qquickitemviewtransition_p.h" #include #include @@ -96,6 +97,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickBasePositioner : public QQuickImplicitSizeIte Q_PROPERTY(QDeclarativeTransition *add READ add WRITE setAdd NOTIFY addChanged) public: enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 }; + QQuickBasePositioner(PositionerType, QQuickItem *parent); ~QQuickBasePositioner(); @@ -116,7 +118,6 @@ protected: QQuickBasePositioner(QQuickBasePositionerPrivate &dd, PositionerType at, QQuickItem *parent); virtual void componentComplete(); virtual void itemChange(ItemChange, const ItemChangeData &); - void finishApplyTransitions(); virtual void updatePolish(); @@ -131,19 +132,22 @@ protected Q_SLOTS: protected: virtual void doPositioning(QSizeF *contentSize)=0; virtual void reportConflictingAnchors()=0; - class PositionedItem { + + class PositionedItem : public QQuickViewItem + { public : - PositionedItem(QQuickItem *i) : item(i), isNew(false), isVisible(true) {} + PositionedItem(QQuickItem *i) : QQuickViewItem(i), isNew(false), isVisible(true) {} bool operator==(const PositionedItem &other) const { return other.item == item; } - QQuickItem *item; + bool isNew; bool isVisible; }; QPODVector positionedItems; QPODVector unpositionedItems;//Still 'in' the positioner, just not positioned - void positionX(qreal,const PositionedItem &target); - void positionY(qreal,const PositionedItem &target); + void positionItem(qreal x, qreal y, PositionedItem *target); + void positionItemX(qreal, PositionedItem *target); + void positionItemY(qreal, PositionedItem *target); private: Q_DISABLE_COPY(QQuickBasePositioner) diff --git a/src/quick/items/qquickpositioners_p_p.h b/src/quick/items/qquickpositioners_p_p.h index d281f1a372..f1d174dc0a 100644 --- a/src/quick/items/qquickpositioners_p_p.h +++ b/src/quick/items/qquickpositioners_p_p.h @@ -66,6 +66,8 @@ QT_BEGIN_NAMESPACE +class QQuickItemViewTransitioner; + class QQuickBasePositionerPrivate : public QQuickImplicitSizeItemPrivate, public QQuickItemChangeListener { Q_DECLARE_PUBLIC(QQuickBasePositioner) @@ -73,7 +75,7 @@ class QQuickBasePositionerPrivate : public QQuickImplicitSizeItemPrivate, public public: QQuickBasePositionerPrivate() : spacing(0), type(QQuickBasePositioner::None) - , moveTransition(0), addTransition(0), positioningDirty(false) + , transitioner(0), positioningDirty(false) , doingPositioning(false), anchorConflict(false), layoutDirection(Qt::LeftToRight) { } @@ -87,12 +89,7 @@ public: qreal spacing; QQuickBasePositioner::PositionerType type; - QDeclarativeTransition *moveTransition; - QDeclarativeTransition *addTransition; - QDeclarativeStateOperation::ActionList addActions; - QDeclarativeStateOperation::ActionList moveActions; - QDeclarativeTransitionManager addTransitionManager; - QDeclarativeTransitionManager moveTransitionManager; + QQuickItemViewTransitioner *transitioner; void watchChanges(QQuickItem *other); void unwatchChanges(QQuickItem* other); diff --git a/tests/auto/qtquick2/qquickpositioners/data/transitions.qml b/tests/auto/qtquick2/qquickpositioners/data/transitions.qml new file mode 100644 index 0000000000..982e64141c --- /dev/null +++ b/tests/auto/qtquick2/qquickpositioners/data/transitions.qml @@ -0,0 +1,196 @@ +import QtQuick 2.0 + +Rectangle { + id: root + width: 500 + height: 500 + + property int duration: 50 + + property int targetTransitionsDone + property int displaceTransitionsDone + + property var targetTrans_items: new Object() + property var targetTrans_targetIndexes: new Array() + property var targetTrans_targetItems: new Array() + + property var displacedTrans_items: new Object() + property var displacedTrans_targetIndexes: new Array() + property var displacedTrans_targetItems: new Array() + + // for QDeclarativeListProperty types + function copyList(propList) { + var temp = new Array() + for (var i=0; i #include #include +#include "../shared/viewtestutil.h" +#include "../shared/visualtestutil.h" #include "../../shared/util.h" +using namespace QQuickViewTestUtil; +using namespace QQuickVisualTestUtil; + class tst_qquickpositioners : public QDeclarativeDataTest { Q_OBJECT @@ -88,11 +93,145 @@ private slots: void test_attachedproperties(); void test_attachedproperties_data(); void test_attachedproperties_dynamic(); + void addTransitions_row(); + void addTransitions_row_data(); + void addTransitions_column(); + void addTransitions_column_data(); + void addTransitions_grid(); + void addTransitions_grid_data(); + void addTransitions_flow(); + void addTransitions_flow_data(); + void moveTransitions_row(); + void moveTransitions_row_data(); + void moveTransitions_column(); + void moveTransitions_column_data(); + void moveTransitions_grid(); + void moveTransitions_grid_data(); + void moveTransitions_flow(); + void moveTransitions_flow_data(); private: QQuickView *createView(const QString &filename, bool wait=true); + + void addTransitions(const QString &positionerObjectName); + void addTransitions_data(); + void moveTransitions(const QString &positionerObjectName); + void moveTransitions_data(); + void matchIndexLists(const QVariantList &indexLists, const QList &expectedIndexes); + void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes); + void matchItemLists(const QVariantList &itemLists, const QList &expectedItems); + void checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize); }; +void tst_qquickpositioners::addTransitions_row() +{ + addTransitions("row"); +} + +void tst_qquickpositioners::addTransitions_row_data() +{ + addTransitions_data(); +} + +void tst_qquickpositioners::addTransitions_column() +{ + addTransitions("column"); +} + +void tst_qquickpositioners::addTransitions_column_data() +{ + addTransitions_data(); +} + +void tst_qquickpositioners::addTransitions_grid() +{ + addTransitions("grid"); +} + +void tst_qquickpositioners::addTransitions_grid_data() +{ + // don't use addTransitions_data() because grid displaces items differently + // (adding items further down the grid can cause displace transitions at + // previous indexes, since grid is auto-resized to tightly fit all of its items) + + QTest::addColumn("initialItemCount"); + QTest::addColumn("insertionIndex"); + QTest::addColumn("insertionCount"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9); + QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(3, 3) + ListRange(5, 9); + QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange(3, 3) + ListRange(7, 7); + + QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9); + QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(1, 3) + ListRange(5, 9); + QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange(1, 3) + ListRange(5, 7) + ListRange(9, 9); +} + +void tst_qquickpositioners::addTransitions_flow() +{ + addTransitions("flow"); +} + +void tst_qquickpositioners::addTransitions_flow_data() +{ + addTransitions_data(); +} + +void tst_qquickpositioners::moveTransitions_row() +{ + moveTransitions("row"); +} + +void tst_qquickpositioners::moveTransitions_row_data() +{ + moveTransitions_data(); +} + +void tst_qquickpositioners::moveTransitions_column() +{ + moveTransitions("column"); +} + +void tst_qquickpositioners::moveTransitions_column_data() +{ + moveTransitions_data(); +} + +void tst_qquickpositioners::moveTransitions_grid() +{ + moveTransitions("grid"); +} + +void tst_qquickpositioners::moveTransitions_grid_data() +{ + // don't use moveTransitions_data() because grid displaces items differently + // (removing items further down the grid can cause displace transitions at + // previous indexes, since grid is auto-resized to tightly fit all of its items) + + QTest::addColumn("initialItemCount"); + QTest::addColumn("change"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9); + QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(2, 3) + ListRange(5, 9); + QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange(2, 3) + ListRange(6, 7); + + QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9); + QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(1, 3) + ListRange(7, 9); + QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange(1, 3) + ListRange(5, 6); +} + +void tst_qquickpositioners::moveTransitions_flow() +{ + moveTransitions("flow"); +} + +void tst_qquickpositioners::moveTransitions_flow_data() +{ + moveTransitions_data(); +} + tst_qquickpositioners::tst_qquickpositioners() { } @@ -370,6 +509,285 @@ void tst_qquickpositioners::test_horizontal_animated_disabled() delete canvas; } +void tst_qquickpositioners::addTransitions(const QString &positionerObjectName) +{ + QFETCH(int, initialItemCount); + QFETCH(int, insertionIndex); + QFETCH(int, insertionCount); + QFETCH(ListRange, expectedDisplacedIndexes); + + QPointF targetItems_transitionFrom(-50, -50); + QPointF displacedItems_transitionVia(100, 100); + + QaimModel model; + for (int i = 0; i < initialItemCount; i++) + model.addItem("Original item" + QString::number(i), ""); + QaimModel model_targetItems_transitionFrom; + QaimModel model_displacedItems_transitionVia; + + QQuickView *canvas = QQuickViewTestUtil::createView(); + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("enableAddTransition", true); + ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom); + ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); + ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom); + ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); + canvas->setSource(testFile("transitions.qml")); + canvas->show(); + qApp->processEvents(); + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + + QQuickItem *positioner = canvas->rootObject()->findChild(positionerObjectName); + QVERIFY(positioner); + positioner->findChild("repeater")->setProperty("model", QVariant::fromValue(&model)); + + QList > targetData; + QList targetIndexes; + for (int i=0; i targetItems = findItems(positioner, "wrapper", targetIndexes); + + // check initial add transition + // (positioners run the add transition on all items that are initially created for the view) + QTRY_COMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), initialItemCount); + QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), 0); + model_targetItems_transitionFrom.matchAgainst(targetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); + matchItemsAndIndexes(canvas->rootObject()->property("targetTrans_items").toMap(), model, targetIndexes); + matchIndexLists(canvas->rootObject()->property("targetTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(canvas->rootObject()->property("targetTrans_targetItems").toList(), targetItems); + + model_targetItems_transitionFrom.clear(); + canvas->rootObject()->setProperty("targetTransitionsDone", 0); + canvas->rootObject()->setProperty("targetTrans_items", QVariantMap()); + canvas->rootObject()->setProperty("targetTrans_targetIndexes", QVariantList()); + canvas->rootObject()->setProperty("targetTrans_targetItems", QVariantList()); + + // do insertion + targetData.clear(); + targetIndexes.clear(); + for (int i=insertionIndex; iproperty("count").toInt()); + + targetItems = findItems(positioner, "wrapper", targetIndexes); + + QTRY_COMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), targetData.count()); + QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.count()); + + // check the target and displaced items were animated + model_targetItems_transitionFrom.matchAgainst(targetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos"); + model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); + + // check attached properties + matchItemsAndIndexes(canvas->rootObject()->property("targetTrans_items").toMap(), model, targetIndexes); + matchIndexLists(canvas->rootObject()->property("targetTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(canvas->rootObject()->property("targetTrans_targetItems").toList(), targetItems); + if (expectedDisplacedIndexes.isValid()) { + // adjust expectedDisplacedIndexes to their final values after the move + QList displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount); + matchItemsAndIndexes(canvas->rootObject()->property("displacedTrans_items").toMap(), model, displacedIndexes); + matchIndexLists(canvas->rootObject()->property("displacedTrans_targetIndexes").toList(), targetIndexes); + matchItemLists(canvas->rootObject()->property("displacedTrans_targetItems").toList(), targetItems); + } + + checkItemPositions(positioner, &model, 5.0); // XXX fetch from qml? + + delete canvas; +} + +void tst_qquickpositioners::addTransitions_data() +{ + // If this data changes, update addTransitions_grid_data() also + + QTest::addColumn("initialItemCount"); + QTest::addColumn("insertionIndex"); + QTest::addColumn("insertionCount"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("add one @ start") << 10 << 0 << 1 << ListRange(0, 9); + QTest::newRow("add one @ middle") << 10 << 5 << 1 << ListRange(5, 9); + QTest::newRow("add one @ end") << 10 << 10 << 1 << ListRange(); + + QTest::newRow("add multiple @ start") << 10 << 0 << 3 << ListRange(0, 9); + QTest::newRow("add multiple @ middle") << 10 << 5 << 3 << ListRange(5, 9); + QTest::newRow("add multiple @ end") << 10 << 10 << 3 << ListRange(); +} + +void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName) +{ + QFETCH(int, initialItemCount); + QFETCH(ListChange, change); + QFETCH(ListRange, expectedDisplacedIndexes); + + QPointF targetItems_transitionFrom(-50, -50); + QPointF displacedItems_transitionVia(100, 100); + + QaimModel model; + for (int i = 0; i < initialItemCount; i++) + model.addItem("Item" + QString::number(i), ""); + QaimModel model_targetItems_transitionFrom; + QaimModel model_displacedItems_transitionVia; + + QQuickView *canvas = QQuickViewTestUtil::createView(); + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("enableAddTransition", false); + ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom); + ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia); + ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom); + ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia); + canvas->setSource(testFile("transitions.qml")); + canvas->show(); + qApp->processEvents(); + + QList > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); + + QQuickItem *positioner = canvas->rootObject()->findChild(positionerObjectName); + QVERIFY(positioner); + positioner->findChild("repeater")->setProperty("model", QVariant::fromValue(&model)); + QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false); + + switch (change.type) { + case ListChange::Removed: + model.removeItems(change.index, change.count); + QTRY_COMPARE(model.count(), positioner->property("count").toInt()); + break; + case ListChange::Moved: + model.moveItems(change.index, change.to, change.count); + QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false); + break; + case ListChange::Inserted: + case ListChange::SetCurrent: + case ListChange::SetContentY: + QVERIFY(false); + break; + } + + QTRY_COMPARE(canvas->rootObject()->property("displaceTransitionsDone").toInt(), expectedDisplacedIndexes.count()); + QCOMPARE(canvas->rootObject()->property("targetTransitionsDone").toInt(), 0); + + // check the target and displaced items were animated + QCOMPARE(model_targetItems_transitionFrom.count(), 0); + model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim"); + + // check attached properties + QCOMPARE(canvas->rootObject()->property("targetTrans_items").toMap().count(), 0); + QCOMPARE(canvas->rootObject()->property("targetTrans_targetIndexes").toList().count(), 0); + QCOMPARE(canvas->rootObject()->property("targetTrans_targetItems").toList().count(), 0); + if (expectedDisplacedIndexes.isValid()) { + // adjust expectedDisplacedIndexes to their final values after the move + QList displacedIndexes; + if (change.type == ListChange::Inserted) + displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, change.index, change.count); + else if (change.type == ListChange::Moved) + displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, change.index, change.to, change.count); + else if (change.type == ListChange::Removed) + displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, change.index, change.count); + else + QVERIFY(false); + matchItemsAndIndexes(canvas->rootObject()->property("displacedTrans_items").toMap(), model, displacedIndexes); + + QVariantList listOfEmptyIntLists; + for (int i=0; i()); + QCOMPARE(canvas->rootObject()->property("displacedTrans_targetIndexes").toList(), listOfEmptyIntLists); + QVariantList listOfEmptyObjectLists; + for (int i=0; irootObject()->property("displacedTrans_targetItems").toList(), listOfEmptyObjectLists); + } + + checkItemPositions(positioner, &model, 5.0); + + delete canvas; +} + +void tst_qquickpositioners::moveTransitions_data() +{ + // If this data changes, update moveTransitions_grid_data() also + + QTest::addColumn("initialItemCount"); + QTest::addColumn("change"); + QTest::addColumn("expectedDisplacedIndexes"); + + QTest::newRow("remove one @ start") << 10 << ListChange::remove(0, 1) << ListRange(1, 9); + QTest::newRow("remove one @ middle") << 10 << ListChange::remove(4, 1) << ListRange(5, 9); + QTest::newRow("remove one @ end") << 10 << ListChange::remove(9, 1) << ListRange(); + + QTest::newRow("remove multiple @ start") << 10 << ListChange::remove(0, 3) << ListRange(3, 9); + QTest::newRow("remove multiple @ middle") << 10 << ListChange::remove(4, 3) << ListRange(7, 9); + QTest::newRow("remove multiple @ end") << 10 << ListChange::remove(7, 3) << ListRange(); +} + + +void tst_qquickpositioners::checkItemPositions(QQuickItem *positioner, QaimModel *model, qreal incrementalSize) +{ + QVERIFY(model->count() > 0); + qreal padding = 0; + qreal currentSize = 30; + qreal rowX = 0; + qreal rowY = 0; + + for (int i=0; icount(); ++i) { + QQuickItem *item = findItem(positioner, "wrapper", i); + QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); + + QCOMPARE(item->width(), currentSize); + QCOMPARE(item->height(), currentSize); + + if (qobject_cast(positioner)) { + QCOMPARE(item->x(), (i * 30.0) + padding); + QCOMPARE(item->y(), 0.0); + } else if (qobject_cast(positioner)) { + QCOMPARE(item->x(), 0.0); + QCOMPARE(item->y(), (i * 30.0) + padding); + } else if (qobject_cast(positioner)) { + int columns = 4; + int rows = qCeil(model->count() / qreal(columns)); + int lastMatchingRowIndex = (rows * columns) - (columns - i%columns); + if (lastMatchingRowIndex >= model->count()) + lastMatchingRowIndex -= columns; + if (i % columns > 0) { + QQuickItem *finalAlignedRowItem = findItem(positioner, "wrapper", lastMatchingRowIndex); + QVERIFY(finalAlignedRowItem); + QCOMPARE(item->x(), finalAlignedRowItem->x()); + } else { + QCOMPARE(item->x(), 0.0); + } + if (i / columns > 0) { + QQuickItem *prevRowLastItem = findItem(positioner, "wrapper", (i/columns * columns) - 1); + QVERIFY(prevRowLastItem); + QCOMPARE(item->y(), prevRowLastItem->y() + prevRowLastItem->height()); + } else { + QCOMPARE(item->y(), 0.0); + } + } else if (qobject_cast(positioner)) { + if (rowX + item->width() > positioner->width()) { + QQuickItem *prevItem = findItem(positioner, "wrapper", i-1); + QVERIFY(prevItem); + rowX = 0; + rowY = prevItem->y() + prevItem->height(); + } + QCOMPARE(item->x(), rowX); + QCOMPARE(item->y(), rowY); + rowX += item->width(); + } else { + QVERIFY2(false, "Unknown positioner type"); + } + QQuickText *name = findItem(positioner, "name", i); + QVERIFY(name != 0); + QTRY_COMPARE(name->text(), model->name(i)); + + padding += i * incrementalSize; + currentSize += incrementalSize; + } +} + void tst_qquickpositioners::test_vertical() { QQuickView *canvas = createView(testFile("vertical.qml")); @@ -1466,6 +1884,43 @@ QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait return canvas; } +void tst_qquickpositioners::matchIndexLists(const QVariantList &indexLists, const QList &expectedIndexes) +{ + for (int i=0; i current = indexLists[i].value >().toSet(); + if (current != expectedIndexes.toSet()) + qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes; + QCOMPARE(current, expectedIndexes.toSet()); + } +} + +void tst_qquickpositioners::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList &expectedIndexes) +{ + for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) { + QVERIFY(it.value().type() == QVariant::Int); + QString name = it.key(); + int itemIndex = it.value().toInt(); + QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex))); + if (model.name(itemIndex) != name) + qDebug() << itemIndex; + QCOMPARE(model.name(itemIndex), name); + } + QCOMPARE(items.count(), expectedIndexes.count()); +} + +void tst_qquickpositioners::matchItemLists(const QVariantList &itemLists, const QList &expectedItems) +{ + for (int i=0; i(current[j].value()); + QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j))); + QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j))); + } + QCOMPARE(current.count(), expectedItems.count()); + } +} QTEST_MAIN(tst_qquickpositioners) diff --git a/tests/auto/qtquick2/shared/viewtestutil.h b/tests/auto/qtquick2/shared/viewtestutil.h index ebee1787d3..9833fcd5cc 100644 --- a/tests/auto/qtquick2/shared/viewtestutil.h +++ b/tests/auto/qtquick2/shared/viewtestutil.h @@ -174,6 +174,7 @@ namespace QQuickViewTestUtil }; } +Q_DECLARE_METATYPE(QQuickViewTestUtil::QaimModel*) Q_DECLARE_METATYPE(QQuickViewTestUtil::ListChange) Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange) -- cgit v1.2.3 From 04fb631120590c55812a11a576dca48dafec6aea Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 29 Feb 2012 13:55:58 +1000 Subject: Return correct propertyIndex for v4 bindings. Change-Id: I4aa37491d36331889f6b30c4d4af8b56cef96225 Reviewed-by: Matthew Vogt --- src/declarative/qml/v4/qv4bindings.cpp | 3 ++- src/declarative/qml/v4/qv4bindings_p.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/v4/qv4bindings.cpp b/src/declarative/qml/v4/qv4bindings.cpp index 2c26fff3d8..319dbf51bb 100644 --- a/src/declarative/qml/v4/qv4bindings.cpp +++ b/src/declarative/qml/v4/qv4bindings.cpp @@ -256,7 +256,8 @@ void QV4Bindings::Binding::destroy() int QV4Bindings::Binding::propertyIndex() const { - return property; + //mask out the type information set for value types + return property & 0xFF00FFFF; } QObject *QV4Bindings::Binding::object() const diff --git a/src/declarative/qml/v4/qv4bindings_p.h b/src/declarative/qml/v4/qv4bindings_p.h index 58dd4328af..a447481a4c 100644 --- a/src/declarative/qml/v4/qv4bindings_p.h +++ b/src/declarative/qml/v4/qv4bindings_p.h @@ -96,6 +96,8 @@ private: int index:30; bool enabled:1; bool updating:1; + // Encoding of property is coreIndex | (propType << 16) | (valueTypeIndex << 24) + // propType and valueTypeIndex are only set if the property is a value type property int property; QObject *scope; int line; -- cgit v1.2.3 From 4dde313139960d706a747d0c3260c774c3966c3d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 28 Feb 2012 16:32:45 +1000 Subject: Add QColor support to v4. Change-Id: I033e92007f894d45695ea48d7f954d534a2fadee Reviewed-by: Chris Adams Reviewed-by: Matthew Vogt Reviewed-by: Martin Jones Reviewed-by: Roberto Raggi --- src/declarative/qml/v4/qv4bindings.cpp | 76 ++++++++++++++++++++++++++++ src/declarative/qml/v4/qv4compiler.cpp | 20 ++++++++ src/declarative/qml/v4/qv4instruction.cpp | 9 ++++ src/declarative/qml/v4/qv4instruction_p.h | 3 ++ src/declarative/qml/v4/qv4ir.cpp | 3 +- src/declarative/qml/v4/qv4ir_p.h | 1 + src/declarative/qml/v4/qv4irbuilder.cpp | 3 ++ src/declarative/qml/v4/qv4program_p.h | 1 + tests/auto/declarative/v4/data/colorType.qml | 18 +++++++ tests/auto/declarative/v4/tst_v4.cpp | 18 +++++++ 10 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/v4/data/colorType.qml diff --git a/src/declarative/qml/v4/qv4bindings.cpp b/src/declarative/qml/v4/qv4bindings.cpp index 319dbf51bb..ecd18cd73f 100644 --- a/src/declarative/qml/v4/qv4bindings.cpp +++ b/src/declarative/qml/v4/qv4bindings.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -86,9 +87,11 @@ struct Register { QVariant *getvariantptr() { return (QVariant *)typeDataPtr(); } QString *getstringptr() { return (QString *)typeDataPtr(); } QUrl *geturlptr() { return (QUrl *)typeDataPtr(); } + QColor *getcolorptr() { return (QColor *)typeDataPtr(); } const QVariant *getvariantptr() const { return (QVariant *)typeDataPtr(); } const QString *getstringptr() const { return (QString *)typeDataPtr(); } const QUrl *geturlptr() const { return (QUrl *)typeDataPtr(); } + const QColor *getcolorptr() const { return (QColor *)typeDataPtr(); } void *typeDataPtr() { return (void *)&data; } void *typeMemory() { return (void *)data; } @@ -112,6 +115,7 @@ struct Register { inline void cleanup(); inline void cleanupString(); inline void cleanupUrl(); + inline void cleanupColor(); inline void cleanupVariant(); inline void copy(const Register &other); @@ -135,6 +139,8 @@ void Register::cleanup() getstringptr()->~QString(); } else if (dataType == QUrlType) { geturlptr()->~QUrl(); + } else if (dataType == QColorType) { + getcolorptr()->~QColor(); } else if (dataType == QVariantType) { getvariantptr()->~QVariant(); } @@ -154,6 +160,12 @@ void Register::cleanupUrl() setUndefined(); } +void Register::cleanupColor() +{ + getcolorptr()->~QColor(); + setUndefined(); +} + void Register::cleanupVariant() { getvariantptr()->~QVariant(); @@ -168,6 +180,8 @@ void Register::copy(const Register &other) new (getstringptr()) QString(*other.getstringptr()); else if (other.dataType == QUrlType) new (geturlptr()) QUrl(*other.geturlptr()); + else if (other.dataType == QColorType) + new (getcolorptr()) QColor(*other.getcolorptr()); else if (other.dataType == QVariantType) new (getvariantptr()) QVariant(*other.getvariantptr()); } @@ -181,6 +195,8 @@ void Register::init(Type type) new (getstringptr()) QString(); else if (dataType == QUrlType) new (geturlptr()) QUrl(); + else if (dataType == QColorType) + new (getcolorptr()) QColor(); else if (dataType == QVariantType) new (getvariantptr()) QVariant(); } @@ -663,6 +679,11 @@ inline quint32 QV4Bindings::toUint32(qreal n) MARK_REGISTER(reg); \ } +#define COLOR_REGISTER(reg) { \ + registers[(reg)].settype(QColorType); \ + MARK_REGISTER(reg); \ +} + #define VARIANT_REGISTER(reg) { \ registers[(reg)].settype(QVariantType); \ MARK_REGISTER(reg); \ @@ -1023,6 +1044,27 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks, } QML_V4_END_INSTR(ConvertStringToUrl, unaryop) + QML_V4_BEGIN_INSTR(ConvertStringToColor, unaryop) + { + const Register &src = registers[instr->unaryop.src]; + Register &output = registers[instr->unaryop.output]; + // ### NaN + if (src.isUndefined()) { + output.setUndefined(); + } else { + const QString tmp(*src.getstringptr()); + if (instr->unaryop.src == instr->unaryop.output) { + output.cleanupString(); + MARK_CLEAN_REGISTER(instr->unaryop.output); + } + QColor *colorPtr = output.getcolorptr(); + new (colorPtr) QColor(QDeclarativeStringConverters::colorFromString(tmp)); + + COLOR_REGISTER(instr->unaryop.output); + } + } + QML_V4_END_INSTR(ConvertStringToUrl, unaryop) + QML_V4_BEGIN_INSTR(ConvertUrlToBool, unaryop) { const Register &src = registers[instr->unaryop.src]; @@ -1060,6 +1102,40 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks, } QML_V4_END_INSTR(ConvertUrlToString, unaryop) + QML_V4_BEGIN_INSTR(ConvertColorToBool, unaryop) + { + const Register &src = registers[instr->unaryop.src]; + Register &output = registers[instr->unaryop.output]; + // ### NaN + if (src.isUndefined()) { + output.setUndefined(); + } else { + // for compatibility with color behavior in v8, always true + output.setbool(true); + } + } + QML_V4_END_INSTR(ConvertColorToBool, unaryop) + + QML_V4_BEGIN_INSTR(ConvertColorToString, unaryop) + { + const Register &src = registers[instr->unaryop.src]; + Register &output = registers[instr->unaryop.output]; + // ### NaN + if (src.isUndefined()) { + output.setUndefined(); + } else { + const QColor tmp(*src.getcolorptr()); + if (instr->unaryop.src == instr->unaryop.output) { + output.cleanupColor(); + MARK_CLEAN_REGISTER(instr->unaryop.output); + } + // to maintain behaviour with QtQuick 1.0, we just output normal toString() value. + new (output.getstringptr()) QString(QVariant(tmp).toString()); + STRING_REGISTER(instr->unaryop.output); + } + } + QML_V4_END_INSTR(ConvertColorToString, unaryop) + QML_V4_BEGIN_INSTR(ResolveUrl, unaryop) { const Register &src = registers[instr->unaryop.src]; diff --git a/src/declarative/qml/v4/qv4compiler.cpp b/src/declarative/qml/v4/qv4compiler.cpp index 29023ae66e..0a0269d903 100644 --- a/src/declarative/qml/v4/qv4compiler.cpp +++ b/src/declarative/qml/v4/qv4compiler.cpp @@ -344,6 +344,9 @@ void QV4CompilerPrivate::visitName(IR::Name *e) case QMetaType::QUrl: regType = QUrlType; break; + case QMetaType::QColor: + regType = QColorType; + break; default: if (propTy == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { @@ -581,6 +584,12 @@ void QV4CompilerPrivate::convertToBool(IR::Expr *expr, int reg) gen(i); } return; + case IR::ColorType: { + Instr::ConvertColorToBool i; + i.output = i.src = reg; + gen(i); + } return; + default: discard(); break; @@ -880,6 +889,7 @@ void QV4CompilerPrivate::visitMove(IR::Move *s) case IR::RealType: opcode = V4Instr::ConvertRealToBool; break; case IR::StringType: opcode = V4Instr::ConvertStringToBool; break; case IR::UrlType: opcode = V4Instr::ConvertUrlToBool; break; + case IR::ColorType: opcode = V4Instr::ConvertColorToBool; break; default: break; } // switch } else if (targetTy == IR::IntType) { @@ -908,6 +918,7 @@ void QV4CompilerPrivate::visitMove(IR::Move *s) case IR::IntType: opcode = V4Instr::ConvertIntToString; break; case IR::RealType: opcode = V4Instr::ConvertRealToString; break; case IR::UrlType: opcode = V4Instr::ConvertUrlToString; break; + case IR::ColorType: opcode = V4Instr::ConvertColorToString; break; default: break; } // switch } else if (targetTy == IR::UrlType) { @@ -920,11 +931,17 @@ void QV4CompilerPrivate::visitMove(IR::Move *s) case IR::BoolType: gen(V4Instr::ConvertBoolToString, convToString); sourceTy = IR::StringType; break; case IR::IntType: gen(V4Instr::ConvertIntToString, convToString); sourceTy = IR::StringType; break; case IR::RealType: gen(V4Instr::ConvertRealToString, convToString); sourceTy = IR::StringType; break; + case IR::ColorType: gen(V4Instr::ConvertColorToString, convToString); sourceTy = IR::StringType; break; default: break; } // switch if (sourceTy == IR::StringType) opcode = V4Instr::ConvertStringToUrl; + } else if (targetTy == IR::ColorType) { + switch (sourceTy) { + case IR::StringType: opcode = V4Instr::ConvertStringToColor; break; + default: break; + } // switch } if (opcode != V4Instr::Noop) { V4Instr conv; @@ -989,6 +1006,9 @@ void QV4CompilerPrivate::visitRet(IR::Ret *s) case IR::UrlType: test.regType = QMetaType::QUrl; break; + case IR::ColorType: + test.regType = QMetaType::QColor; + break; case IR::SGAnchorLineType: test.regType = QDeclarativeMetaType::QQuickAnchorLineMetaTypeId(); break; diff --git a/src/declarative/qml/v4/qv4instruction.cpp b/src/declarative/qml/v4/qv4instruction.cpp index d470b5b841..e9213f5e3f 100644 --- a/src/declarative/qml/v4/qv4instruction.cpp +++ b/src/declarative/qml/v4/qv4instruction.cpp @@ -171,12 +171,21 @@ void Bytecode::dump(const V4Instr *i, int address) const case V4Instr::ConvertStringToUrl: INSTR_DUMP << "\t" << "ConvertStringToUrl" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")"; break; + case V4Instr::ConvertStringToColor: + INSTR_DUMP << "\t" << "ConvertStringToColor" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")"; + break; case V4Instr::ConvertUrlToBool: INSTR_DUMP << "\t" << "ConvertUrlToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")"; break; case V4Instr::ConvertUrlToString: INSTR_DUMP << "\t" << "ConvertUrlToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")"; break; + case V4Instr::ConvertColorToBool: + INSTR_DUMP << "\t" << "ConvertColorToBool" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")"; + break; + case V4Instr::ConvertColorToString: + INSTR_DUMP << "\t" << "ConvertColorToString" << "\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")"; + break; case V4Instr::ResolveUrl: INSTR_DUMP << "\t" << "ResolveUrl" << "\t\t" << "Input_Reg(" << i->unaryop.src << ") -> Output_Reg(" << i->unaryop.output << ")"; break; diff --git a/src/declarative/qml/v4/qv4instruction_p.h b/src/declarative/qml/v4/qv4instruction_p.h index 477a085dd7..d243d3fb9d 100644 --- a/src/declarative/qml/v4/qv4instruction_p.h +++ b/src/declarative/qml/v4/qv4instruction_p.h @@ -92,8 +92,11 @@ QT_BEGIN_NAMESPACE F(ConvertStringToInt, unaryop) \ F(ConvertStringToReal, unaryop) \ F(ConvertStringToUrl, unaryop) \ + F(ConvertStringToColor, unaryop) \ F(ConvertUrlToBool, unaryop) \ F(ConvertUrlToString, unaryop) \ + F(ConvertColorToBool, unaryop) \ + F(ConvertColorToString, unaryop) \ F(ResolveUrl, unaryop) \ F(MathSinReal, unaryop) \ F(MathCosReal, unaryop) \ diff --git a/src/declarative/qml/v4/qv4ir.cpp b/src/declarative/qml/v4/qv4ir.cpp index 149479d757..6a30e93227 100644 --- a/src/declarative/qml/v4/qv4ir.cpp +++ b/src/declarative/qml/v4/qv4ir.cpp @@ -59,6 +59,7 @@ inline const char *typeName(Type t) case VoidType: return "void"; case StringType: return "string"; case UrlType: return "url"; + case ColorType: return "color"; case SGAnchorLineType: return "SGAnchorLine"; case AttachType: return "AttachType"; case ObjectType: return "object"; @@ -77,7 +78,7 @@ inline bool isNumberType(IR::Type ty) inline bool isStringType(IR::Type ty) { - return ty == IR::StringType || ty == IR::UrlType; + return ty == IR::StringType || ty == IR::UrlType || ty == IR::ColorType; } IR::Type maxType(IR::Type left, IR::Type right) diff --git a/src/declarative/qml/v4/qv4ir_p.h b/src/declarative/qml/v4/qv4ir_p.h index 746995e5be..f6aae06f44 100644 --- a/src/declarative/qml/v4/qv4ir_p.h +++ b/src/declarative/qml/v4/qv4ir_p.h @@ -142,6 +142,7 @@ enum Type { VoidType, StringType, UrlType, + ColorType, SGAnchorLineType, AttachType, ObjectType, diff --git a/src/declarative/qml/v4/qv4irbuilder.cpp b/src/declarative/qml/v4/qv4irbuilder.cpp index 522bc01684..e9f02b0c2f 100644 --- a/src/declarative/qml/v4/qv4irbuilder.cpp +++ b/src/declarative/qml/v4/qv4irbuilder.cpp @@ -69,6 +69,9 @@ static IR::Type irTypeFromVariantType(int t, QDeclarativeEnginePrivate *engine, case QMetaType::QUrl: return IR::UrlType; + case QMetaType::QColor: + return IR::ColorType; + default: if (t == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { return IR::SGAnchorLineType; diff --git a/src/declarative/qml/v4/qv4program_p.h b/src/declarative/qml/v4/qv4program_p.h index 1f37786307..6792ccb783 100644 --- a/src/declarative/qml/v4/qv4program_p.h +++ b/src/declarative/qml/v4/qv4program_p.h @@ -96,6 +96,7 @@ enum QDeclarativeRegisterType { QStringType = FirstCleanupType, QUrlType, QVariantType, + QColorType }; const char *QV4Program::data() const diff --git a/tests/auto/declarative/v4/data/colorType.qml b/tests/auto/declarative/v4/data/colorType.qml new file mode 100644 index 0000000000..f6a98a4a3e --- /dev/null +++ b/tests/auto/declarative/v4/data/colorType.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +QtObject { + property bool useMyColor: true + property color myColor: "red" + property color myOtherColor: "green" + + property color test1: useMyColor ? myColor : myOtherColor + property color test2: useMyColor ? "red" : "green" + property color test3: useMyColor ? myColor : "green" + + property bool test4: !myColor ? false : true + + property bool test5: myColor != "red" + property bool test6: myColor == "#ff0000" + property bool test7: myColor != "#00ff00" +} + diff --git a/tests/auto/declarative/v4/tst_v4.cpp b/tests/auto/declarative/v4/tst_v4.cpp index 927dc0f082..99e3f3255f 100644 --- a/tests/auto/declarative/v4/tst_v4.cpp +++ b/tests/auto/declarative/v4/tst_v4.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -73,6 +74,7 @@ private slots: void stringComparison(); void unaryMinus(); void unaryPlus(); + void colorType(); private: QDeclarativeEngine engine; @@ -348,6 +350,22 @@ void tst_v4::unaryPlus() delete o; } +void tst_v4::colorType() +{ + QDeclarativeComponent component(&engine, testFileUrl("colorType.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").value(), QColor("red")); + QCOMPARE(o->property("test2").value(), QColor("red")); + QCOMPARE(o->property("test3").value(), QColor("red")); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + QCOMPARE(o->property("test6").toBool(), true); + QCOMPARE(o->property("test7").toBool(), true); + delete o; +} + QTEST_MAIN(tst_v4) #include "tst_v4.moc" -- cgit v1.2.3 From 3c42ca87fac3326bb86a8bb816de07223b7b2e9d Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 2 Mar 2012 10:36:10 +1000 Subject: Treat parentless items as focus scopes The root item of a tree is implicitly a focus scope simply because it is the root of the tree. QQuickRootItem could gain the focus scope flag in order to solve this for most cases, but there would still be a possiblity of a crash for disconnected trees. Change-Id: I6e04f11df4268fb3b96660d50707d70935a5dc5e Reviewed-by: Martin Jones --- src/quick/items/qquickitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 04f4c1f801..7ca683fac3 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2121,7 +2121,7 @@ QQuickItem *QQuickItemPrivate::InitializationState::getFocusScope(QQuickItem *it { if (!focusScope) { QQuickItem *fs = item->parentItem(); - while (!fs->isFocusScope()) + while (fs->parentItem() && !fs->isFocusScope()) fs = fs->parentItem(); focusScope = fs; } -- cgit v1.2.3 From 82a252afdd0f920357b1e543f2ee97f92c34919b Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 1 Mar 2012 13:45:29 +0200 Subject: Use velocity from touch events only when they are valid Add the capability flags to the extended mouse events. Otherwise it is not possible to tell if the velocity is valid. While the original version is fine if velocity is guaranteed to be available whenever QT_TRANSLATE_TOUCH_TO_MOUSE is set, some platform and driver combinations, e.g. the evdevtouch plugin that comes with Qt, do not provide velocity data in touch events. The touch-only mode of QML may be very useful in these cases too, we just need to fall back to the built-in velocity calculation. Change-Id: Iec5e7632a66380dc04c9435b09f5c173107bbe00 Reviewed-by: Martin Jones --- src/quick/items/qquickcanvas.cpp | 4 ++++ src/quick/items/qquickevents_p_p.h | 14 ++++++++++++-- src/quick/items/qquickflickable.cpp | 17 +++++++++++------ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/quick/items/qquickcanvas.cpp b/src/quick/items/qquickcanvas.cpp index 670baa8df7..f135975b3c 100644 --- a/src/quick/items/qquickcanvas.cpp +++ b/src/quick/items/qquickcanvas.cpp @@ -378,6 +378,7 @@ void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event) QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseButtonDblClick, p); me.setTimestamp(event->timestamp()); me.setAccepted(false); + me.setCapabilities(event->device()->capabilities()); if (!mouseGrabberItem) { if (deliverInitialMousePressEvent(rootItem, &me)) { touchMouseId = p.id(); @@ -394,6 +395,7 @@ void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event) QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseButtonPress, p); me.setTimestamp(event->timestamp()); me.setAccepted(false); + me.setCapabilities(event->device()->capabilities()); deliverMouseEvent(&me); if (me.isAccepted()) { touchMouseId = p.id(); @@ -405,6 +407,7 @@ void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event) if (p.state() & Qt::TouchPointMoved) { QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseMove, p); me.setTimestamp(event->timestamp()); + me.setCapabilities(event->device()->capabilities()); if (!mouseGrabberItem) { if (lastMousePosition.isNull()) lastMousePosition = me.windowPos(); @@ -428,6 +431,7 @@ void QQuickCanvasPrivate::translateTouchToMouse(QTouchEvent *event) return; QQuickMouseEventEx me = touchToMouseEvent(QEvent::MouseButtonRelease, p); me.setTimestamp(event->timestamp()); + me.setCapabilities(event->device()->capabilities()); deliverMouseEvent(&me); mouseGrabberItem = 0; } diff --git a/src/quick/items/qquickevents_p_p.h b/src/quick/items/qquickevents_p_p.h index 1d13a19fed..7ff4835b4c 100644 --- a/src/quick/items/qquickevents_p_p.h +++ b/src/quick/items/qquickevents_p_p.h @@ -163,8 +163,11 @@ public: QQuickMouseEventEx(const QMouseEvent &event) : QMouseEvent(event) { - if (extended(&event)) - setVelocity(extended(&event)->velocity()); + const QQuickMouseEventEx *eventEx = extended(&event); + if (eventEx) { + setVelocity(eventEx->velocity()); + setCapabilities(eventEx->capabilities()); + } } static const QQuickMouseEventEx *extended(const QMouseEvent *e) { @@ -186,8 +189,15 @@ public: } QVector2D velocity() const { return _velocity; } + void setCapabilities(QTouchDevice::Capabilities caps) { + setExtended(); + _capabilities = caps; + } + QTouchDevice::Capabilities capabilities() const { return _capabilities; } + private: QVector2D _velocity; + QTouchDevice::Capabilities _capabilities; }; diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index 43aaf92b1a..0e8097af15 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -975,7 +975,7 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) lastPosTime = currentTimestamp; QQuickMouseEventEx *extended = QQuickMouseEventEx::extended(event); if (q->yflick() && !rejectY) { - if (extended) { + if (extended && extended->capabilities().testFlag(QTouchDevice::Velocity)) { vData.addVelocitySample(extended->velocity().y(), maxVelocity); } else { qreal dy = event->localPos().y()-lastPos.y(); @@ -983,7 +983,7 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event) } } if (q->xflick() && !rejectX) { - if (extended) { + if (extended && extended->capabilities().testFlag(QTouchDevice::Velocity)) { hData.addVelocitySample(extended->velocity().x(), maxVelocity); } else { qreal dx = event->localPos().x()-lastPos.x(); @@ -1020,7 +1020,8 @@ void QQuickFlickablePrivate::handleMouseReleaseEvent(QMouseEvent *event) qreal vVelocity = 0; if (elapsed < 100 && vData.velocity != 0.) { QQuickMouseEventEx *extended = QQuickMouseEventEx::extended(event); - vVelocity = extended ? extended->velocity().y() : vData.velocity; + vVelocity = (extended && extended->capabilities().testFlag(QTouchDevice::Velocity)) + ? extended->velocity().y() : vData.velocity; } if (vData.atBeginning || vData.atEnd) { vVelocity /= 2; @@ -1035,7 +1036,8 @@ void QQuickFlickablePrivate::handleMouseReleaseEvent(QMouseEvent *event) qreal hVelocity = 0; if (elapsed < 100 && hData.velocity != 0.) { QQuickMouseEventEx *extended = QQuickMouseEventEx::extended(event); - hVelocity = extended ? extended->velocity().x() : hData.velocity; + hVelocity = (extended && extended->capabilities().testFlag(QTouchDevice::Velocity)) + ? extended->velocity().x() : hData.velocity; } if (hData.atBeginning || hData.atEnd) { hVelocity /= 2; @@ -1769,8 +1771,11 @@ bool QQuickFlickable::sendMouseEvent(QMouseEvent *event) QQuickMouseEventEx mouseEvent(event->type(), mapFromScene(event->windowPos()), event->windowPos(), event->screenPos(), event->button(), event->buttons(), event->modifiers()); - if (QQuickMouseEventEx::extended(event)) - mouseEvent.setVelocity(QQuickMouseEventEx::extended(event)->velocity()); + QQuickMouseEventEx *eventEx = QQuickMouseEventEx::extended(event); + if (eventEx) { + mouseEvent.setVelocity(eventEx->velocity()); + mouseEvent.setCapabilities(eventEx->capabilities()); + } mouseEvent.setTimestamp(event->timestamp()); mouseEvent.setAccepted(false); -- cgit v1.2.3 From cc462d6a161b453e57523e71cd5d11deb4840f21 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 28 Feb 2012 12:00:26 +1000 Subject: Use view transitions in drag'n'drop example Change-Id: Idc661225acf9e517d26928cafba650ac48ca880a Reviewed-by: Andrew den Exter --- examples/qtquick/draganddrop/views/gridview.qml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/qtquick/draganddrop/views/gridview.qml b/examples/qtquick/draganddrop/views/gridview.qml index 04d8dee463..b18078f48d 100644 --- a/examples/qtquick/draganddrop/views/gridview.qml +++ b/examples/qtquick/draganddrop/views/gridview.qml @@ -45,6 +45,10 @@ GridView { width: 320; height: 480 cellWidth: 80; cellHeight: 80 + displaced: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.OutQuad } + } + model: VisualDataModel { id: visualModel model: ListModel { @@ -93,7 +97,7 @@ GridView { color: model.color radius: 3 - Drag.active: delegateRoot.pressed + Drag.active: delegateRoot.drag.active Drag.source: delegateRoot Drag.hotSpot.x: 36 Drag.hotSpot.y: 36 -- cgit v1.2.3 From d290cb3a499a0c3a71ab1f63cbd2fc45b0f5835f Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 27 Feb 2012 16:26:05 +1000 Subject: Fix when animating items that are already moving The view must transition displaced/moved items that are currently transitioning to another position; check against the current transition-to position, not just the current item position. Task-number: QTBUG-24522 Change-Id: Icf1c290f76ceb8c93716f1562ae0bc5a75445b78 Reviewed-by: Martin Jones --- src/quick/items/qquickitemviewtransition.cpp | 20 ++++++++++---- src/quick/items/qquickitemviewtransition_p.h | 1 + .../qquickgridview/data/multipleTransitions.qml | 28 ++++++++++++++++++- .../qtquick2/qquickgridview/tst_qquickgridview.cpp | 32 ++++++++++++++++++---- .../qquicklistview/data/multipleTransitions.qml | 27 ++++++++++++++++++ .../qtquick2/qquicklistview/tst_qquicklistview.cpp | 28 ++++++++++++++++--- 6 files changed, 121 insertions(+), 15 deletions(-) diff --git a/src/quick/items/qquickitemviewtransition.cpp b/src/quick/items/qquickitemviewtransition.cpp index abff768ad3..3febc9b113 100644 --- a/src/quick/items/qquickitemviewtransition.cpp +++ b/src/quick/items/qquickitemviewtransition.cpp @@ -383,6 +383,9 @@ bool QQuickViewItem::prepareTransition(const QRectF &viewBounds) if (nextTransitionType != QQuickItemViewTransitioner::NoTransition && !nextTransitionToSet) moveTo(item->pos()); + // For move transitions (both target and displaced) and displaced transitions of other + // types, only run the transition if the item is actually moving to another position. + switch (nextTransitionType) { case QQuickItemViewTransitioner::NoTransition: { @@ -394,14 +397,14 @@ bool QQuickViewItem::prepareTransition(const QRectF &viewBounds) } case QQuickItemViewTransitioner::AddTransition: case QQuickItemViewTransitioner::RemoveTransition: - // For Add targets, do transition if item is moving into visible area - // For Remove targets, do transition if item is currently in visible area if (viewBounds.isNull()) { if (isTransitionTarget) doTransition = true; else - doTransition = (nextTransitionTo != item->pos()); + doTransition = transitionWillChangePosition(); } else if (isTransitionTarget) { + // For Add targets, do transition if item is moving into visible area + // For Remove targets, do transition if item is currently in visible area doTransition = (nextTransitionType == QQuickItemViewTransitioner::AddTransition) ? viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height())) : viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())); @@ -410,7 +413,7 @@ bool QQuickViewItem::prepareTransition(const QRectF &viewBounds) } else { if (viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())) || viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height()))) { - doTransition = (nextTransitionTo != item->pos()); + doTransition = transitionWillChangePosition(); } else { item->setPos(nextTransitionTo); } @@ -418,7 +421,7 @@ bool QQuickViewItem::prepareTransition(const QRectF &viewBounds) break; case QQuickItemViewTransitioner::MoveTransition: // do transition if moving from or into visible area - if (nextTransitionTo != item->pos()) { + if (transitionWillChangePosition()) { doTransition = viewBounds.isNull() || viewBounds.intersects(QRectF(item->x(), item->y(), item->width(), item->height())) || viewBounds.intersects(QRectF(nextTransitionTo.x(), nextTransitionTo.y(), item->width(), item->height())); @@ -472,6 +475,13 @@ void QQuickViewItem::setNextTransition(QQuickItemViewTransitioner::TransitionTyp isTransitionTarget = isTargetItem; } +bool QQuickViewItem::transitionWillChangePosition() const +{ + if (transitionRunning() && transition->m_toPos != nextTransitionTo) + return true; + return nextTransitionTo != item->pos(); +} + void QQuickViewItem::finishedTransition() { nextTransitionToSet = false; diff --git a/src/quick/items/qquickitemviewtransition_p.h b/src/quick/items/qquickitemviewtransition_p.h index 1ebc52c185..57ea85bae6 100644 --- a/src/quick/items/qquickitemviewtransition_p.h +++ b/src/quick/items/qquickitemviewtransition_p.h @@ -152,6 +152,7 @@ private: friend class QQuickItemViewTransitioner; friend class QQuickItemViewTransitionJob; void setNextTransition(QQuickItemViewTransitioner::TransitionType, bool isTargetItem); + bool transitionWillChangePosition() const; void finishedTransition(); void resetTransitionData(); }; diff --git a/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml index 45b86e22cf..909ec3a0b7 100644 --- a/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml +++ b/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml @@ -10,7 +10,7 @@ Rectangle { // interrupting transitions will still produce the correct result) property int timeBetweenActions: duration / 2 - property int duration: 100 + property int duration: 300 property int count: grid.count @@ -46,6 +46,8 @@ Rectangle { property bool runningAddDisplaced: false property bool runningMoveTargets: false property bool runningMoveDisplaced: false + property bool runningRemoveTargets: false + property bool runningRemoveDisplaced: false objectName: "grid" width: 240 @@ -103,6 +105,30 @@ Rectangle { ScriptAction { script: grid.runningMoveDisplaced = false } } } + + remove: Transition { + id: removeTargets + SequentialAnimation { + ScriptAction { script: grid.runningRemoveTargets = true } + ParallelAnimation { + NumberAnimation { properties: "x"; to: removeTargets_transitionTo.x; duration: root.duration } + NumberAnimation { properties: "y"; to: removeTargets_transitionTo.y; duration: root.duration } + } + ScriptAction { script: grid.runningRemoveTargets = false } + } + } + + removeDisplaced: Transition { + id: removeDisplaced + SequentialAnimation { + ScriptAction { script: grid.runningRemoveDisplaced = true } + ParallelAnimation { + NumberAnimation { properties: "x"; from: removeDisplaced_transitionFrom.x; duration: root.duration } + NumberAnimation { properties: "y"; from: removeDisplaced_transitionFrom.y; duration: root.duration } + } + ScriptAction { script: grid.runningRemoveDisplaced = false } + } + } } Rectangle { diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index 6d755a64c7..077cd2b26a 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -4776,12 +4776,15 @@ void tst_QQuickGridView::multipleTransitions() QFETCH(int, initialCount); QFETCH(qreal, contentY); QFETCH(QList, changes); + QFETCH(bool, rippleAddDisplaced); // add transitions on the left, moves on the right QPointF addTargets_transitionFrom(-50, -50); QPointF addDisplaced_transitionFrom(-50, 50); QPointF moveTargets_transitionFrom(50, -50); QPointF moveDisplaced_transitionFrom(50, 50); + QPointF removeTargets_transitionTo(-100, 300); + QPointF removeDisplaced_transitionFrom(100, 300); QmlListModel model; for (int i = 0; i < initialCount; i++) @@ -4794,8 +4797,12 @@ void tst_QQuickGridView::multipleTransitions() ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom); ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom); ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom); + ctxt->setContextProperty("removeTargets_transitionTo", removeTargets_transitionTo); + ctxt->setContextProperty("removeDisplaced_transitionFrom", removeDisplaced_transitionFrom); + ctxt->setContextProperty("rippleAddDisplaced", rippleAddDisplaced); canvas->setSource(testFileUrl("multipleTransitions.qml")); canvas->show(); + QTest::qWaitForWindowShown(canvas); QQuickGridView *gridview = findItem(canvas->rootObject(), "grid"); QTRY_VERIFY(gridview != 0); @@ -4803,6 +4810,11 @@ void tst_QQuickGridView::multipleTransitions() QVERIFY(contentItem != 0); QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + if (contentY != 0) { + gridview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + } + int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt(); QList > targetItems; @@ -4894,18 +4906,21 @@ void tst_QQuickGridView::multipleTransitions_data() QTest::addColumn("initialCount"); QTest::addColumn("contentY"); QTest::addColumn >("changes"); + QTest::addColumn("rippleAddDisplaced"); // the added item and displaced items should move to final dest correctly QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList() - << ListChange::insert(0, 1) - << ListChange::move(0, 3, 1) - ); + << ListChange::insert(0, 1) + << ListChange::move(0, 3, 1) + ) + << false; // items affected by the add should change from move to add transition QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList() << ListChange::move(1, 10, 3) << ListChange::insert(0, 1) - ); + ) + << false; // items should be placed correctly if you trigger a transition then refill for that index QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList() @@ -4913,7 +4928,14 @@ void tst_QQuickGridView::multipleTransitions_data() << ListChange::setContentY(160.0) << ListChange::setContentY(0.0) << ListChange::insert(0, 1) - ); + ) + << false; + + QTest::newRow("insert then remove same index, with ripple effect on add displaced") << 20 << 0.0 << (QList() + << ListChange::insert(1, 1) + << ListChange::remove(1, 1) + ) + << true; } void tst_QQuickGridView::cacheBuffer() diff --git a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml index 3e3248535b..8264b42b64 100644 --- a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml +++ b/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml @@ -45,6 +45,8 @@ Rectangle { property bool runningAddDisplaced: false property bool runningMoveTargets: false property bool runningMoveDisplaced: false + property bool runningRemoveTargets: false + property bool runningRemoveDisplaced: false objectName: "list" focus: true @@ -70,6 +72,7 @@ Rectangle { id: addDisplaced SequentialAnimation { ScriptAction { script: list.runningAddDisplaced = true } + PauseAnimation { duration: rippleAddDisplaced ? addDisplaced.ViewTransition.index * root.duration/10 : 0 } ParallelAnimation { NumberAnimation { properties: "x"; from: addDisplaced_transitionFrom.x; duration: root.duration } NumberAnimation { properties: "y"; from: addDisplaced_transitionFrom.y; duration: root.duration } @@ -101,6 +104,30 @@ Rectangle { ScriptAction { script: list.runningMoveDisplaced = false } } } + + remove: Transition { + id: removeTargets + SequentialAnimation { + ScriptAction { script: list.runningRemoveTargets = true } + ParallelAnimation { + NumberAnimation { properties: "x"; to: removeTargets_transitionTo.x; duration: root.duration } + NumberAnimation { properties: "y"; to: removeTargets_transitionTo.y; duration: root.duration } + } + ScriptAction { script: list.runningRemoveTargets = false } + } + } + + removeDisplaced: Transition { + id: removeDisplaced + SequentialAnimation { + ScriptAction { script: list.runningRemoveDisplaced = true } + ParallelAnimation { + NumberAnimation { properties: "x"; from: removeDisplaced_transitionFrom.x; duration: root.duration } + NumberAnimation { properties: "y"; from: removeDisplaced_transitionFrom.y; duration: root.duration } + } + ScriptAction { script: list.runningRemoveDisplaced = false } + } + } } Rectangle { diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp index a834f1aa03..8f1527fa36 100644 --- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp @@ -5787,12 +5787,14 @@ void tst_QQuickListView::multipleTransitions() QFETCH(int, initialCount); QFETCH(qreal, contentY); QFETCH(QList, changes); + QFETCH(bool, rippleAddDisplaced); - // add transitions on the left, moves on the right QPointF addTargets_transitionFrom(-50, -50); QPointF addDisplaced_transitionFrom(-50, 50); QPointF moveTargets_transitionFrom(50, -50); QPointF moveDisplaced_transitionFrom(50, 50); + QPointF removeTargets_transitionTo(-100, 300); + QPointF removeDisplaced_transitionFrom(100, 300); QmlListModel model; for (int i = 0; i < initialCount; i++) @@ -5807,6 +5809,9 @@ void tst_QQuickListView::multipleTransitions() ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom); ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom); ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom); + ctxt->setContextProperty("removeTargets_transitionTo", removeTargets_transitionTo); + ctxt->setContextProperty("removeDisplaced_transitionFrom", removeDisplaced_transitionFrom); + ctxt->setContextProperty("rippleAddDisplaced", rippleAddDisplaced); canvas->setSource(testFileUrl("multipleTransitions.qml")); canvas->show(); QTest::qWaitForWindowShown(canvas); @@ -5817,6 +5822,11 @@ void tst_QQuickListView::multipleTransitions() QVERIFY(contentItem != 0); QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + if (contentY != 0) { + listview->setContentY(contentY); + QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + } + int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt(); QList > targetItems; @@ -5897,18 +5907,21 @@ void tst_QQuickListView::multipleTransitions_data() QTest::addColumn("initialCount"); QTest::addColumn("contentY"); QTest::addColumn >("changes"); + QTest::addColumn("rippleAddDisplaced"); // the added item and displaced items should move to final dest correctly QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList() << ListChange::insert(0, 1) << ListChange::move(0, 3, 1) - ); + ) + << false; // items affected by the add should change from move to add transition QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList() << ListChange::move(1, 10, 3) << ListChange::insert(0, 1) - ); + ) + << false; // items should be placed correctly if you trigger a transition then refill for that index QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList() @@ -5916,7 +5929,14 @@ void tst_QQuickListView::multipleTransitions_data() << ListChange::setContentY(80.0) << ListChange::setContentY(0.0) << ListChange::insert(0, 1) - ); + ) + << false; + + QTest::newRow("insert then remove same index, with ripple effect on add displaced") << 20 << 0.0 << (QList() + << ListChange::insert(1, 1) + << ListChange::remove(1, 1) + ) + << true; } QList tst_QQuickListView::toIntList(const QVariantList &list) -- cgit v1.2.3 From 181545935323c74c2ec9c5a89ff51606008e30c0 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 29 Feb 2012 14:59:49 +0100 Subject: Profiler: Use RAII helper structs for ranges Exclusively use RAII helper structs for ranges. Change-Id: Ief9ab25a9e49e1b2c3c091e5d9de6479e36eaa50 Reviewed-by: Christiaan Janssen --- .../debugger/qdeclarativeprofilerservice.cpp | 57 ++------ .../debugger/qdeclarativeprofilerservice_p.h | 156 ++++++++++++++++++--- src/declarative/qml/qdeclarativeboundsignal.cpp | 15 +- src/declarative/qml/qdeclarativecomponent.cpp | 21 +-- src/declarative/qml/qdeclarativecomponent_p.h | 4 +- src/declarative/qml/qdeclarativeengine.cpp | 11 +- src/declarative/qml/qdeclarativetypeloader.cpp | 6 +- .../qdeclarativeprofilerservice.pro | 2 +- 8 files changed, 180 insertions(+), 92 deletions(-) diff --git a/src/declarative/debugger/qdeclarativeprofilerservice.cpp b/src/declarative/debugger/qdeclarativeprofilerservice.cpp index 074355fe97..3ad87495bb 100644 --- a/src/declarative/debugger/qdeclarativeprofilerservice.cpp +++ b/src/declarative/debugger/qdeclarativeprofilerservice.cpp @@ -52,23 +52,10 @@ QT_BEGIN_NAMESPACE +// instance will be set, unset in constructor. Allows static methods to be inlined. +QDeclarativeProfilerService *QDeclarativeProfilerService::instance = 0; Q_GLOBAL_STATIC(QDeclarativeProfilerService, profilerInstance) -QDeclarativeBindingProfiler::QDeclarativeBindingProfiler(const QString &url, int line, int column) -{ - QDeclarativeProfilerService::startRange(QDeclarativeProfilerService::Binding); - QDeclarativeProfilerService::rangeLocation(QDeclarativeProfilerService::Binding, url, line, column); -} - -QDeclarativeBindingProfiler::~QDeclarativeBindingProfiler() -{ - QDeclarativeProfilerService::endRange(QDeclarativeProfilerService::Binding); -} - -void QDeclarativeBindingProfiler::addDetail(const QString &details) -{ - QDeclarativeProfilerService::rangeData(QDeclarativeProfilerService::Binding, details); -} // convert to a QByteArray that can be sent to the debug client // use of QDataStream can skew results @@ -106,12 +93,13 @@ QDeclarativeProfilerService::QDeclarativeProfilerService() QDeclarativeProfilerService::~QDeclarativeProfilerService() { + instance = 0; } void QDeclarativeProfilerService::initialize() { // just make sure that the service is properly registered - profilerInstance(); + instance = profilerInstance(); } bool QDeclarativeProfilerService::startProfiling() @@ -134,31 +122,6 @@ void QDeclarativeProfilerService::addEvent(EventType t) profilerInstance()->addEventImpl(t); } -void QDeclarativeProfilerService::startRange(RangeType t) -{ - profilerInstance()->startRangeImpl(t); -} - -void QDeclarativeProfilerService::rangeData(RangeType t, const QString &data) -{ - profilerInstance()->rangeDataImpl(t, data); -} - -void QDeclarativeProfilerService::rangeLocation(RangeType t, const QString &fileName, int line, int column) -{ - profilerInstance()->rangeLocationImpl(t, fileName, line, column); -} - -void QDeclarativeProfilerService::rangeLocation(RangeType t, const QUrl &fileName, int line, int column) -{ - profilerInstance()->rangeLocationImpl(t, fileName, line, column); -} - -void QDeclarativeProfilerService::endRange(RangeType t) -{ - profilerInstance()->endRangeImpl(t); -} - void QDeclarativeProfilerService::animationFrame(qint64 delta) { profilerInstance()->animationFrameImpl(delta); @@ -209,7 +172,7 @@ void QDeclarativeProfilerService::addEventImpl(EventType event) processMessage(ed); } -void QDeclarativeProfilerService::startRangeImpl(RangeType range) +void QDeclarativeProfilerService::startRange(RangeType range) { if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) return; @@ -218,7 +181,7 @@ void QDeclarativeProfilerService::startRangeImpl(RangeType range) processMessage(rd); } -void QDeclarativeProfilerService::rangeDataImpl(RangeType range, const QString &rData) +void QDeclarativeProfilerService::rangeData(RangeType range, const QString &rData) { if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) return; @@ -227,7 +190,7 @@ void QDeclarativeProfilerService::rangeDataImpl(RangeType range, const QString & processMessage(rd); } -void QDeclarativeProfilerService::rangeDataImpl(RangeType range, const QUrl &rData) +void QDeclarativeProfilerService::rangeData(RangeType range, const QUrl &rData) { if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) return; @@ -236,7 +199,7 @@ void QDeclarativeProfilerService::rangeDataImpl(RangeType range, const QUrl &rDa processMessage(rd); } -void QDeclarativeProfilerService::rangeLocationImpl(RangeType range, const QString &fileName, int line, int column) +void QDeclarativeProfilerService::rangeLocation(RangeType range, const QString &fileName, int line, int column) { if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) return; @@ -245,7 +208,7 @@ void QDeclarativeProfilerService::rangeLocationImpl(RangeType range, const QStri processMessage(rd); } -void QDeclarativeProfilerService::rangeLocationImpl(RangeType range, const QUrl &fileName, int line, int column) +void QDeclarativeProfilerService::rangeLocation(RangeType range, const QUrl &fileName, int line, int column) { if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) return; @@ -254,7 +217,7 @@ void QDeclarativeProfilerService::rangeLocationImpl(RangeType range, const QUrl processMessage(rd); } -void QDeclarativeProfilerService::endRangeImpl(RangeType range) +void QDeclarativeProfilerService::endRange(RangeType range) { if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) return; diff --git a/src/declarative/debugger/qdeclarativeprofilerservice_p.h b/src/declarative/debugger/qdeclarativeprofilerservice_p.h index d2f263cca6..ef92e6800e 100644 --- a/src/declarative/debugger/qdeclarativeprofilerservice_p.h +++ b/src/declarative/debugger/qdeclarativeprofilerservice_p.h @@ -57,6 +57,7 @@ #include #include #include +#include QT_BEGIN_HEADER @@ -83,13 +84,6 @@ Q_DECLARE_TYPEINFO(QDeclarativeProfilerData, Q_MOVABLE_TYPE); class QUrl; class QDeclarativeEngine; -// RAII -class Q_AUTOTEST_EXPORT QDeclarativeBindingProfiler { -public: - QDeclarativeBindingProfiler(const QString &url, int line, int column); - ~QDeclarativeBindingProfiler(); - void addDetail(const QString &details); -}; class Q_DECLARATIVE_EXPORT QDeclarativeProfilerService : public QDeclarativeDebugService { @@ -132,11 +126,6 @@ public: static bool stopProfiling(); static void sendStartedProfilingMessage(); static void addEvent(EventType); - static void startRange(RangeType); - static void rangeData(RangeType, const QString &); - static void rangeLocation(RangeType, const QString &, int, int); - static void rangeLocation(RangeType, const QUrl &, int, int); - static void endRange(RangeType); static void animationFrame(qint64); static void sendProfilingData(); @@ -153,14 +142,16 @@ private: bool stopProfilingImpl(); void sendStartedProfilingMessageImpl(); void addEventImpl(EventType); - void startRangeImpl(RangeType); - void rangeDataImpl(RangeType, const QString &); - void rangeDataImpl(RangeType, const QUrl &); - void rangeLocationImpl(RangeType, const QString &, int, int); - void rangeLocationImpl(RangeType, const QUrl &, int, int); - void endRangeImpl(RangeType); void animationFrameImpl(qint64); + void startRange(RangeType); + void rangeData(RangeType, const QString &); + void rangeData(RangeType, const QUrl &); + void rangeLocation(RangeType, const QString &, int, int); + void rangeLocation(RangeType, const QUrl &, int, int); + void endRange(RangeType); + + bool profilingEnabled(); void setProfilingEnabled(bool enable); void sendMessages(); @@ -172,6 +163,135 @@ private: bool m_messageReceived; QVector m_data; QMutex m_mutex; + + static QDeclarativeProfilerService *instance; + + friend struct QDeclarativeBindingProfiler; + friend struct QDeclarativeHandlingSignalProfiler; + friend struct QDeclarativeObjectCreatingProfiler; + friend struct QDeclarativeCompilingProfiler; +}; + +// +// RAII helper structs +// + +struct QDeclarativeBindingProfiler { + QDeclarativeBindingProfiler(const QString &url, int line, int column) + { + QDeclarativeProfilerService *instance = QDeclarativeProfilerService::instance; + enabled = instance ? instance->profilingEnabled() : false; + if (enabled) { + instance->startRange(QDeclarativeProfilerService::Binding); + instance->rangeLocation(QDeclarativeProfilerService::Binding, url, line, column); + } + } + + ~QDeclarativeBindingProfiler() + { + if (enabled) + QDeclarativeProfilerService::instance->endRange(QDeclarativeProfilerService::Binding); + } + + void addDetail(const QString &details) + { + if (enabled) + QDeclarativeProfilerService::instance->rangeData(QDeclarativeProfilerService::Binding, + details); + } +\ + bool enabled; +}; + +struct QDeclarativeHandlingSignalProfiler { + QDeclarativeHandlingSignalProfiler() + { + enabled = QDeclarativeProfilerService::instance + ? QDeclarativeProfilerService::instance->profilingEnabled() : false; + if (enabled) { + QDeclarativeProfilerService::instance->startRange( + QDeclarativeProfilerService::HandlingSignal); + } + } + + void setSignalInfo(const QString &name, const QString &expression) + { + if (enabled) + QDeclarativeProfilerService::instance->rangeData( + QDeclarativeProfilerService::HandlingSignal, + name % QLatin1String(": ") % expression); + } + + void setLocation(const QString &file, int line, int column) + { + if (enabled) + QDeclarativeProfilerService::instance->rangeLocation( + QDeclarativeProfilerService::HandlingSignal, file, line, column); + } + + ~QDeclarativeHandlingSignalProfiler() + { + if (enabled) + QDeclarativeProfilerService::instance->endRange( + QDeclarativeProfilerService::HandlingSignal); + } + + bool enabled; +}; + +struct QDeclarativeObjectCreatingProfiler { + QDeclarativeObjectCreatingProfiler() + { + QDeclarativeProfilerService *instance = QDeclarativeProfilerService::instance; + enabled = instance ? + instance->profilingEnabled() : false; + if (enabled) + instance->startRange(QDeclarativeProfilerService::Creating); + } + + void setTypeName(const QString &typeName) + { + if (enabled) + QDeclarativeProfilerService::instance->rangeData( + QDeclarativeProfilerService::Creating, typeName); + } + + void setLocation(const QUrl &url, int line, int column) + { + if (enabled) + QDeclarativeProfilerService::instance->rangeLocation( + QDeclarativeProfilerService::Creating, url, line, column); + } + + ~QDeclarativeObjectCreatingProfiler() + { + if (enabled) + QDeclarativeProfilerService::instance->endRange(QDeclarativeProfilerService::Creating); + } + + bool enabled; +}; + +struct QDeclarativeCompilingProfiler { + QDeclarativeCompilingProfiler(const QString &name) + { + QDeclarativeProfilerService *instance = QDeclarativeProfilerService::instance; + enabled = instance ? + instance->profilingEnabled() : false; + if (enabled) { + instance->startRange(QDeclarativeProfilerService::Compiling); + instance->rangeLocation(QDeclarativeProfilerService::Compiling, name, 1, 1); + instance->rangeData(QDeclarativeProfilerService::Compiling, name); + } + } + + ~QDeclarativeCompilingProfiler() + { + if (enabled) + QDeclarativeProfilerService::instance->endRange(QDeclarativeProfilerService::Compiling); + } + + bool enabled; }; QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp index 5d1c28b095..bf96f03016 100644 --- a/src/declarative/qml/qdeclarativeboundsignal.cpp +++ b/src/declarative/qml/qdeclarativeboundsignal.cpp @@ -170,12 +170,18 @@ int QDeclarativeBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a) if (c == QMetaObject::InvokeMetaMethod && id == evaluateIdx) { if (!m_expression) return -1; - if (QDeclarativeDebugService::isDebuggingEnabled()) { - QDeclarativeProfilerService::startRange(QDeclarativeProfilerService::HandlingSignal); - QDeclarativeProfilerService::rangeData(QDeclarativeProfilerService::HandlingSignal, QLatin1String(m_signal.signature()) % QLatin1String(": ") % m_expression->expression()); - QDeclarativeProfilerService::rangeLocation(QDeclarativeProfilerService::HandlingSignal, m_expression->sourceFile(), m_expression->lineNumber(), m_expression->columnNumber()); + + if (QDeclarativeDebugService::isDebuggingEnabled()) QV8DebugService::instance()->signalEmitted(QString::fromAscii(m_signal.signature())); + + QDeclarativeHandlingSignalProfiler prof; + if (prof.enabled) { + prof.setSignalInfo(QString::fromLatin1(m_signal.signature()), + m_expression->expression()); + prof.setLocation(m_expression->sourceFile(), m_expression->lineNumber(), + m_expression->columnNumber()); } + m_isEvaluating = true; if (!m_paramsValid) { if (!m_signal.parameterTypes().isEmpty()) @@ -191,7 +197,6 @@ int QDeclarativeBoundSignal::qt_metacall(QMetaObject::Call c, int id, void **a) } if (m_params) m_params->clearValues(); m_isEvaluating = false; - QDeclarativeProfilerService::endRange(QDeclarativeProfilerService::HandlingSignal); return -1; } else { return QObject::qt_metacall(c, id, a); diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index c168c8f4eb..57c30748f3 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -739,14 +739,15 @@ QDeclarativeComponentPrivate::beginCreate(QDeclarativeContextData *context) QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(engine); - bool isRoot = enginePriv->inProgressCreations == 0; + if (enginePriv->inProgressCreations == 0) { + // only track root, since further ones might not be properly nested + profiler = new QDeclarativeObjectCreatingProfiler(); + } + enginePriv->inProgressCreations++; state.errors.clear(); state.completePending = true; - if (isRoot) - QDeclarativeProfilerService::startRange(QDeclarativeProfilerService::Creating); - enginePriv->referenceScarceResources(); state.vme.init(context, cc, start, creationContext); QObject *rv = state.vme.execute(&state.errors); @@ -762,13 +763,12 @@ QDeclarativeComponentPrivate::beginCreate(QDeclarativeContextData *context) if (!context->isInternal) context->asQDeclarativeContextPrivate()->instances.append(rv); QDeclarativeEngineDebugService::instance()->objectCreated(engine, rv); - if (isRoot) { - QDeclarativeProfilerService::rangeData(QDeclarativeProfilerService::Creating, - buildTypeNameForDebug(rv->metaObject())); + + if (profiler && profiler->enabled) { + profiler->setTypeName(buildTypeNameForDebug(rv->metaObject())); QDeclarativeData *data = QDeclarativeData::get(rv); Q_ASSERT(data); - QDeclarativeProfilerService::rangeLocation(QDeclarativeProfilerService::Creating, - cc->url, data->lineNumber, data->columnNumber); + profiler->setLocation(cc->url, data->lineNumber, data->columnNumber); } } @@ -824,7 +824,8 @@ void QDeclarativeComponentPrivate::completeCreate() QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); complete(ep, &state); - QDeclarativeProfilerService::endRange(QDeclarativeProfilerService::Creating); + delete profiler; + profiler = 0; } } diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h index 2a237366d8..6824bd2927 100644 --- a/src/declarative/qml/qdeclarativecomponent_p.h +++ b/src/declarative/qml/qdeclarativecomponent_p.h @@ -62,6 +62,7 @@ #include "qdeclarativevme_p.h" #include "qdeclarativeerror.h" #include "qdeclarative.h" +#include "../debugger/qdeclarativeprofilerservice_p.h" #include #include @@ -83,7 +84,7 @@ class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeComponentPrivate : public QObject Q_DECLARE_PUBLIC(QDeclarativeComponent) public: - QDeclarativeComponentPrivate() : typeData(0), progress(0.), start(-1), cc(0), engine(0), creationContext(0) {} + QDeclarativeComponentPrivate() : typeData(0), progress(0.), start(-1), cc(0), engine(0), creationContext(0), profiler(0) {} QObject *beginCreate(QDeclarativeContextData *); void completeCreate(); @@ -116,6 +117,7 @@ public: QDeclarativeEngine *engine; QDeclarativeGuardedContextData creationContext; + QDeclarativeObjectCreatingProfiler *profiler; void clear(); diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index dca0ef2faf..963bec57b5 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -966,13 +966,13 @@ Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object) QDeclarativeData *data = QDeclarativeData::get(object); if (data && data->deferredComponent) { - if (QDeclarativeDebugService::isDebuggingEnabled()) { - QDeclarativeProfilerService::startRange(QDeclarativeProfilerService::Creating); + QDeclarativeObjectCreatingProfiler prof; + if (prof.enabled) { QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject()); - QString typeName = type ? type->qmlTypeName() : QString::fromUtf8(object->metaObject()->className()); - QDeclarativeProfilerService::rangeData(QDeclarativeProfilerService::Creating, typeName); + prof.setTypeName(type ? type->qmlTypeName() + : QString::fromUtf8(object->metaObject()->className())); if (data->outerContext) - QDeclarativeProfilerService::rangeLocation(QDeclarativeProfilerService::Creating, data->outerContext->url, data->lineNumber, data->columnNumber); + prof.setLocation(data->outerContext->url, data->lineNumber, data->columnNumber); } QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context->engine); @@ -983,7 +983,6 @@ Q_AUTOTEST_EXPORT void qmlExecuteDeferred(QObject *object) data->deferredComponent = 0; QDeclarativeComponentPrivate::complete(ep, &state); - QDeclarativeProfilerService::endRange(QDeclarativeProfilerService::Creating); } } diff --git a/src/declarative/qml/qdeclarativetypeloader.cpp b/src/declarative/qml/qdeclarativetypeloader.cpp index a07e4fb04b..92dac182c7 100644 --- a/src/declarative/qml/qdeclarativetypeloader.cpp +++ b/src/declarative/qml/qdeclarativetypeloader.cpp @@ -1578,13 +1578,12 @@ void QDeclarativeTypeData::downloadProgressChanged(qreal p) void QDeclarativeTypeData::compile() { Q_ASSERT(m_compiledData == 0); - QDeclarativeProfilerService::startRange(QDeclarativeProfilerService::Compiling); m_compiledData = new QDeclarativeCompiledData(typeLoader()->engine()); m_compiledData->url = finalUrl(); m_compiledData->name = finalUrlString(); - QDeclarativeProfilerService::rangeLocation(QDeclarativeProfilerService::Compiling, m_compiledData->name,1,1); - QDeclarativeProfilerService::rangeData(QDeclarativeProfilerService::Compiling, m_compiledData->name); + + QDeclarativeCompilingProfiler prof(m_compiledData->name); QDeclarativeCompiler compiler(&scriptParser._pool); if (!compiler.compile(typeLoader()->engine(), this, m_compiledData)) { @@ -1592,7 +1591,6 @@ void QDeclarativeTypeData::compile() m_compiledData->release(); m_compiledData = 0; } - QDeclarativeProfilerService::endRange(QDeclarativeProfilerService::Compiling); } void QDeclarativeTypeData::resolveTypes() diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro index 564945faf7..52139bf569 100644 --- a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro +++ b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro @@ -12,4 +12,4 @@ include (../../../shared/util.pri) CONFIG += parallel_test declarative_debug -QT += declarative-private testlib +QT += core-private v8-private declarative-private testlib -- cgit v1.2.3 From 36bd7f616f37f5f60e59bce1f0d8970248d627de Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Wed, 29 Feb 2012 10:10:11 +1000 Subject: More documentation about importing LocalStorage module from Javascript Task-number:QTBUG-24478 Change-Id: Iad0fe15e8b2f1fcfa82b1654c3fd606d08563457 Reviewed-by: Martin Jones --- doc/src/localstorage/localstorage.qdoc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/src/localstorage/localstorage.qdoc b/doc/src/localstorage/localstorage.qdoc index bee491f9b9..7f4c2b021e 100644 --- a/doc/src/localstorage/localstorage.qdoc +++ b/doc/src/localstorage/localstorage.qdoc @@ -33,9 +33,24 @@ The local storage API provides a JavaScript interface to an SQL relational database. The QtQuick.LocalStorage module contains the API and it may be given a namespace. +Import QtQuick.LocalStorage module from QML: \code -import QtQuick.LocalStorage 2.0 as SQL +//sql.qml + +import QtQuick.LocalStorage 2.0 as Sql +\endcode + + +Import QtQuick.LocalStorage module from JavaScript: +\code +//sql.js +.import QtQuick.LocalStorage 2.0 as Sql \endcode + +Note, importing a module from JavaScript is different from importing from QML. +The \l{JavaScript Code} article contains detailed information on importing in JavaScript code. + + \section2 Database API The \c openDatabaseSync() and related functions -- cgit v1.2.3